From: Roy Hopkins <roy.hopkins@suse.com>
To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, linux-coco@lists.linux.dev
Cc: Roy Hopkins <roy.hopkins@suse.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Michael Roth <michael.roth@amd.com>,
Ashish Kalra <ashish.kalra@amd.com>,
Joerg Roedel <jroedel@suse.de>,
Tom Lendacky <thomas.lendacky@amd.com>
Subject: [RFC PATCH 5/5] x86/kvm: Add target VMPL to IRQs and send to APIC for VMPL
Date: Mon, 16 Sep 2024 19:17:57 +0100 [thread overview]
Message-ID: <67ffe577fe98f53068d68c053fa209e8d4b4bae9.1726506534.git.roy.hopkins@suse.com> (raw)
In-Reply-To: <cover.1726506534.git.roy.hopkins@suse.com>
Systems that support VMPLs need to decide which VMPL each
IRQ is destined for; each VMPL can support its own set of hardware
devices that generate interrupts.
This commit extends kvm_lapic_irq to include a target_vmpl field the
sends the IRQ to the APIC instance at the target VMPL.
Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
---
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/kvm/ioapic.c | 3 +++
arch/x86/kvm/irq_comm.c | 1 +
arch/x86/kvm/lapic.c | 6 +++++-
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3dd3a5ff0cec..d0febb67dabf 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1624,6 +1624,7 @@ struct kvm_lapic_irq {
u32 shorthand;
u32 dest_id;
bool msi_redir_hint;
+ unsigned int target_vmpl;
};
static inline u16 kvm_lapic_irq_dest_mode(bool dest_mode_logical)
diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 995eb5054360..7b835a192561 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -413,6 +413,8 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
irq.shorthand = APIC_DEST_NOSHORT;
irq.dest_id = e->fields.dest_id;
irq.msi_redir_hint = false;
+ irq.target_vmpl = ioapic->kvm->arch.default_irq_vmpl;
+
bitmap_zero(vcpu_bitmap, KVM_MAX_VCPUS);
kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
vcpu_bitmap);
@@ -458,6 +460,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
irqe.level = 1;
irqe.shorthand = APIC_DEST_NOSHORT;
irqe.msi_redir_hint = false;
+ irqe.target_vmpl = ioapic->kvm->arch.default_irq_vmpl;
if (irqe.trig_mode == IOAPIC_EDGE_TRIG)
ioapic->irr_delivered |= 1 << irq;
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 8136695f7b96..6bd4a78dddba 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -119,6 +119,7 @@ void kvm_set_msi_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e,
irq->msi_redir_hint = msg.arch_addr_lo.redirect_hint;
irq->level = 1;
irq->shorthand = APIC_DEST_NOSHORT;
+ irq->target_vmpl = kvm->arch.default_irq_vmpl;
}
EXPORT_SYMBOL_GPL(kvm_set_msi_irq);
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index e2dd573e4f2d..20b433a78457 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -836,7 +836,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
struct dest_map *dest_map)
{
- struct kvm_lapic *apic = vcpu->arch.apic;
+ struct kvm_lapic *apic = vcpu->vcpu_parent->vcpu_vmpl[irq->target_vmpl]->arch.apic;
+ if (!apic)
+ return -EINVAL;
return __apic_accept_irq(apic, irq->delivery_mode, irq->vector,
irq->level, irq->trig_mode, dest_map);
@@ -1528,6 +1530,8 @@ void kvm_apic_send_ipi(struct kvm_lapic *apic, u32 icr_low, u32 icr_high)
irq.trig_mode = icr_low & APIC_INT_LEVELTRIG;
irq.shorthand = icr_low & APIC_SHORT_MASK;
irq.msi_redir_hint = false;
+ /* IPIs always target the same VMPL as the source */
+ irq.target_vmpl = apic->vcpu->vmpl;
if (apic_x2apic_mode(apic))
irq.dest_id = icr_high;
else
--
2.43.0
next prev parent reply other threads:[~2024-09-16 18:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-16 18:17 [RFC PATCH 0/5] Extend SEV-SNP SVSM support with a kvm_vcpu per VMPL Roy Hopkins
2024-09-16 18:17 ` [RFC PATCH 1/5] kvm: Move kvm_vcpu fields into common structure Roy Hopkins
2024-09-16 18:17 ` [RFC PATCH 2/5] x86/kvm: Create a child struct kvm_vcpu for each VMPL Roy Hopkins
2024-09-16 18:17 ` [RFC PATCH 3/5] kvm/sev: Update SEV VMPL handling to use multiple struct kvm_vcpus Roy Hopkins
2024-09-16 18:17 ` [RFC PATCH 4/5] x86/kvm: Add x86 field to find the default VMPL that IRQs should target Roy Hopkins
2024-09-16 18:17 ` Roy Hopkins [this message]
2024-10-18 15:36 ` [RFC PATCH 0/5] Extend SEV-SNP SVSM support with a kvm_vcpu per VMPL James Bottomley
2024-10-21 19:51 ` Sean Christopherson
2024-10-23 11:48 ` Paolo Bonzini
2024-10-23 14:33 ` James Bottomley
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=67ffe577fe98f53068d68c053fa209e8d4b4bae9.1726506534.git.roy.hopkins@suse.com \
--to=roy.hopkins@suse.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=jroedel@suse.de \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@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®