Skip to contentSkip to conversation

x86/xen: some xen_hypercall_hvm() fixes

PATCH In review Juergen Gross 3 participants 6 messages Feb 5, 2025

Subsystems (2)
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

v2 cover x86/xen: some xen_hypercall_hvm() fixes

3 fixes of the xen_hypercall_hvm() function, with the last one being probably more a cleanup.

Juergen Gross (3):
x86/xen: fix xen_hypercall_hvm() to not clobber %rbx x86/xen: add FRAME_END to xen_hypercall_hvm() x86/xen: remove unneeded dummy push from xen_hypercall_hvm()

 arch/x86/xen/xen-head.S | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/3 x86/xen: fix xen_hypercall_hvm() to not clobber %rbx

xen_hypercall_hvm(), which is used when running as a Xen PVH guest at most only once during early boot, is clobbering %rbx. Depending on whether the caller relies on %rbx to be preserved across the call or not, this clobbering might result in an early crash of the system.

This can be avoided by using an already saved register instead of %rbx.

Fixes b4845bb63838 ("x86/xen: add central hypercall functions")

---
V2:
- use %rcx instead of %rbx, keeping the lea instruction (Jan Beulich)

---
 arch/x86/xen/xen-head.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/xen/xen-head.S +2 -2
index 9252652afe59..72f28d66e0e5 100644
@@ -117,8 +117,8 @@ SYM_FUNC_START(xen_hypercall_hvm)
 	pop %ebx
 	pop %eax
 #else
-	lea xen_hypercall_amd(%rip), %rbx
-	cmp %rax, %rbx
+	lea xen_hypercall_amd(%rip), %rcx
+	cmp %rax, %rcx
 #ifdef CONFIG_FRAME_POINTER
 	pop %rax	/* Dummy pop. */
 #endif
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v2 2/3 x86/xen: add FRAME_END to xen_hypercall_hvm()

In reply to Juergen Gross

xen_hypercall_hvm() is missing a FRAME_END at the end, add it.

Fixes b4845bb63838 ("x86/xen: add central hypercall functions")
---
 arch/x86/xen/xen-head.S | 1 +
 1 file changed, 1 insertion(+)
arch/x86/xen/xen-head.S +1 -0
index 72f28d66e0e5..4e481b0eefc9 100644
@@ -132,6 +132,7 @@ SYM_FUNC_START(xen_hypercall_hvm)
 	pop %rcx
 	pop %rax
 #endif
+	FRAME_END
 	/* Use correct hypercall function. */
 	jz xen_hypercall_amd
 	jmp xen_hypercall_intel
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v2 3/3 x86/xen: remove unneeded dummy push from xen_hypercall_hvm()

In reply to Juergen Gross

Stack alignment of the kernel in 64-bit mode is 8, not 16, so the dummy push in xen_hypercall_hvm() for aligning the stack to 16 bytes can be removed.

---
 arch/x86/xen/xen-head.S | 6 ------
 1 file changed, 6 deletions(-)
arch/x86/xen/xen-head.S +0 -6
index 4e481b0eefc9..894edf8d6d62 100644
@@ -100,9 +100,6 @@ SYM_FUNC_START(xen_hypercall_hvm)
 	push %r10
 	push %r9
 	push %r8
-#ifdef CONFIG_FRAME_POINTER
-	pushq $0	/* Dummy push for stack alignment. */
-#endif
 #endif
 	/* Set the vendor specific function. */
 	call __xen_hypercall_setfunc
@@ -119,9 +116,6 @@ SYM_FUNC_START(xen_hypercall_hvm)
 #else
 	lea xen_hypercall_amd(%rip), %rcx
 	cmp %rax, %rcx
-#ifdef CONFIG_FRAME_POINTER
-	pop %rax	/* Dummy pop. */
-#endif
 	pop %r8
 	pop %r9
 	pop %r10
Signature · 1 line
2.43.0
Reviewed-by on the v2 series
#4 lore raw
In reply to Juergen Gross
Quoted 7 lines · Juergen Gross

3 fixes of the xen_hypercall_hvm() function, with the last one being probably more a cleanup.

Juergen Gross (3):
x86/xen: fix xen_hypercall_hvm() to not clobber %rbx x86/xen: add FRAME_END to xen_hypercall_hvm() x86/xen: remove unneeded dummy push from xen_hypercall_hvm()

Reviewed-by on the v2 series
#5 lore raw
In reply to Juergen Gross
Quoted 11 lines · Juergen Gross

3 fixes of the xen_hypercall_hvm() function, with the last one being probably more a cleanup.

Juergen Gross (3):
x86/xen: fix xen_hypercall_hvm() to not clobber %rbx x86/xen: add FRAME_END to xen_hypercall_hvm() x86/xen: remove unneeded dummy push from xen_hypercall_hvm()

 arch/x86/xen/xen-head.S | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)