Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields

From: Shivansh Dhiman

Date: Fri Mar 27 2026 - 02:47:56 EST


Hi,

On 09-03-2026 23:16, Shivansh Dhiman wrote:
> Hey Sean,
>
> On 07-03-2026 07:28, Sean Christopherson wrote:
>> On Thu, Jan 29, 2026, Shivansh Dhiman wrote:
>>> From: Neeraj Upadhyay <Neeraj.Upadhyay@xxxxxxx>
>>>
>>> The upcoming AMD FRED (Flexible Return and Event Delivery) feature
>>> introduces several new fields to the VMCB save area. These fields include
>>> FRED-specific stack pointers (fred_rsp[0-3], fred_ssp[1-3]), stack level
>>> tracking (fred_stklvls), and configuration (fred_config).
>>>
>>> Ensure that a vCPU starts with a clean and valid FRED state on
>>> capable hardware. Also update the size of save areas of VMCB.
>>
>>> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
>>> index f4ccb3e66635..5cec971a1f5a 100644
>>> --- a/arch/x86/kvm/svm/svm.c
>>> +++ b/arch/x86/kvm/svm/svm.c
>>> @@ -1110,6 +1110,16 @@ static void init_vmcb(struct kvm_vcpu *vcpu, bool init_event)
>>> save->idtr.base = 0;
>>> save->idtr.limit = 0xffff;
>>>
>>> + save->fred_rsp0 = 0;
>>> + save->fred_rsp1 = 0;
>>> + save->fred_rsp2 = 0;
>>> + save->fred_rsp3 = 0;
>>> + save->fred_stklvls = 0;
>>> + save->fred_ssp1 = 0;
>>> + save->fred_ssp2 = 0;
>>> + save->fred_ssp3 = 0;
>>> + save->fred_config = 0;
>>
>> Is this architecturally correct? I.e. are all the FRED MSRs zeroed on INIT?
>
> Yes that's right, the FRED MSRs are zeroed on init.

I would like to correct my earlier statement. After consulting with the hardware
folks, it turns out the FRED MSRs are not zeroed on INIT, instead they are left
unchanged. I had incorrectly mixed up the INIT behavior with RESET values in my
previous reply. Apologies for the confusion.

I'll rework this patch so that the FRED MSR initialization is only applied on
RESET and not on INIT events. v2 will address this soon.

- Shivansh

>
> - Shivansh
>