Re: [PATCH v10 22/28] KVM: nVMX: Restrict event data VMCS fields to FRED-supported hosts

From: Chao Gao

Date: Wed Nov 04 2026 - 08:32:57 EST


On Wed, Nov 04, 2026 at 02:57:45PM +0800, Binbin Wu wrote:
>On 9/12/2026 5:36 AM, Sohil Mehta wrote:
>> From: Xin Li <xin@xxxxxxxxx>
>>
>> Prevent L1 from accessing the ORIGINAL_EVENT_DATA and INJECTED_EVENT_DATA
>> VMCS fields via VMREAD or VMWRITE when FRED support is disabled or not
>> present in KVM.
>
>I think the change log should tell why the patch only restricts event data
>fields.

Sean preferred an "unconditional" rule for cpu_has_vmcs12_field() [1],
i.e., new fields are added there whether or not they are shadowed.
Following that rule, this patch should cover all FRED VMCS fields.

[1]: https://lore.kernel.org/all/aULATi4uMa-5z08k@xxxxxxxxxx/

>
>>
>> Signed-off-by: Xin Li <xin@xxxxxxxxx>
>> Signed-off-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>
>> ---
>> v10:
>> - Split out of "KVM: nVMX: Guard SHADOW_FIELD_R[OW] macros with VMX
>> feature checks" and renamed (Sean).
>> ---
>> arch/x86/kvm/vmx/vmcs12.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/x86/kvm/vmx/vmcs12.c b/arch/x86/kvm/vmx/vmcs12.c
>> index 837cb3d568c3..67c730e31465 100644
>> --- a/arch/x86/kvm/vmx/vmcs12.c
>> +++ b/arch/x86/kvm/vmx/vmcs12.c
>> @@ -222,6 +222,9 @@ static __init bool cpu_has_vmcs12_field(unsigned int idx)
>> case HOST_SSP:
>> case HOST_INTR_SSP_TABLE:
>> return cpu_has_load_cet_ctrl();
>> + VMCS12_CASE64(ORIGINAL_EVENT_DATA):
>> + VMCS12_CASE64(INJECTED_EVENT_DATA):
>> + return cpu_has_vmx_fred();
>>
>> /* KVM always emulates PML and the VMX preemption timer in software. */
>> case GUEST_PML_INDEX:
>