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

Chang S. Bae
2026-04-28T20:12:37Z

On 4/28/2026 2:03 AM, Paolo Bonzini wrote:
>
> I would also consider using inst.h's name-to-index conversion:
>
> .macro LOAD_GPRS src:req, regs_ofs:req, regs:vararg
> .irp reg, \regs
> #ifdef CONFIG_X86_64
>     R64_NUM reg_num \reg
> #else
>     R32_NUM reg_num \reg
> #endif
>     .if \reg_num <> REG_NUM_INVALID
>     mov (\regs_ofs + \reg_num * WORD_SIZE)(%_ASM_DI), \reg
>     .else
>     .err invalid register \reg
>     .endif
> .endr
> .endm
Yup! Also, looks like still needs the REG_TYPE macro:

.macro LOAD_REGS src:req, regs_ofs:req, regs:vararg
.irp reg, \regs
REG_TYPE reg_type \reg
.if reg_type == REG_TYPE_R64
R64_NUM reg_num \reg
.else
R32_NUM reg_num \reg
.endif
.if reg_num <> REG_NUM_INVALID
mov (\regs_ofs + reg_num * WORD_SIZE)(\src), \reg
.else
.err invalid register \reg
.endif
.endr
.endm

Thanks,
Chang