Re: [PATCH RFC v1 08/20] KVM: VMX: Support extended register index in exit handling

Paolo Bonzini
2025-11-13T23:40:39Z

On 11/14/25 00:22, Chang S. Bae wrote:
>>> @@ -415,7 +420,10 @@ static __always_inline unsigned long
>>> vmx_get_exit_qual(struct kvm_vcpu *vcpu)
>>>   static inline int vmx_get_exit_qual_gpr(struct kvm_vcpu *vcpu)
>>>   {
>>> -    return (vmx_get_exit_qual(vcpu) >> 8) & 0xf;
>>> +    if (vmx_egpr_enabled(vcpu))
>>> +        return (vmx_get_exit_qual(vcpu) >> 8) & 0x1f;
>>> +    else
>>> +        return (vmx_get_exit_qual(vcpu) >> 8) & 0xf;
>>
>> Can this likewise mask against 0x1f, unconditionally?
>
> It looks like the behavior of that previously-undefined bit is not
> guaranteed -- there's no architectural promise that the bit will always
> read as zero. So in this case, I think it's still safer to rely on the
> enumeration.
The manual says "VM Exit qualification is extended in-place"... This
suggests that the wording of the SDM, "Not currently defined", really
means "currently zero, but may not be *in the future*".

It is indeed safer, but it's a bit sad too. :) Let's at least use
either static_cpu_has() or a global __read_mostly variable, instead of a
more expensive test using the vcpu.

Paolo