[RFC PATCH v2 08/17] KVM: SVM: Do not inject exception for Secure AVIC

Neeraj Upadhyay posted 17 patches 1 week, 1 day ago
[RFC PATCH v2 08/17] KVM: SVM: Do not inject exception for Secure AVIC
Posted by Neeraj Upadhyay 1 week, 1 day ago
From: Kishon Vijay Abraham I <kvijayab@amd.com>

Secure AVIC does not support injecting exception from the hypervisor.
Take an early return from svm_inject_exception() for Secure AVIC enabled
guests.

Hardware takes care of delivering exceptions initiated by the guest as
well as re-injecting exceptions initiated by the guest (in case there's
an intercept before delivering the exception).

Signed-off-by: Kishon Vijay Abraham I <kvijayab@amd.com>
Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
---
 arch/x86/kvm/svm/svm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 7811a87bc111..fdd612c975ae 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -374,6 +374,9 @@ static void svm_inject_exception(struct kvm_vcpu *vcpu)
 	struct kvm_queued_exception *ex = &vcpu->arch.exception;
 	struct vcpu_svm *svm = to_svm(vcpu);
 
+	if (sev_savic_active(vcpu->kvm))
+		return;
+
 	kvm_deliver_exception_payload(vcpu, ex);
 
 	if (kvm_exception_is_soft(ex->vector) &&
-- 
2.34.1
Re: [RFC PATCH v2 08/17] KVM: SVM: Do not inject exception for Secure AVIC
Posted by Tom Lendacky 1 week, 1 day ago
On 9/23/25 00:03, Neeraj Upadhyay wrote:
> From: Kishon Vijay Abraham I <kvijayab@amd.com>
> 
> Secure AVIC does not support injecting exception from the hypervisor.
> Take an early return from svm_inject_exception() for Secure AVIC enabled
> guests.
> 
> Hardware takes care of delivering exceptions initiated by the guest as
> well as re-injecting exceptions initiated by the guest (in case there's
> an intercept before delivering the exception).
> 
> Signed-off-by: Kishon Vijay Abraham I <kvijayab@amd.com>
> Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
> ---
>  arch/x86/kvm/svm/svm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 7811a87bc111..fdd612c975ae 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -374,6 +374,9 @@ static void svm_inject_exception(struct kvm_vcpu *vcpu)
>  	struct kvm_queued_exception *ex = &vcpu->arch.exception;
>  	struct vcpu_svm *svm = to_svm(vcpu);
>  
> +	if (sev_savic_active(vcpu->kvm))
> +		return;

A comment above this would be good to have.

Thanks,
Tom

> +
>  	kvm_deliver_exception_payload(vcpu, ex);
>  
>  	if (kvm_exception_is_soft(ex->vector) &&