[intel-sgx-kernel-dev,1/7] intel_sgx: move ENCLS error codes from uapi/sgx.h to sgx.h
diff mbox

Message ID 20170404072938.4800-2-kai.huang@linux.intel.com
State New
Headers show

Commit Message

Kai Huang April 4, 2017, 7:29 a.m. UTC
KVM code needs to use ENCLS error codes as well, but it makes little sense
for KVM to include asm/uapi/sgx.h as it is for user application. Therefore
move ENCLS error codes to asm/sgx.h and make asm/uapi/sgx.h include it.
Probably a better way is to define new error code for user application,
instead of just using ENCLS error code, but in this case SDK needs to be
aligned as well.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
---
 arch/x86/include/asm/sgx.h      | 25 +++++++++++++++++++++++++
 arch/x86/include/uapi/asm/sgx.h | 26 +-------------------------
 2 files changed, 26 insertions(+), 25 deletions(-)

Comments

Jarkko Sakkinen April 4, 2017, 2:19 p.m. UTC | #1
On Tue, Apr 04, 2017 at 07:29:32PM +1200, Kai Huang wrote:
> KVM code needs to use ENCLS error codes as well, but it makes little sense
> for KVM to include asm/uapi/sgx.h as it is for user application. Therefore
> move ENCLS error codes to asm/sgx.h and make asm/uapi/sgx.h include it.
> Probably a better way is to define new error code for user application,
> instead of just using ENCLS error code, but in this case SDK needs to be
> aligned as well.
> 
> Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
> ---
>  arch/x86/include/asm/sgx.h      | 25 +++++++++++++++++++++++++
>  arch/x86/include/uapi/asm/sgx.h | 26 +-------------------------
>  2 files changed, 26 insertions(+), 25 deletions(-)

Why do you need this just to add KVM support? I will eventually move
these error codes but at this point this is low priority. Your cover
letter stated that the point was to make changes necessary to add KVM
support.

/Jarkko

> diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h
> index 378ad77..190e3ed 100644
> --- a/arch/x86/include/asm/sgx.h
> +++ b/arch/x86/include/asm/sgx.h
> @@ -185,6 +185,31 @@ enum {
>  	EMODT	= 0xF,
>  };
>  
> +/* SGX leaf instruction return values */
> +#define SGX_SUCCESS			0
> +#define SGX_INVALID_SIG_STRUCT		1
> +#define SGX_INVALID_ATTRIBUTE		2
> +#define SGX_BLKSTATE			3
> +#define SGX_INVALID_MEASUREMENT		4
> +#define SGX_NOTBLOCKABLE		5
> +#define SGX_PG_INVLD			6
> +#define SGX_LOCKFAIL			7
> +#define SGX_INVALID_SIGNATURE		8
> +#define SGX_MAC_COMPARE_FAIL		9
> +#define SGX_PAGE_NOT_BLOCKED		10
> +#define SGX_NOT_TRACKED			11
> +#define SGX_VA_SLOT_OCCUPIED		12
> +#define SGX_CHILD_PRESENT		13
> +#define SGX_ENCLAVE_ACT			14
> +#define SGX_ENTRYEPOCH_LOCKED		15
> +#define SGX_INVALID_LICENSE		16
> +#define SGX_PREV_TRK_INCMPL		17
> +#define SGX_PG_IS_SECS			18
> +#define SGX_INVALID_CPUSVN		32
> +#define SGX_INVALID_ISVSVN		64
> +#define SGX_UNMASKED_EVENT		128
> +#define SGX_INVALID_KEYNAME		256
> +
>  #define __encls_ret(rax, rbx, rcx, rdx)			\
>  	({						\
>  	int ret;					\
> diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h
> index 503f6be..b5bd5c3 100644
> --- a/arch/x86/include/uapi/asm/sgx.h
> +++ b/arch/x86/include/uapi/asm/sgx.h
> @@ -62,6 +62,7 @@
>  
>  #include <linux/types.h>
>  #include <linux/ioctl.h>
> +#include <asm/sgx.h>
>  
>  #define SGX_MAGIC 0xA4
>  
> @@ -72,31 +73,6 @@
>  #define SGX_IOC_ENCLAVE_INIT \
>  	_IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
>  
> -/* SGX leaf instruction return values */
> -#define SGX_SUCCESS			0
> -#define SGX_INVALID_SIG_STRUCT		1
> -#define SGX_INVALID_ATTRIBUTE		2
> -#define SGX_BLKSTATE			3
> -#define SGX_INVALID_MEASUREMENT		4
> -#define SGX_NOTBLOCKABLE		5
> -#define SGX_PG_INVLD			6
> -#define SGX_LOCKFAIL			7
> -#define SGX_INVALID_SIGNATURE		8
> -#define SGX_MAC_COMPARE_FAIL		9
> -#define SGX_PAGE_NOT_BLOCKED		10
> -#define SGX_NOT_TRACKED			11
> -#define SGX_VA_SLOT_OCCUPIED		12
> -#define SGX_CHILD_PRESENT		13
> -#define SGX_ENCLAVE_ACT			14
> -#define SGX_ENTRYEPOCH_LOCKED		15
> -#define SGX_INVALID_LICENSE		16
> -#define SGX_PREV_TRK_INCMPL		17
> -#define SGX_PG_IS_SECS			18
> -#define SGX_INVALID_CPUSVN		32
> -#define SGX_INVALID_ISVSVN		64
> -#define SGX_UNMASKED_EVENT		128
> -#define SGX_INVALID_KEYNAME		256
> -
>  /* IOCTL return values */
>  #define SGX_POWER_LOST_ENCLAVE		0x40000000
>  #define SGX_LE_ROLLBACK			0x40000001
> -- 
> 2.9.3
>
Kai Huang April 4, 2017, 11:18 p.m. UTC | #2
On 4/5/2017 2:19 AM, Jarkko Sakkinen wrote:
> On Tue, Apr 04, 2017 at 07:29:32PM +1200, Kai Huang wrote:
>> KVM code needs to use ENCLS error codes as well, but it makes little sense
>> for KVM to include asm/uapi/sgx.h as it is for user application. Therefore
>> move ENCLS error codes to asm/sgx.h and make asm/uapi/sgx.h include it.
>> Probably a better way is to define new error code for user application,
>> instead of just using ENCLS error code, but in this case SDK needs to be
>> aligned as well.
>>
>> Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
>> ---
>>  arch/x86/include/asm/sgx.h      | 25 +++++++++++++++++++++++++
>>  arch/x86/include/uapi/asm/sgx.h | 26 +-------------------------
>>  2 files changed, 26 insertions(+), 25 deletions(-)
>
> Why do you need this just to add KVM support? I will eventually move
> these error codes but at this point this is low priority. Your cover
> letter stated that the point was to make changes necessary to add KVM
> support.

KVM needs to use those error codes as well. For example, SGX_PG_INVLD, 
SGX_LOCKFAIL, SGX_NOT_TRACKED, etc. Without this patch KVM needs to 
include uapi/asm/sgx.h (you don't want KVM to define those error codes 
again by itself, do you?), but as I explained to me it makes little 
sense for KVM to include uapi/asm/sgx.h so I moved the error codes to 
asm/sgx.h (KVM needs to use other staff in asm/sgx.h anyway). If you 
think it's reasonable for KVM to include both asm/sgx.h and 
uapi/asm/sgx.h then I am fine with dropping this patch, but I am not 
sure KVM community likes this or not.

Thanks,
-Kai

>
> /Jarkko
>
>> diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h
>> index 378ad77..190e3ed 100644
>> --- a/arch/x86/include/asm/sgx.h
>> +++ b/arch/x86/include/asm/sgx.h
>> @@ -185,6 +185,31 @@ enum {
>>  	EMODT	= 0xF,
>>  };
>>
>> +/* SGX leaf instruction return values */
>> +#define SGX_SUCCESS			0
>> +#define SGX_INVALID_SIG_STRUCT		1
>> +#define SGX_INVALID_ATTRIBUTE		2
>> +#define SGX_BLKSTATE			3
>> +#define SGX_INVALID_MEASUREMENT		4
>> +#define SGX_NOTBLOCKABLE		5
>> +#define SGX_PG_INVLD			6
>> +#define SGX_LOCKFAIL			7
>> +#define SGX_INVALID_SIGNATURE		8
>> +#define SGX_MAC_COMPARE_FAIL		9
>> +#define SGX_PAGE_NOT_BLOCKED		10
>> +#define SGX_NOT_TRACKED			11
>> +#define SGX_VA_SLOT_OCCUPIED		12
>> +#define SGX_CHILD_PRESENT		13
>> +#define SGX_ENCLAVE_ACT			14
>> +#define SGX_ENTRYEPOCH_LOCKED		15
>> +#define SGX_INVALID_LICENSE		16
>> +#define SGX_PREV_TRK_INCMPL		17
>> +#define SGX_PG_IS_SECS			18
>> +#define SGX_INVALID_CPUSVN		32
>> +#define SGX_INVALID_ISVSVN		64
>> +#define SGX_UNMASKED_EVENT		128
>> +#define SGX_INVALID_KEYNAME		256
>> +
>>  #define __encls_ret(rax, rbx, rcx, rdx)			\
>>  	({						\
>>  	int ret;					\
>> diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h
>> index 503f6be..b5bd5c3 100644
>> --- a/arch/x86/include/uapi/asm/sgx.h
>> +++ b/arch/x86/include/uapi/asm/sgx.h
>> @@ -62,6 +62,7 @@
>>
>>  #include <linux/types.h>
>>  #include <linux/ioctl.h>
>> +#include <asm/sgx.h>
>>
>>  #define SGX_MAGIC 0xA4
>>
>> @@ -72,31 +73,6 @@
>>  #define SGX_IOC_ENCLAVE_INIT \
>>  	_IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
>>
>> -/* SGX leaf instruction return values */
>> -#define SGX_SUCCESS			0
>> -#define SGX_INVALID_SIG_STRUCT		1
>> -#define SGX_INVALID_ATTRIBUTE		2
>> -#define SGX_BLKSTATE			3
>> -#define SGX_INVALID_MEASUREMENT		4
>> -#define SGX_NOTBLOCKABLE		5
>> -#define SGX_PG_INVLD			6
>> -#define SGX_LOCKFAIL			7
>> -#define SGX_INVALID_SIGNATURE		8
>> -#define SGX_MAC_COMPARE_FAIL		9
>> -#define SGX_PAGE_NOT_BLOCKED		10
>> -#define SGX_NOT_TRACKED			11
>> -#define SGX_VA_SLOT_OCCUPIED		12
>> -#define SGX_CHILD_PRESENT		13
>> -#define SGX_ENCLAVE_ACT			14
>> -#define SGX_ENTRYEPOCH_LOCKED		15
>> -#define SGX_INVALID_LICENSE		16
>> -#define SGX_PREV_TRK_INCMPL		17
>> -#define SGX_PG_IS_SECS			18
>> -#define SGX_INVALID_CPUSVN		32
>> -#define SGX_INVALID_ISVSVN		64
>> -#define SGX_UNMASKED_EVENT		128
>> -#define SGX_INVALID_KEYNAME		256
>> -
>>  /* IOCTL return values */
>>  #define SGX_POWER_LOST_ENCLAVE		0x40000000
>>  #define SGX_LE_ROLLBACK			0x40000001
>> --
>> 2.9.3
>>
> _______________________________________________
> intel-sgx-kernel-dev mailing list
> intel-sgx-kernel-dev@lists.01.org
> https://lists.01.org/mailman/listinfo/intel-sgx-kernel-dev
>

Patch
diff mbox

diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h
index 378ad77..190e3ed 100644
--- a/arch/x86/include/asm/sgx.h
+++ b/arch/x86/include/asm/sgx.h
@@ -185,6 +185,31 @@  enum {
 	EMODT	= 0xF,
 };
 
+/* SGX leaf instruction return values */
+#define SGX_SUCCESS			0
+#define SGX_INVALID_SIG_STRUCT		1
+#define SGX_INVALID_ATTRIBUTE		2
+#define SGX_BLKSTATE			3
+#define SGX_INVALID_MEASUREMENT		4
+#define SGX_NOTBLOCKABLE		5
+#define SGX_PG_INVLD			6
+#define SGX_LOCKFAIL			7
+#define SGX_INVALID_SIGNATURE		8
+#define SGX_MAC_COMPARE_FAIL		9
+#define SGX_PAGE_NOT_BLOCKED		10
+#define SGX_NOT_TRACKED			11
+#define SGX_VA_SLOT_OCCUPIED		12
+#define SGX_CHILD_PRESENT		13
+#define SGX_ENCLAVE_ACT			14
+#define SGX_ENTRYEPOCH_LOCKED		15
+#define SGX_INVALID_LICENSE		16
+#define SGX_PREV_TRK_INCMPL		17
+#define SGX_PG_IS_SECS			18
+#define SGX_INVALID_CPUSVN		32
+#define SGX_INVALID_ISVSVN		64
+#define SGX_UNMASKED_EVENT		128
+#define SGX_INVALID_KEYNAME		256
+
 #define __encls_ret(rax, rbx, rcx, rdx)			\
 	({						\
 	int ret;					\
diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h
index 503f6be..b5bd5c3 100644
--- a/arch/x86/include/uapi/asm/sgx.h
+++ b/arch/x86/include/uapi/asm/sgx.h
@@ -62,6 +62,7 @@ 
 
 #include <linux/types.h>
 #include <linux/ioctl.h>
+#include <asm/sgx.h>
 
 #define SGX_MAGIC 0xA4
 
@@ -72,31 +73,6 @@ 
 #define SGX_IOC_ENCLAVE_INIT \
 	_IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
 
-/* SGX leaf instruction return values */
-#define SGX_SUCCESS			0
-#define SGX_INVALID_SIG_STRUCT		1
-#define SGX_INVALID_ATTRIBUTE		2
-#define SGX_BLKSTATE			3
-#define SGX_INVALID_MEASUREMENT		4
-#define SGX_NOTBLOCKABLE		5
-#define SGX_PG_INVLD			6
-#define SGX_LOCKFAIL			7
-#define SGX_INVALID_SIGNATURE		8
-#define SGX_MAC_COMPARE_FAIL		9
-#define SGX_PAGE_NOT_BLOCKED		10
-#define SGX_NOT_TRACKED			11
-#define SGX_VA_SLOT_OCCUPIED		12
-#define SGX_CHILD_PRESENT		13
-#define SGX_ENCLAVE_ACT			14
-#define SGX_ENTRYEPOCH_LOCKED		15
-#define SGX_INVALID_LICENSE		16
-#define SGX_PREV_TRK_INCMPL		17
-#define SGX_PG_IS_SECS			18
-#define SGX_INVALID_CPUSVN		32
-#define SGX_INVALID_ISVSVN		64
-#define SGX_UNMASKED_EVENT		128
-#define SGX_INVALID_KEYNAME		256
-
 /* IOCTL return values */
 #define SGX_POWER_LOST_ENCLAVE		0x40000000
 #define SGX_LE_ROLLBACK			0x40000001