]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/sgx: Expose SGX architectural definitions to the kernel
authorSean Christopherson <sean.j.christopherson@intel.com>
Fri, 19 Mar 2021 07:23:03 +0000 (20:23 +1300)
committerBorislav Petkov <bp@suse.de>
Tue, 6 Apr 2021 07:43:41 +0000 (09:43 +0200)
Expose SGX architectural structures, as KVM will use many of the
architectural constants and structs to virtualize SGX.

Name the new header file as asm/sgx.h, rather than asm/sgx_arch.h, to
have single header to provide SGX facilities to share with other kernel
componments. Also update MAINTAINERS to include asm/sgx.h.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Co-developed-by: Kai Huang <kai.huang@intel.com>
Signed-off-by: Kai Huang <kai.huang@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Link: https://lkml.kernel.org/r/6bf47acd91ab4d709e66ad1692c7803e4c9063a0.1616136308.git.kai.huang@intel.com
MAINTAINERS
arch/x86/include/asm/sgx.h [moved from arch/x86/kernel/cpu/sgx/arch.h with 95% similarity]
arch/x86/kernel/cpu/sgx/encl.c
arch/x86/kernel/cpu/sgx/sgx.h
tools/testing/selftests/sgx/defines.h

index aa84121c56117ff16eefb996ade37e586183e985..0cb606aeba5ec311e3c733dafc8685259a27c0ed 100644 (file)
@@ -9274,6 +9274,7 @@ Q:        https://patchwork.kernel.org/project/intel-sgx/list/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/sgx
 F:     Documentation/x86/sgx.rst
 F:     arch/x86/entry/vdso/vsgx.S
+F:     arch/x86/include/asm/sgx.h
 F:     arch/x86/include/uapi/asm/sgx.h
 F:     arch/x86/kernel/cpu/sgx/*
 F:     tools/testing/selftests/sgx/*
similarity index 95%
rename from arch/x86/kernel/cpu/sgx/arch.h
rename to arch/x86/include/asm/sgx.h
index abf99bb71fdc45a71a1f81ee027098f0be462790..14bb5f7e221c070ccf5d6fd2ade03f20e93d6c03 100644 (file)
@@ -2,15 +2,20 @@
 /**
  * Copyright(c) 2016-20 Intel Corporation.
  *
- * Contains data structures defined by the SGX architecture.  Data structures
- * defined by the Linux software stack should not be placed here.
+ * Intel Software Guard Extensions (SGX) support.
  */
-#ifndef _ASM_X86_SGX_ARCH_H
-#define _ASM_X86_SGX_ARCH_H
+#ifndef _ASM_X86_SGX_H
+#define _ASM_X86_SGX_H
 
 #include <linux/bits.h>
 #include <linux/types.h>
 
+/*
+ * This file contains both data structures defined by SGX architecture and Linux
+ * defined software data structures and functions.  The two should not be mixed
+ * together for better readibility.  The architectural definitions come first.
+ */
+
 /* The SGX specific CPUID function. */
 #define SGX_CPUID              0x12
 /* EPC enumeration. */
@@ -337,4 +342,9 @@ struct sgx_sigstruct {
 
 #define SGX_LAUNCH_TOKEN_SIZE 304
 
-#endif /* _ASM_X86_SGX_ARCH_H */
+/*
+ * Do not put any hardware-defined SGX structure representations below this
+ * comment!
+ */
+
+#endif /* _ASM_X86_SGX_H */
index d25f2a245e1d61b2b1b84e7ef9bce09084557229..3be203297988f09e627388f2f69d4fb8263eaf46 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/shmem_fs.h>
 #include <linux/suspend.h>
 #include <linux/sched/mm.h>
-#include "arch.h"
+#include <asm/sgx.h>
 #include "encl.h"
 #include "encls.h"
 #include "sgx.h"
index 4854f3980edd96121c9492b69efb8e8ea9c79034..e4cbc71bf1364fc16d45dff4f4f563d715790d5b 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/rwsem.h>
 #include <linux/types.h>
 #include <asm/asm.h>
-#include "arch.h"
+#include <asm/sgx.h>
 
 #undef pr_fmt
 #define pr_fmt(fmt) "sgx: " fmt
index 592c1ccf4576d316c81b1abc76c7accd0a0e468d..0bd73428d2f3ebb8787130df22627abfbfc07ca7 100644 (file)
@@ -14,7 +14,7 @@
 #define __aligned(x) __attribute__((__aligned__(x)))
 #define __packed __attribute__((packed))
 
-#include "../../../../arch/x86/kernel/cpu/sgx/arch.h"
+#include "../../../../arch/x86/include/asm/sgx.h"
 #include "../../../../arch/x86/include/asm/enclu.h"
 #include "../../../../arch/x86/include/uapi/asm/sgx.h"