Merge tag 'x86_cleanups_for_v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / arch / x86 / include / asm / sgx.h
similarity index 89%
rename from arch/x86/kernel/cpu/sgx/arch.h
rename to arch/x86/include/asm/sgx.h
index 26315bea1cb4e99f5722230c32d7b9076bc737d9..9c31e0ebc55b14ed0ecce56f17e42636d5f2a7eb 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. */
 /* The bitmask for the EPC section type. */
 #define SGX_CPUID_EPC_MASK     GENMASK(3, 0)
 
+enum sgx_encls_function {
+       ECREATE = 0x00,
+       EADD    = 0x01,
+       EINIT   = 0x02,
+       EREMOVE = 0x03,
+       EDGBRD  = 0x04,
+       EDGBWR  = 0x05,
+       EEXTEND = 0x06,
+       ELDU    = 0x08,
+       EBLOCK  = 0x09,
+       EPA     = 0x0A,
+       EWB     = 0x0B,
+       ETRACK  = 0x0C,
+       EAUG    = 0x0D,
+       EMODPR  = 0x0E,
+       EMODT   = 0x0F,
+};
+
 /**
  * enum sgx_return_code - The return code type for ENCLS, ENCLU and ENCLV
  * %SGX_NOT_TRACKED:           Previous ETRACK's shootdown sequence has not
  *                             been completed yet.
+ * %SGX_CHILD_PRESENT          SECS has child pages present in the EPC.
  * %SGX_INVALID_EINITTOKEN:    EINITTOKEN is invalid and enclave signer's
  *                             public key does not match IA32_SGXLEPUBKEYHASH.
  * %SGX_UNMASKED_EVENT:                An unmasked event, e.g. INTR, was received
  */
 enum sgx_return_code {
        SGX_NOT_TRACKED                 = 11,
+       SGX_CHILD_PRESENT               = 13,
        SGX_INVALID_EINITTOKEN          = 16,
        SGX_UNMASKED_EVENT              = 128,
 };
@@ -335,4 +360,19 @@ 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!
+ */
+
+#ifdef CONFIG_X86_SGX_KVM
+int sgx_virt_ecreate(struct sgx_pageinfo *pageinfo, void __user *secs,
+                    int *trapnr);
+int sgx_virt_einit(void __user *sigstruct, void __user *token,
+                  void __user *secs, u64 *lepubkeyhash, int *trapnr);
+#endif
+
+int sgx_set_attribute(unsigned long *allowed_attributes,
+                     unsigned int attribute_fd);
+
+#endif /* _ASM_X86_SGX_H */