Skip to contentSkip to conversation

drop wrappers of SVM instructions

PATCH In review Alexander M. Merritt 2 participants 4 messages Apr 2, 2025

lore
Share & tools
lore
#0 lore raw

cover drop wrappers of SVM instructions

Part of cleanup following toolchain baseline upgrade.

As the new toolchain baseline knows the SVM instructions, this series drops macros with SVM instructions, and updates SVM wrappers to use real instructions rather than bytecode.

Resolves: xen-project/xen#204

Alexander M. Merritt (1):
xen/x86: drop wrappers of SVM instructions

 xen/arch/x86/hvm/svm/svm.h           | 14 +++-----------
 xen/arch/x86/include/asm/asm-defns.h | 12 ------------
 2 files changed, 3 insertions(+), 23 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/1 xen/x86: drop wrappers of SVM instructions

The new toolchain baseline knows the SVM instructions.

Resolves: xen-project/xen#204

---
 xen/arch/x86/hvm/svm/svm.h           | 14 +++-----------
 xen/arch/x86/include/asm/asm-defns.h | 12 ------------
 2 files changed, 3 insertions(+), 23 deletions(-)
xen/arch/x86/hvm/svm/svm.h +3 -11
index beeaaab4f7..5c5e91a1ac 100644
@@ -23,25 +23,17 @@ void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len);
 
 static inline void svm_vmload_pa(paddr_t vmcb)
 {
-    asm volatile (
-        ".byte 0x0f,0x01,0xda" /* vmload */
-        : : "a" (vmcb) : "memory" );
+    asm volatile ( "vmload" : : "a" (vmcb) : "memory" );
 }
 
 static inline void svm_vmsave_pa(paddr_t vmcb)
 {
-    asm volatile (
-        ".byte 0x0f,0x01,0xdb" /* vmsave */
-        : : "a" (vmcb) : "memory" );
+    asm volatile ( "vmsave" : : "a" (vmcb) : "memory" );
 }
 
 static inline void svm_invlpga(unsigned long linear, uint32_t asid)
 {
-    asm volatile (
-        ".byte 0x0f,0x01,0xdf"
-        : /* output */
-        : /* input */
-        "a" (linear), "c" (asid) );
+    asm volatile ( "invlpga" : /* output */ : /* input */ "a" (linear), "c" (asid) );
 }
 
 /*
xen/arch/x86/include/asm/asm-defns.h +0 -12
index 32d6b44910..5a64b42495 100644
@@ -10,18 +10,6 @@
 .endm
 #endif
 
-.macro vmrun
-    .byte 0x0f, 0x01, 0xd8
-.endm
-
-.macro stgi
-    .byte 0x0f, 0x01, 0xdc
-.endm
-
-.macro clgi
-    .byte 0x0f, 0x01, 0xdd
-.endm
-
 /*
  * Call a noreturn function.  This could be JMP, but CALL results in a more
  * helpful backtrace.  BUG is to catch functions which do decide to return...
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#2 lore raw

Re: [XEN PATCH 1/1] xen/x86: drop wrappers of SVM instructions

Quoted 5 lines · Alexander M. Merritt

The new toolchain baseline knows the SVM instructions.

Resolves: xen-project/xen#204

notes.

Quoted 10 lines
---
 xen/arch/x86/hvm/svm/svm.h           | 14 +++-----------
 xen/arch/x86/include/asm/asm-defns.h | 12 ------------
 2 files changed, 3 insertions(+), 23 deletions(-)
xen/arch/x86/hvm/svm/svm.h +0 -0
index beeaaab4f7..5c5e91a1ac 100644

xen/arch/x86/hvm/svm/svm.h void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len); · line 26

Quoted 7 lines
xen/arch/x86/hvm/svm/svm.h +1 -3
@@ -23,25 +23,17 @@ void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len);
 
 static inline void svm_vmload_pa(paddr_t vmcb)
 {
-    asm volatile (
-        ".byte 0x0f,0x01,0xda" /* vmload */
-        : : "a" (vmcb) : "memory" );
+    asm volatile ( "vmload" : : "a" (vmcb) : "memory" );

We tend to prefer :: for empty sections.

Quoted 8 lines
xen/arch/x86/hvm/svm/svm.h +1 -3
 }
 
 static inline void svm_vmsave_pa(paddr_t vmcb)
 {
-    asm volatile (
-        ".byte 0x0f,0x01,0xdb" /* vmsave */
-        : : "a" (vmcb) : "memory" );
+    asm volatile ( "vmsave" : : "a" (vmcb) : "memory" );

xen/arch/x86/hvm/svm/svm.h void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len); · line 36

Quoted 10 lines
xen/arch/x86/hvm/svm/svm.h +1 -5
 }
 
 static inline void svm_invlpga(unsigned long linear, uint32_t asid)
 {
-    asm volatile (
-        ".byte 0x0f,0x01,0xdf"
-        : /* output */
-        : /* input */
-        "a" (linear), "c" (asid) );
+    asm volatile ( "invlpga" : /* output */ : /* input */ "a" (linear), "c" (asid) );

And here, the output/input comments are useless and can be dropped.

I can fix both on commit if you're happy?

~Andrew

#3 lore raw

Re: [XEN PATCH 1/1] xen/x86: drop wrappers of SVM instructions

Quoted 5 lines · Andrew Cooper

On 02/04/2025 3:54 pm, Alexander M. Merritt wrote:

I can fix both on commit if you're happy?

~Andrew

Noted for future updates. Yes please go ahead.

-Alex