* Re: Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
@ 2026-03-14 12:55 Christian Ludloff
2026-03-27 6:47 ` Shivansh Dhiman
0 siblings, 1 reply; 9+ messages in thread
From: Christian Ludloff @ 2026-03-14 12:55 UTC (permalink / raw)
To: Shivansh Dhiman
Cc: Sean Christopherson, pbonzini, linux-kernel, kvm, tglx, mingo,
bp, dave.hansen, x86, hpa, xin, nikunj.dadhania, santosh.shukla,
Andrew Cooper
>> 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.
Ahem... citation required, please. :)
Because the FRED spec certainly claims otherwise:
"The RESET state of each of the new MSRs is zero.
INIT does not change the value of the FRED MSRs."
See SDM vol3 #325384-090 @ end of section 8.2.3.
Getting initialized by INIT tends to be outlier behavior
when it comes to MSRs – MPX, CET, EFER, FS/GS/
kGS... but afaik the rest all remain unchanged.
And yes... this will need clarification from Intel... given
that CET_PL0_SSP = FRED_SSP0_SL0... and it can
not be both, unchanged and set-to-zero... 8-)
--
C.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-03-14 12:55 Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields Christian Ludloff
@ 2026-03-27 6:47 ` Shivansh Dhiman
2026-03-27 7:29 ` Christian Ludloff
0 siblings, 1 reply; 9+ messages in thread
From: Shivansh Dhiman @ 2026-03-27 6:47 UTC (permalink / raw)
To: ludloff
Cc: Sean Christopherson, pbonzini, linux-kernel, kvm, tglx, mingo,
bp, dave.hansen, x86, hpa, xin, nikunj.dadhania, santosh.shukla,
Andrew Cooper, Shivansh Dhiman
Hi Christian,
On 14-03-2026 18:25, Christian Ludloff wrote:
>>> 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.
>
> Ahem... citation required, please. :)
>
> Because the FRED spec certainly claims otherwise:
>
> "The RESET state of each of the new MSRs is zero.
> INIT does not change the value of the FRED MSRs."
>
> See SDM vol3 #325384-090 @ end of section 8.2.3.
>
> Getting initialized by INIT tends to be outlier behavior
> when it comes to MSRs – MPX, CET, EFER, FS/GS/
> kGS... but afaik the rest all remain unchanged.
Thanks for pointing this out. After consulting with the hardware folks, it
turns out the FRED MSRs are left unchanged on INIT. I had mistakenly mixed
up the INIT and RESET behavior. Apologies for the confusion.
I'll update the patch to only zero the FRED MSRs on RESET. Will address this
in v2.
Thanks,
Shivansh
>
> And yes... this will need clarification from Intel... given
> that CET_PL0_SSP = FRED_SSP0_SL0... and it can
> not be both, unchanged and set-to-zero... 8-)
>
> --
> C.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-03-27 6:47 ` Shivansh Dhiman
@ 2026-03-27 7:29 ` Christian Ludloff
0 siblings, 0 replies; 9+ messages in thread
From: Christian Ludloff @ 2026-03-27 7:29 UTC (permalink / raw)
To: Shivansh Dhiman
Cc: Sean Christopherson, pbonzini, linux-kernel, kvm, tglx, mingo,
bp, dave.hansen, x86, hpa, xin, nikunj.dadhania, santosh.shukla,
Andrew Cooper
On Fri, Mar 27, 2026 at 7:47 AM Shivansh Dhiman <shivansh.dhiman@amd.com> wrote:
> On 14-03-2026 18:25, Christian Ludloff wrote:
> >>> 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.
> >
> > Ahem... citation required, please. :)
> >
> > Because the FRED spec certainly claims otherwise:
> >
> > "The RESET state of each of the new MSRs is zero.
> > INIT does not change the value of the FRED MSRs."
> >
> > See SDM vol3 #325384-090 @ end of section 8.2.3.
> >
> > Getting initialized by INIT tends to be outlier behavior
> > when it comes to MSRs – MPX, CET, EFER, FS/GS/
> > kGS... but afaik the rest all remain unchanged.
>
> Thanks for pointing this out. After consulting with the hardware folks, it
> turns out the FRED MSRs are left unchanged on INIT. I had mistakenly mixed
> up the INIT and RESET behavior. Apologies for the confusion.
Thanks.
> I'll update the patch to only zero the FRED MSRs on RESET. Will address this
> in v2.
Thanks.
> > And yes... this will need clarification from Intel... given
> > that CET_PL0_SSP = FRED_SSP0_SL0... and it can
> > not be both, unchanged and set-to-zero... 8-)
Intel folks – can you please state the CET INIT behavior,
for SSP as well as the 4+1+2=7 MSRs, at long last? The
answer I was given years ago was "like RESET", but for
at least PL0_SSP that doesn't match SSP0_SL0.
--
C.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-03-09 17:46 ` Shivansh Dhiman
2026-03-09 18:57 ` Sean Christopherson
@ 2026-03-27 6:41 ` Shivansh Dhiman
1 sibling, 0 replies; 9+ messages in thread
From: Shivansh Dhiman @ 2026-03-27 6:41 UTC (permalink / raw)
To: Sean Christopherson
Cc: pbonzini, linux-kernel, kvm, tglx, mingo, bp, dave.hansen, x86,
hpa, xin, nikunj.dadhania, santosh.shukla, Shivansh Dhiman
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@amd.com>
>>>
>>> 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
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-03-09 18:57 ` Sean Christopherson
@ 2026-03-11 4:18 ` Shivansh Dhiman
0 siblings, 0 replies; 9+ messages in thread
From: Shivansh Dhiman @ 2026-03-11 4:18 UTC (permalink / raw)
To: Sean Christopherson, Shivansh Dhiman
Cc: pbonzini, linux-kernel, kvm, tglx, mingo, bp, dave.hansen, x86,
hpa, xin, nikunj.dadhania, santosh.shukla
On 10-03-2026 00:27, Sean Christopherson wrote:
>>>> + 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.
>
> Please use that as the basis for the changelog. "Ensure that a vCPU starts with
> a clean and valid FRED state on capable hardware" is largely meaningless because
> vCPU structures are zero-allocated.
Will do. Thanks for pointing out.
- Shivansh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-03-09 17:46 ` Shivansh Dhiman
@ 2026-03-09 18:57 ` Sean Christopherson
2026-03-11 4:18 ` Shivansh Dhiman
2026-03-27 6:41 ` Shivansh Dhiman
1 sibling, 1 reply; 9+ messages in thread
From: Sean Christopherson @ 2026-03-09 18:57 UTC (permalink / raw)
To: Shivansh Dhiman
Cc: pbonzini, linux-kernel, kvm, tglx, mingo, bp, dave.hansen, x86,
hpa, xin, nikunj.dadhania, santosh.shukla
On Mon, Mar 09, 2026, 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@amd.com>
> >>
> >> 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.
Please use that as the basis for the changelog. "Ensure that a vCPU starts with
a clean and valid FRED state on capable hardware" is largely meaningless because
vCPU structures are zero-allocated.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-03-07 1:58 ` Sean Christopherson
@ 2026-03-09 17:46 ` Shivansh Dhiman
2026-03-09 18:57 ` Sean Christopherson
2026-03-27 6:41 ` Shivansh Dhiman
0 siblings, 2 replies; 9+ messages in thread
From: Shivansh Dhiman @ 2026-03-09 17:46 UTC (permalink / raw)
To: Sean Christopherson, Shivansh Dhiman
Cc: pbonzini, linux-kernel, kvm, tglx, mingo, bp, dave.hansen, x86,
hpa, xin, nikunj.dadhania, santosh.shukla
Hey Sean,
On 07-03-2026 07:28, Sean Christopherson wrote:
> On Thu, Jan 29, 2026, Shivansh Dhiman wrote:
>> From: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
>>
>> 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.
- Shivansh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-01-29 6:36 ` [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields Shivansh Dhiman
@ 2026-03-07 1:58 ` Sean Christopherson
2026-03-09 17:46 ` Shivansh Dhiman
0 siblings, 1 reply; 9+ messages in thread
From: Sean Christopherson @ 2026-03-07 1:58 UTC (permalink / raw)
To: Shivansh Dhiman
Cc: pbonzini, linux-kernel, kvm, tglx, mingo, bp, dave.hansen, x86,
hpa, xin, nikunj.dadhania, santosh.shukla
On Thu, Jan 29, 2026, Shivansh Dhiman wrote:
> From: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
>
> 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?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields
2026-01-29 6:36 [PATCH 0/7] KVM: SVM: Enable FRED support Shivansh Dhiman
@ 2026-01-29 6:36 ` Shivansh Dhiman
2026-03-07 1:58 ` Sean Christopherson
0 siblings, 1 reply; 9+ messages in thread
From: Shivansh Dhiman @ 2026-01-29 6:36 UTC (permalink / raw)
To: seanjc, pbonzini, linux-kernel, kvm
Cc: tglx, mingo, bp, dave.hansen, x86, hpa, xin, nikunj.dadhania,
santosh.shukla
From: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
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.
Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Co-developed-by: Shivansh Dhiman <shivansh.dhiman@amd.com>
Signed-off-by: Shivansh Dhiman <shivansh.dhiman@amd.com>
Reviewed-by: Nikunj A Dadhania <nikunj@amd.com>
---
arch/x86/include/asm/svm.h | 33 ++++++++++++++++++++++++++++++---
arch/x86/kvm/svm/svm.c | 10 ++++++++++
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
index 17f6c3fedeee..a42ed39aa8fb 100644
--- a/arch/x86/include/asm/svm.h
+++ b/arch/x86/include/asm/svm.h
@@ -165,7 +165,10 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
u8 reserved_9[22];
u64 allowed_sev_features; /* Offset 0x138 */
u64 guest_sev_features; /* Offset 0x140 */
- u8 reserved_10[664];
+ u8 reserved_10[40];
+ u64 exit_int_data; /* Offset 0x170 */
+ u64 event_inj_data;
+ u8 reserved_11[608];
/*
* Offset 0x3e0, 32 bytes reserved
* for use by hypervisor/software.
@@ -360,6 +363,18 @@ struct vmcb_save_area {
u64 last_excp_to;
u8 reserved_0x298[72];
u64 spec_ctrl; /* Guest version of SPEC_CTRL at 0x2E0 */
+ u8 reserved_0x2e8[448];
+ u64 guest_exit_int_data; /* GUEST_EXITINTDATA 0x4A8 */
+ u64 guest_event_inj_data;
+ u64 fred_rsp0;
+ u64 fred_rsp1;
+ u64 fred_rsp2;
+ u64 fred_rsp3;
+ u64 fred_stklvls;
+ u64 fred_ssp1;
+ u64 fred_ssp2;
+ u64 fred_ssp3;
+ u64 fred_config;
} __packed;
/* Save area definition for SEV-ES and SEV-SNP guests */
@@ -472,6 +487,18 @@ struct sev_es_save_area {
u8 fpreg_x87[80];
u8 fpreg_xmm[256];
u8 fpreg_ymm[256];
+ u8 reserved_0x670[568];
+ u64 guest_exit_int_data; /* GUEST_EXITINTDATA 0x8A8 */
+ u64 guest_event_inj_data;
+ u64 fred_rsp0;
+ u64 fred_rsp1;
+ u64 fred_rsp2;
+ u64 fred_rsp3;
+ u64 fred_stklvls;
+ u64 fred_ssp1;
+ u64 fred_ssp2;
+ u64 fred_ssp3;
+ u64 fred_config;
} __packed;
struct ghcb_save_area {
@@ -542,9 +569,9 @@ struct vmcb {
};
} __packed;
-#define EXPECTED_VMCB_SAVE_AREA_SIZE 744
+#define EXPECTED_VMCB_SAVE_AREA_SIZE 1280
#define EXPECTED_GHCB_SAVE_AREA_SIZE 1032
-#define EXPECTED_SEV_ES_SAVE_AREA_SIZE 1648
+#define EXPECTED_SEV_ES_SAVE_AREA_SIZE 2304
#define EXPECTED_VMCB_CONTROL_AREA_SIZE 1024
#define EXPECTED_GHCB_SIZE PAGE_SIZE
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;
+
init_sys_seg(&save->ldtr, SEG_TYPE_LDT);
init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16);
--
2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-03-27 7:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-14 12:55 Re: [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields Christian Ludloff
2026-03-27 6:47 ` Shivansh Dhiman
2026-03-27 7:29 ` Christian Ludloff
-- strict thread matches above, loose matches on Subject: below --
2026-01-29 6:36 [PATCH 0/7] KVM: SVM: Enable FRED support Shivansh Dhiman
2026-01-29 6:36 ` [PATCH 1/7] KVM: SVM: Initialize FRED VMCB fields Shivansh Dhiman
2026-03-07 1:58 ` Sean Christopherson
2026-03-09 17:46 ` Shivansh Dhiman
2026-03-09 18:57 ` Sean Christopherson
2026-03-11 4:18 ` Shivansh Dhiman
2026-03-27 6:41 ` Shivansh Dhiman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®