Fix a recently introduced bug where an odd number of 8-byte parameters are pushed on the stack prior to invoking the userspace callback, which causes the CALL to execute with an unaligned stack and violate the x86_64 ABI. Reported-by: Cedric Xing <cedric.xing@xxxxxxxxx> Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> --- arch/x86/entry/vdso/vsgx_enter_enclave.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vsgx_enter_enclave.S b/arch/x86/entry/vdso/vsgx_enter_enclave.S index fc5622dcd2fa..b63091818df1 100644 --- a/arch/x86/entry/vdso/vsgx_enter_enclave.S +++ b/arch/x86/entry/vdso/vsgx_enter_enclave.S @@ -135,10 +135,12 @@ ENTRY(__vdso_sgx_enter_enclave) .Linvoke_userspace_handler: /* * Align stack per x86_64 ABI. Save the original %rsp in %rbx to be - * restored after the callback returns. + * restored after the callback returns. Note, %rsp needs to be 16-byte + * aligned _after_ pushing the three parameters on the stack. */ mov %rsp, %rbx and $-0x10, %rsp + sub $0x8, %rsp /* Push @e, u_rsp and @tcs as parameters to the callback. */ push 0x18(%rbp) -- 2.22.0