summaryrefslogtreecommitdiff
path: root/arch/x86/virt
diff options
context:
space:
mode:
authorKai Huang <kai.huang@intel.com>2023-08-15 14:02:02 +0300
committerDave Hansen <dave.hansen@linux.intel.com>2023-09-13 02:30:14 +0300
commit90f5ecd37faed9a59eb2788a56dac8deeee0a508 (patch)
tree2c100cb8bc92233b7d5fbabb92480463c6b73069 /arch/x86/virt
parentc641cfb5c157b6c3062a824fd8ba190bf06fb952 (diff)
downloadlinux-90f5ecd37faed9a59eb2788a56dac8deeee0a508.tar.xz
x86/tdx: Reimplement __tdx_hypercall() using TDX_MODULE_CALL asm
Now the TDX_HYPERCALL asm is basically identical to the TDX_MODULE_CALL with both '\saved' and '\ret' enabled, with two minor things though: 1) The way to restore the structure pointer is different The TDX_HYPERCALL uses RCX as spare to restore the structure pointer, but the TDX_MODULE_CALL assumes no spare register can be used. In other words, TDX_MODULE_CALL already covers what TDX_HYPERCALL does. 2) TDX_MODULE_CALL only clears shared registers for TDH.VP.ENTER For this just need to make that code available for the non-host case. Thus, remove the TDX_HYPERCALL and reimplement the __tdx_hypercall() using the TDX_MODULE_CALL. Extend the TDX_MODULE_CALL to cover "clear shared registers" for TDG.VP.VMCALL. Introduce a new __tdcall_saved_ret() to replace the temporary __tdcall_hypercall(). The __tdcall_saved_ret() can also be used for those new TDCALLs which require more input/output registers than the basic TDCALLs do. Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Kai Huang <kai.huang@intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/all/e68a2473fb6f5bcd78b078cae7510e9d0753b3df.1692096753.git.kai.huang%40intel.com
Diffstat (limited to 'arch/x86/virt')
-rw-r--r--arch/x86/virt/vmx/tdx/tdxcall.S8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S
index c54ea009b241..3f0b83a9977e 100644
--- a/arch/x86/virt/vmx/tdx/tdxcall.S
+++ b/arch/x86/virt/vmx/tdx/tdxcall.S
@@ -142,10 +142,10 @@
movq %r11, TDX_MODULE_r11(%rsi)
.endif /* \ret */
-.if \host && \saved && \ret
+.if \saved && \ret
/*
- * Clear registers shared by guest for VP.ENTER to prevent
- * speculative use of guest's values, including those are
+ * Clear registers shared by guest for VP.VMCALL/VP.ENTER to prevent
+ * speculative use of guest's/VMM's values, including those are
* restored from the stack.
*
* See arch/x86/kvm/vmx/vmenter.S:
@@ -170,7 +170,7 @@
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %edi, %edi
-.endif /* \host && \ret && \host */
+.endif /* \ret && \host */
.if \host
.Lout\@: