Re: [PATCH 1/2] kvm: vmx: Use basic exit reason to check if it's the specific VM EXIT

From: Vitaly Kuznetsov
Date: Mon Feb 24 2020 - 08:04:54 EST


Xiaoyao Li <xiaoyao.li@xxxxxxxxx> writes:

> On 2/24/2020 6:16 PM, Vitaly Kuznetsov wrote:
>> Xiaoyao Li <xiaoyao.li@xxxxxxxxx> writes:
>>

...

>>> rip = kvm_rip_read(vcpu);
>>> rip += vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
>>> kvm_rip_write(vcpu, rip);
>>> @@ -5797,6 +5797,7 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
>>> {
>>> struct vcpu_vmx *vmx = to_vmx(vcpu);
>>> u32 exit_reason = vmx->exit_reason;
>>> + u16 basic_exit_reason = basic(exit_reason);
>>
>> I don't think renaming local variable is needed, let's just do
>>
>> 'u16 exit_reason = basic_exit_reason(vmx->exit_reason)' and keep the
>> rest of the code as-is.
>
> No, we can't do this.
>
> It's not just renaming local variable, the full 32-bit exit reason is
> used elsewhere in this function that needs the upper 16-bit.
>
> Here variable basic_exit_reason is added for the cases where only basic
> exit reason number is needed.
>

Can we do the other way around, i.e. introduce 'extended_exit_reason'
and use it where all 32 bits are needed? I'm fine with the change, just
trying to minimize the (unneeded) code churn.

--
Vitaly