public inbox for linux-coco@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] x86/kvm/tdx: Save %rbp in TDX_MODULE_CALL
@ 2024-05-17 12:14 Juergen Gross
  2024-05-17 13:55 ` Kirill A. Shutemov
  0 siblings, 1 reply; 24+ messages in thread
From: Juergen Gross @ 2024-05-17 12:14 UTC (permalink / raw)
  To: linux-kernel, x86, linux-coco
  Cc: Juergen Gross, Kirill A. Shutemov, Dave Hansen, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin

While testing TDX host support patches, a crash of the host has been
observed a few instructions after doing a seamcall. Reason was a
clobbered %rbp (set to 0), which occurred in spite of the TDX module
offering the feature NOT to modify %rbp across TDX module calls.

In order not having to build the host kernel with CONFIG_FRAME_POINTER,
save %rbp across a seamcall/tdcall.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/virt/vmx/tdx/tdxcall.S | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S
index 016a2a1ec1d6..68728acf0d3a 100644
--- a/arch/x86/virt/vmx/tdx/tdxcall.S
+++ b/arch/x86/virt/vmx/tdx/tdxcall.S
@@ -44,6 +44,10 @@
  */
 .macro TDX_MODULE_CALL host:req ret=0 saved=0
 	FRAME_BEGIN
+#ifndef CONFIG_FRAME_POINTER
+	/* Buggy firmware sometimes clobbers %rbp, so save it. */
+	pushq	%rbp
+#endif
 
 	/* Move Leaf ID to RAX */
 	mov %rdi, %rax
@@ -187,6 +191,9 @@
 	popq	%rbx
 .endif	/* \saved */
 
+#ifndef CONFIG_FRAME_POINTER
+	popq	%rbp
+#endif
 	FRAME_END
 	RET
 
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2024-05-24  5:46 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 12:14 [PATCH] x86/kvm/tdx: Save %rbp in TDX_MODULE_CALL Juergen Gross
2024-05-17 13:55 ` Kirill A. Shutemov
2024-05-17 14:08   ` Juergen Gross
2024-05-17 14:39     ` Kirill A. Shutemov
2024-05-17 14:41       ` Kirill A. Shutemov
2024-05-17 14:44       ` Juergen Gross
2024-05-17 15:16         ` Dave Hansen
2024-05-17 15:27           ` Jürgen Groß
2024-05-17 15:43             ` Dave Hansen
2024-05-17 15:48               ` Juergen Gross
2024-05-17 15:52                 ` Dave Hansen
2024-05-17 15:58                   ` Juergen Gross
2024-05-17 16:48                     ` Dave Hansen
2024-05-20 11:54                       ` Huang, Kai
2024-05-23  5:56                         ` Jürgen Groß
2024-05-23 10:30                           ` Huang, Kai
2024-05-23 12:26                             ` Huang, Kai
2024-05-23 12:43                               ` Jürgen Groß
2024-05-23 22:34                                 ` Huang, Kai
2024-05-23 23:28                                   ` Huang, Kai
2024-05-24  5:46                                   ` Jürgen Groß
2024-05-17 16:12   ` Sean Christopherson
2024-05-17 16:34     ` Dave Hansen
2024-05-17 17:01       ` Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox