Re: [PATCH v2 09/16] KVM: emulate: Support EGPR accessing and tracking
From: Sean Christopherson
Date: Wed Mar 04 2026 - 23:22:55 EST
For the scope,
KVM: x86:
because other architectures have emulator code, and as is the case here, x86's
emulator code isn't strictly contained to the emulate.c.
On Mon, Jan 12, 2026, Chang S. Bae wrote:
> Extend the emulator context and GPR accessors to handle EGPRs before
> adding support for REX2-prefixed instructions.
>
> Now the KVM GPR accessors can handle EGPRs. Then, the emulator can
> uniformly cache and track all GPRs without requiring separate handling.
>
> Signed-off-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
> ---
> arch/x86/kvm/kvm_emulate.h | 10 +++++-----
> arch/x86/kvm/x86.c | 4 ++--
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h
> index fb3dab4b5a53..16b35a796a7f 100644
> --- a/arch/x86/kvm/kvm_emulate.h
> +++ b/arch/x86/kvm/kvm_emulate.h
> @@ -105,13 +105,13 @@ struct x86_instruction_info {
> struct x86_emulate_ops {
> void (*vm_bugged)(struct x86_emulate_ctxt *ctxt);
> /*
> - * read_gpr: read a general purpose register (rax - r15)
> + * read_gpr: read a general purpose register (rax - r31)
> *
> * @reg: gpr number.
> */
> ulong (*read_gpr)(struct x86_emulate_ctxt *ctxt, unsigned reg);
> /*
> - * write_gpr: write a general purpose register (rax - r15)
> + * write_gpr: write a general purpose register (rax - r31)
> *
> * @reg: gpr number.
> * @val: value to write.
> @@ -314,7 +314,7 @@ typedef void (*fastop_t)(struct fastop *);
> * a ModRM or SIB byte.
> */
> #ifdef CONFIG_X86_64
> -#define NR_EMULATOR_GPRS 16
> +#define NR_EMULATOR_GPRS 32
If we add Kconfig, this would be the place to use it...