From aa92bb7745c92dc19b207d08c699e70e32430882 Mon Sep 17 00:00:00 2001 From: Sergiu Moga Date: Mon, 3 Jun 2024 13:57:23 +0300 Subject: [PATCH] plat/common/x86: Sanitize the ECTX slot on syscall entry Commit c716bcca4822 ("{lib,arch,plat}: Redo syscall ctx's and swapgs logic"), following a rework of architecture specific contexts and syscall entries, by mistake removed the ECTX sanitization at the beginning of system calls. This can result in #GP on x86 if the XSAVE header happens to be dirty. Thus, bring this sanitization back. Signed-off-by: Sergiu Moga Reviewed-by: Radu Nichita Approved-by: Razvan Deaconescu GitHub-Closes: #1444 --- plat/common/x86/syscall.S | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plat/common/x86/syscall.S b/plat/common/x86/syscall.S index 6621ab6f1..e7813f4e9 100644 --- a/plat/common/x86/syscall.S +++ b/plat/common/x86/syscall.S @@ -225,8 +225,18 @@ ENTRY(_ukplat_syscall) * Store execenv's stored ECTX which resides at offset: * sizeof(struct __regs) + sizeof(struct ukarch_sysctx) from beginning * of execenv. + * + * NOTE: Always sanitize the ECTX slot first to ensure that the XSAVE + * header is not dirty. */ addq $(__REGS_SIZEOF + UKARCH_SYSCTX_SIZE), %rdi + call ukarch_ectx_sanitize + /** + * After function calls, %rsp preserved value of execenv pointer so + * restore that into %rdi. + */ + movq %rsp, %rdi + addq $(__REGS_SIZEOF + UKARCH_SYSCTX_SIZE), %rdi call ukarch_ectx_store /** -- 2.39.5