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

Chang S. Bae
2026-04-29T17:22:28Z

On 4/29/2026 12:50 AM, Paolo Bonzini wrote:
> On Tue, Apr 28, 2026 at 10:12 PM Chang S. Bae <chang.seok.bae@intel.com> wrote:
>> 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:
>
> I don't think so, you can (and should) assume that \reg has WORD_SIZE
> size (i.e. disallow %eax if CONFIG_X86_64 is set). Only CLEAR_REGS
> uses smaller registers but it does not need the reg_num.
Okay, I think I didn't close look at the error. Simply "\reg_num" to
"reg_num" builds fine. Yes, REG_TYPE can go away.

Thanks,
Chang