Skip to contentSkip to conversation

x86/vdso: Use named constant for ENCLU leaves

PATCH In review Jarkko Sakkinen 1 participant 2 messages Mar 19, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/vdso: Use named constant for ENCLU leaves

Rather than using magic numbers and a comment, replace the magic numbers with named constants.

Cc Sean Christopherson <[email protected]>

---
Already pushed (as is RSA key generation). Just something noted when going through 2/8 patch.

 arch/x86/entry/vdso/vsgx_enter_enclave.S | 5 +++--
 arch/x86/include/asm/enclu.h             | 8 ++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/include/asm/enclu.h
arch/x86/entry/vdso/vsgx_enter_enclave.S +3 -2
index 22a22e0774d8..7c01a629dc7e 100644
@@ -3,6 +3,7 @@
 #include <linux/linkage.h>
 #include <asm/export.h>
 #include <asm/errno.h>
+#include <asm/enclu.h>
 
 #include "extable.h"
 
@@ -85,9 +86,9 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave)
 
 .Lenter_enclave:
 	/* EENTER <= leaf <= ERESUME */
-	cmp	$0x2, %eax
+	cmp	EENTER, %eax
 	jb	.Linvalid_leaf
-	cmp	$0x3, %eax
+	cmp	ERESUME, %eax
 	ja	.Linvalid_leaf
 
 	/* Load TCS and AEP */
arch/x86/include/asm/enclu.h new file +8 -0
new file mode 100644
index 000000000000..06157b3e9ede
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_ENCLU_H
+#define _ASM_X86_ENCLU_H
+
+#define EENTER	0x02
+#define ERESUME	0x03
+
+#endif /* _ASM_X86_ENCLU_H */
Signature · 1 line
2.25.1
#1 lore raw
Quoted 26 lines · Jarkko Sakkinen

Rather than using magic numbers and a comment, replace the magic numbers with named constants.

Cc Sean Christopherson <[email protected]>

---
Already pushed (as is RSA key generation). Just something noted when going through 2/8 patch.

 arch/x86/entry/vdso/vsgx_enter_enclave.S | 5 +++--
 arch/x86/include/asm/enclu.h             | 8 ++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/include/asm/enclu.h
arch/x86/entry/vdso/vsgx_enter_enclave.S +1 -0
index 22a22e0774d8..7c01a629dc7e 100644
@@ -3,6 +3,7 @@
 #include <linux/linkage.h>
 #include <asm/export.h>
 #include <asm/errno.h>
+#include <asm/enclu.h>
 
 #include "extable.h"
 

arch/x86/entry/vdso/vsgx_enter_enclave.S SYM_FUNC_START(__vdso_sgx_enter_enclave) · line 91

Quoted 8 lines
arch/x86/entry/vdso/vsgx_enter_enclave.S +2 -2
@@ -85,9 +86,9 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave)
 
 .Lenter_enclave:
 	/* EENTER <= leaf <= ERESUME */
-	cmp	$0x2, %eax
+	cmp	EENTER, %eax
 	jb	.Linvalid_leaf
-	cmp	$0x3, %eax
+	cmp	ERESUME, %eax

These are correct in my tree ('$').

/Jarkko