diff mbox series

[for_v23,v2,1/3] x86/vdso: sgx: Save untrusted stack before aligning %rsp

Message ID 20191017000554.11927-2-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series x86/vdso: sgx: Bug fixes for v23 | expand

Commit Message

Sean Christopherson Oct. 17, 2019, 12:05 a.m. UTC
The untrusted stack is restored from %rbx after the userspace exit
handler, but that only works if %rsp is first saved into %rbx...

Reported-by: Cedric Xing <cedric.xing@intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/entry/vdso/vsgx_enter_enclave.S | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/entry/vdso/vsgx_enter_enclave.S b/arch/x86/entry/vdso/vsgx_enter_enclave.S
index 94f613b53b13..e56737cc9f2c 100644
--- a/arch/x86/entry/vdso/vsgx_enter_enclave.S
+++ b/arch/x86/entry/vdso/vsgx_enter_enclave.S
@@ -137,6 +137,9 @@  ENTRY(__vdso_sgx_enter_enclave)
 	/* Pass the untrusted RSP (at exit) to the callback via %rcx. */
 	mov	%rsp, %rcx
 
+	/* Save the untrusted RSP in %rbx (non-volatile register). */
+	mov	%rsp, %rbx
+
 	/*
 	 * Align stack per x86_64 ABI. Note, %rsp needs to be 16-byte aligned
 	 * _after_ pushing the three parameters on the stack.