Re: [PATCH v2 01/16] KVM: x86: Rename register accessors to be GPR-specific
From: Chang S. Bae
Date: Fri Mar 06 2026 - 20:33:07 EST
On 3/4/2026 5:35 PM, Sean Christopherson wrote:
On Mon, Jan 12, 2026, Chang S. Bae wrote:
Refactor the VCPU register state accessors to make them explicitly
GPR-only.
I like "register" though.
Yeah, agree that it is more general.
The existing register accessors operate on the cached VCPU register
state. That cache holds GPRs and RIP. RIP has its own interface already.
Isn't it possible that e.g. get_vmx_mem_address() will do kvm_register_read()
for a RIP-relative address? One could RIP isn't a pure GPR, but it's also not
something entirely different either.
The 'reg' argument has historically matched the index of the register cache array, vcpu::arch::regs[]. When extending the accessors to support EGPRs, it looked smooth to keep using it as a register ID, since that wires up cleanly with VMX instruction info and emulator sites. But then reg=16 immediately conflicts with RIP.
Separating accessors for RIP and GPRs was an option. Yes, the usages are very close and EGPRs are strictly not *legacy* GPRs.
Then, another option would be adjust RIP numbering. For example, use something like VCPU_REGS_RIP=32 for the accessor, while keeping a separate value like __VCPU_REGS_RIP=16 for the reg cache index. But there are many sites directly referencing regs[] and the change looked rather ugly -- two numberings for RIP alone.
Thoughts?