Re: [PATCH] KVM: nVMX: Dynamically compute max VMCS index for vmcs12

From: Paolo Bonzini
Date: Tue Jul 06 2021 - 01:42:58 EST


On 06/07/21 05:05, Hu, Robert wrote:
As noted in the code comments, KVM allows VMREAD/VMWRITE to all defined
fields, whether or not the field should actually exist for the vCPU model doesn't
enter into the equation. That's technically wrong as there are a number of
fields that the SDM explicitly states exist iff a certain feature is supported. To
fix that we'd need to add a "feature flag" to vmcs_field_to_offset_table that is
checked against the vCPU model, though updating the MSR would probably fall
onto userspace's shoulders?

[Hu, Robert]
Perhaps more easier and proper to do this in KVM side.
QEMU sets actual feature set down to KVM, and KVM updates IA32_VMX_VMCS_ENUM
MSR accordingly. We don't see a channel that QEMU constructs a VMCS and sets a whole
to KVM.

Yes, it's possible to do that too. If that is included in Linux 5.14, we can remove it from QEMU.

Paolo