From: Shivansh Dhiman <shivansh.dhiman@amd.com>
To: <seanjc@google.com>, <pbonzini@redhat.com>,
<linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>
Cc: <tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
<xin@zytor.com>, <andrew.cooper3@citrix.com>,
<sohil.mehta@intel.com>, <dwmw@amazon.co.uk>, <yosry@kernel.org>,
<nikunj.dadhania@amd.com>, <santosh.shukla@amd.com>,
<shivansh.dhiman@amd.com>
Subject: [PATCH v3 5/9] KVM: SVM: Populate FRED event data on event injection
Date: Fri, 25 Sep 2026 11:40:13 +0000 [thread overview]
Message-ID: <20260925114017.2208531-6-shivansh.dhiman@amd.com> (raw)
In-Reply-To: <20260925114017.2208531-1-shivansh.dhiman@amd.com>
From: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Set injected-event data (in EVENTINJDATA) when injecting an event,
use EXITINTDATA for populating the injected-event data during
reinjection.
Unlike IDT using some extra CPU register as part of an event
context, e.g., %cr2 for #PF, FRED saves a complete event context
in its stack frame, e.g., FRED saves the faulting linear address
of a #PF into the event data field defined in its stack frame.
Populate the EVENTINJDATA during event injection. The event data
will be pushed into a FRED stack frame for VM entries that inject
an event using FRED event delivery.
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>
---
Changes in v3:
* Rebased, no changes.
Changes in v2:
* Removed the need for a new function parameter 'reinject_on_vmexit' in
svm_complete_interrupts() (Paolo Bonzini).
---
arch/x86/kvm/svm/svm.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 72d49c6daee7..6c15e8480d25 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -401,6 +401,10 @@ static void svm_inject_exception(struct kvm_vcpu *vcpu)
| SVM_EVTINJ_VALID
| (ex->has_error_code ? SVM_EVTINJ_VALID_ERR : 0)
| SVM_EVTINJ_TYPE_EXEPT;
+
+ if (is_fred_enabled(vcpu))
+ svm->vmcb->control.event_inj_data = ex->event_data;
+
svm->vmcb->control.event_inj_err = ex->error_code;
}
@@ -4478,6 +4482,7 @@ static void svm_complete_interrupts(struct kvm_vcpu *vcpu)
break;
case SVM_EXITINTINFO_TYPE_EXEPT: {
u32 error_code = 0;
+ u64 event_data = 0;
/*
* Never re-inject a #VC exception.
@@ -4488,9 +4493,16 @@ static void svm_complete_interrupts(struct kvm_vcpu *vcpu)
if (exitintinfo & SVM_EXITINTINFO_VALID_ERR)
error_code = svm->vmcb->control.exit_int_info_err;
+ /*
+ * FRED requires an additional field to pass injected-event
+ * data to the guest.
+ */
+ if (is_fred_enabled(vcpu) && (vector == PF_VECTOR || vector == DB_VECTOR))
+ event_data = svm->vmcb->control.exit_int_data;
+
kvm_requeue_exception(vcpu, vector,
exitintinfo & SVM_EXITINTINFO_VALID_ERR,
- error_code, false, 0);
+ error_code, false, event_data);
break;
}
case SVM_EXITINTINFO_TYPE_INTR:
@@ -4512,6 +4524,7 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu)
control->exit_int_info = control->event_inj;
control->exit_int_info_err = control->event_inj_err;
+ control->exit_int_data = control->event_inj_data;
control->event_inj = 0;
svm_complete_interrupts(vcpu);
}
--
2.43.0
next prev parent reply other threads:[~2026-09-25 11:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 11:40 [PATCH v3 0/9] KVM: SVM: Enable FRED support Shivansh Dhiman
2026-09-25 11:40 ` [PATCH v3 1/9] KVM: SVM: Initialize FRED VMCB fields Shivansh Dhiman
2026-09-25 11:40 ` [PATCH v3 2/9] KVM: SVM: Disable interception of FRED MSRs for FRED supported guests Shivansh Dhiman
2026-09-25 11:40 ` [PATCH v3 3/9] KVM: SVM: Save/restore FRED_RSP0 " Shivansh Dhiman
2026-09-25 11:40 ` [PATCH v3 4/9] KVM: SVM: Add support for saving and restoring FRED MSRs Shivansh Dhiman
2026-09-25 11:40 ` Shivansh Dhiman [this message]
2026-09-25 11:40 ` [PATCH v3 6/9] KVM: SVM: Support FRED nested exception injection Shivansh Dhiman
2026-09-25 11:40 ` [PATCH v3 7/9] KVM: SVM: Dump FRED context in dump_vmcb() Shivansh Dhiman
2026-09-25 11:40 ` [PATCH v3 8/9] KVM: SVM: Enable FRED virtualization Shivansh Dhiman
2026-09-25 11:40 ` [PATCH v3 9/9] KVM: SVM: Don't intercept ICEBP while the guest has FRED enabled Shivansh Dhiman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260925114017.2208531-6-shivansh.dhiman@amd.com \
--to=shivansh.dhiman@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nikunj.dadhania@amd.com \
--cc=pbonzini@redhat.com \
--cc=santosh.shukla@amd.com \
--cc=seanjc@google.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
--cc=yosry@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®