Re: [PATCH v3 3/4] KVM: nVMX: Disallow access to vmcs12 fields that aren't supported by "hardware"
From: Xiaoyao Li
Date: Fri Jan 09 2026 - 09:13:28 EST
On 1/9/2026 12:15 PM, Sean Christopherson wrote:
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 61113ead3d7b..ac7a17560c8f 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -111,6 +111,9 @@ static void init_vmcs_shadow_fields(void)
field <= GUEST_TR_AR_BYTES,
"Update vmcs12_write_any() to drop reserved bits from AR_BYTES");
+ if (get_vmcs12_field_offset(field) < 0)
+ continue;
+
why shadow_read_only_fields[] doesn't need such guard?
IIUC, copy_vmcs12_to_shadow() will VMWRITE shadowed readonly field even
if it doesn't exist on the hardware?