[PATCH v2 3/3] x86/sgx: Use SGX_LAUNCH_TOKEN_SIZE in __sgx_virt_einit()

From: Thorsten Blum

Date: Wed Jul 29 2026 - 09:10:31 EST


Both sgx_ioc_enclave_init() and __sgx_virt_einit() use the same 304-byte
launch token. Use SGX_LAUNCH_TOKEN_SIZE in __sgx_virt_einit() instead of
maintaining a second local definition.

Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>
Reviewed-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
---
arch/x86/kernel/cpu/sgx/virt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c
index 6a1933ddc6fc..7c5ac5d38ee1 100644
--- a/arch/x86/kernel/cpu/sgx/virt.c
+++ b/arch/x86/kernel/cpu/sgx/virt.c
@@ -395,9 +395,8 @@ static int __sgx_virt_einit(void __user *sigstruct, void __user *token,
* All other checks deferred to ENCLS itself. Also see comment
* for @secs in sgx_virt_ecreate().
*/
-#define SGX_EINITTOKEN_SIZE 304
if (WARN_ON_ONCE(!access_ok(sigstruct, sizeof(struct sgx_sigstruct)) ||
- !access_ok(token, SGX_EINITTOKEN_SIZE) ||
+ !access_ok(token, SGX_LAUNCH_TOKEN_SIZE) ||
!access_ok(secs, PAGE_SIZE)))
return -EINVAL;