Re: [PATCH v8 18/21] KVM: nVMX: Add FRED VMCS fields to nested VMX context handling

Xin Li
2025-10-14T07:50:49Z

On 10/14/2025 2:57 PM, Chao Gao wrote:
>> + if (!vmx->nested.nested_run_pending ||
>> + !nested_cpu_load_guest_fred_state(vmcs12)) {
>> + vmx->nested.pre_vmenter_fred_config = vmcs_read64(GUEST_IA32_FRED_CONFIG);
>> + vmx->nested.pre_vmenter_fred_rsp1 = vmcs_read64(GUEST_IA32_FRED_RSP1);
>> + vmx->nested.pre_vmenter_fred_rsp2 = vmcs_read64(GUEST_IA32_FRED_RSP2);
>> + vmx->nested.pre_vmenter_fred_rsp3 = vmcs_read64(GUEST_IA32_FRED_RSP3);
>> + vmx->nested.pre_vmenter_fred_stklvls = vmcs_read64(GUEST_IA32_FRED_STKLVLS);
>> + vmx->nested.pre_vmenter_fred_ssp1 = vmcs_read64(GUEST_IA32_FRED_SSP1);
>> + vmx->nested.pre_vmenter_fred_ssp2 = vmcs_read64(GUEST_IA32_FRED_SSP2);
>> + vmx->nested.pre_vmenter_fred_ssp3 = vmcs_read64(GUEST_IA32_FRED_SSP3);
> FRED state save/restore is needed only when the guest has FRED support. So, the
> above save/restore should be guarded by guest_cpu_cap_has(vcpu, X86_FEATURE_FRED).
> Otherwise, on hardware without FRED, vmread_error() would be triggered here as
> reported by syzbot.

You're right, I wanted to avoid unnecessary checking, but this caught me.

Will fix it with a v8A patch.