Re: [PATCH v2 1/6] KVM: x86: Add dedicated storage for guest RIP

From: Chang S. Bae

Date: Fri Apr 10 2026 - 15:00:21 EST


On 4/9/2026 3:42 PM, Sean Christopherson wrote:
Add kvm_vcpu_arch.rip to track guest RIP instead of including it in the
generic regs[] array. Decoupling RIP from regs[] will allow using a
*completely* arbitrary index for RIP, as opposed to the mostly-arbitrary
index that is currently used. That in turn will allow using indices
16-31 to track R16-R31 that are coming with APX....
- unsigned long regs[NR_VCPU_REGS];
+ unsigned long regs[NR_VCPU_GENERAL_PURPOSE_REGS];
+ unsigned long rip;

Digging the history, this effectively reverts part of changes in

commit 5fdbf9765b7b ("KVM: x86: accessors for guest registers")

which had

- unsigned long regs[NR_VCPU_REGS];
- unsigned long rip; /* needs vcpu_load_rsp_rip() */
+ /*
+ * rip and regs accesses must go through
+ * kvm_{register,rip}_{read,write} functions.
+ */
+ unsigned long regs[NR_VCPU_REGS];

But its changelog didn't go into much detail about this change. I could only relate to vcpu_load_rsp_rip() which might establish perception coupling RSP with RIP back then.

In any case, it doesn't matter. I think this patch makes a clear improvement - for example, now aligns with _regs[NR_EMULATOR_GPRS] in struct x86_emulate_ctxt for general consistency.

Indeed, this and the whole series paves the way for APX. Appreciate for the time and effort!

Reviewed-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>