Re: [PATCH v2 0/7] KVM: SVM: Enable FRED support

From: Shivansh Dhiman

Date: Fri Apr 24 2026 - 00:57:49 EST


Hi,

I'm planning to add another patch to this series in the next version. This is
related to dependency of FRED Virtualization on NMI Virtualization as mentioned
in the vFRED specification [1]. Any comments are welcome.

[1] https://docs.amd.com/v/u/en-US/69191-PUB

Thanks,
Shivansh

---

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 4b270490b2fd..f1fe407ea5da 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -5379,6 +5379,9 @@ static __init void svm_set_cpu_caps(void)
/* CPUID 0x8000001F (SME/SEV features) */
sev_set_cpu_caps();

+ if (!vnmi)
+ kvm_cpu_cap_clear(X86_FEATURE_FRED);
+
/*
* Clear capabilities that are automatically configured by common code,
* but that require explicit SVM support (that isn't yet implemented).



On 03-04-26 00:12, Shivansh Dhiman wrote:
> This series adds SVM support for FRED (Flexible Return and Event Delivery)
> virtualization in KVM.
>
> FRED introduces simplified privilege level transitions to replace IDT-based
> event delivery and IRET returns, providing lower latency event handling while
> ensuring complete supervisor context on delivery and full user context on
> return. FRED defines event delivery for both ring 3->0 and ring 0->0
> transitions, and introduces ERETU for returning to ring 3 and ERETS for
> remaining in ring 0.
>
> AMD hardware extends the VMCB to support FRED virtualization with dedicated
> save area fields for FRED MSRs (RSP0-3, SSP1-3, STKLVLS, CONFIG) and control
> fields for event injection data (EXITINTDATA, EVENTINJDATA).
>
> The implementation spans seven patches. The important changes are:
>
> 1) Extend VMCB structures with FRED fields mentioned above and disable MSR
> interception for FRED-enabled guests to avoid unnecessary VM exits.
>
> 2) Support for nested exceptions where we populate event injection data
> when delivering exceptions like page faults and debug traps.
>
> Changes in v2:
> - Modified the zeroing of FRED MSRs from INIT to RESET and updated the commit
> message (Sean Christopherson).
> - Used guest_cpu_cap_has() instead of checking VMCB bit in recalc intercepts
> (Sean Christopherson).
> - Variable rename from 'fred_enable' to 'intercept' (Sean Christopherson).
> - Moved FRED MSRs save/restore logic from svm_vcpu_enter_exit() to
> svm_prepare_[host_switch/switch_to_guest]() to reduce some MSR accesses.
> - While switching to host, added a safety check on guest_state_loaded.
> - Removed the need for a new function parameter 'reinject_on_vmexit' in
> svm_complete_interrupts() (Paolo Bonzini).
> - Replace variable 'nested' with 'is_nested' (Sean Christopherson).
> - Formatted variables in reverse fir-tree order (Sean Christopherson).
> - Gate all the FRED MSRs through guest_cpu_cap_has() while dumping VMCB
> (Sean Christopherson).
> - Confined the enabling of vFRED to svm_vcpu_after_set_cpuid() only
> (Sean Christopherson).
>
> This series is based on top of FRED support for VMX patchset [1],
> patches 1-17. The VMX patchset was rebased on top of v6.18.0 kernel.
> Previous version v1 of this series can be found here:
> https://lore.kernel.org/kvm/20260129063653.3553076-1-shivansh.dhiman@xxxxxxx/
>
> [1] https://lore.kernel.org/kvm/20251026201911.505204-1-xin@xxxxxxxxx
>
> Regards,
> Shivansh
> ---
> Neeraj Upadhyay (3):
> KVM: SVM: Initialize FRED VMCB fields
> KVM: SVM: Populate FRED event data on event injection
> KVM: SVM: Support FRED nested exception injection
>
> Shivansh Dhiman (4):
> KVM: SVM: Disable interception of FRED MSRs for FRED supported guests
> KVM: SVM: Save restore FRED_RSP0 for FRED supported guests
> KVM: SVM: Dump FRED context in dump_vmcb()
> KVM: SVM: Enable FRED virtualization
>
> arch/x86/include/asm/svm.h | 35 ++++++++++-
> arch/x86/kvm/svm/svm.c | 122 ++++++++++++++++++++++++++++++++++++-
> 2 files changed, 152 insertions(+), 5 deletions(-)
>
> base-commit: f76e83ecf6bce6d3793f828d92170b69e636f3c9