Re: [PATCH v3 01/20] KVM: VMX: Macrofy 64-bit GPR swapping in __vmx_vcpu_run()

Paolo Bonzini
2026-04-28T09:09:36Z

On 4/28/26 07:00, Chang S. Bae wrote:
> /* Clear return value to indicate VM-Exit (as opposed to VM-Fail). */
> @@ -227,14 +199,7 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
> xor %esi, %esi
> xor %edi, %edi
> #ifdef CONFIG_X86_64
> - xor %r8d, %r8d
> - xor %r9d, %r9d
> - xor %r10d, %r10d
> - xor %r11d, %r11d
> - xor %r12d, %r12d
> - xor %r13d, %r13d
> - xor %r14d, %r14d
> - xor %r15d, %r15d
> + CLEAR_REGS 8d,9d,10d,11d,12d,13d,14d,15d

Likewise, it's worth making this a bit more verbose:

.macro CLEAR_REGS regs:vararg
.irp reg, \regs
xorl \reg, \reg
.endr
.endm

CLEAR_REGS %eax, %ecx, %edx, %ebp, %esi, %edi
#ifdef CONFIG_X86_64
CLEAR_REGS %r8d, %r9d, %r10d, %r11d, %r12d, %r13d, %r14d, %r15d
#endif

but macroize ten more lines of code across VMX and SVM.

Paolo