Re: [PATCH 07/11] KVM: x86: Add mode-aware versions of kvm__{read,write}() helpers

Binbin Wu
2026-04-14T09:02:27Z

On 4/10/2026 7:56 AM, Sean Christopherson wrote:

[...]

> @@ -2542,18 +2542,18 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
>
> #ifdef CONFIG_X86_64
> if (is_64_bit_hypercall(vcpu)) {
> - hc.param = kvm_rcx_read(vcpu);
> - hc.ingpa = kvm_rdx_read(vcpu);
> - hc.outgpa = kvm_r8_read(vcpu);
> + hc.param = kvm_rcx_read_raw(vcpu);
> + hc.ingpa = kvm_rdx_read_raw(vcpu);
> + hc.outgpa = kvm_r8_read_raw(vcpu);
> } else
> #endif
> {
> - hc.param = ((u64)kvm_rdx_read(vcpu) << 32) |
> - (kvm_rax_read(vcpu) & 0xffffffff);
> - hc.ingpa = ((u64)kvm_rbx_read(vcpu) << 32) |
> - (kvm_rcx_read(vcpu) & 0xffffffff);
> - hc.outgpa = ((u64)kvm_rdi_read(vcpu) << 32) |
> - (kvm_rsi_read(vcpu) & 0xffffffff);
> + hc.param = ((u64)kvm_rdx_read_raw(vcpu) << 32) |
> + (kvm_rdx_read_raw(vcpu) & 0xffffffff);
> + hc.ingpa = ((u64)kvm_rdx_read_raw(vcpu) << 32) |
> + (kvm_rdx_read_raw(vcpu) & 0xffffffff);
> + hc.outgpa = ((u64)kvm_rdx_read_raw(vcpu) << 32) |
> + (kvm_rdx_read_raw(vcpu) & 0xffffffff);

All registers become RDX, which seems not right.
Also, should "e" versions used here?

> }
>
> hc.code = hc.param & 0xffff; …