From: Oliver Upton <oliver.upton@linux.dev>
To: kvmarm@lists.linux.dev
Cc: Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>,
Oliver Upton <oliver.upton@linux.dev>
Subject: [PATCH 1/3] KVM: arm64: nv: Leave vPE nonresident in nested vgic state
Date: Fri, 23 Aug 2024 21:27:01 +0000 [thread overview]
Message-ID: <20240823212703.3576061-2-oliver.upton@linux.dev> (raw)
In-Reply-To: <20240823212703.3576061-1-oliver.upton@linux.dev>
Nested VGIC support hasn't taken shape upstream yet, although one thing
that's already clear is KVM will not virtualize GICv4 for the guest
hypervisor. Nope. Nada. Maybe we can revisit the topic for the next GIC
architecture.
Leave the vPE unloaded in nested state and document why we do it. This
has been spun off from the nested VGIC patch that Marc has been carrying
as part of the NV series.
Co-developed-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
arch/arm64/kvm/vgic/vgic-v3.c | 15 ++++++++++++++-
include/kvm/arm_vgic.h | 5 +++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c
index ed6e412cd74b..27b42664bb1c 100644
--- a/arch/arm64/kvm/vgic/vgic-v3.c
+++ b/arch/arm64/kvm/vgic/vgic-v3.c
@@ -727,7 +727,14 @@ void vgic_v3_load(struct kvm_vcpu *vcpu)
if (has_vhe())
__vgic_v3_activate_traps(cpu_if);
- WARN_ON(vgic_v4_load(vcpu));
+ /*
+ * KVM does not virtualize GICv4 for the guest hypervisor, so there's no
+ * vPE to load when in a nested state. The L1 vPE remains nonresident
+ * so the GIC will generate a doorbell when a vLPI/vSGI becomes pending
+ * for the L1.
+ */
+ if (!vgic_is_nested_state(vcpu))
+ WARN_ON(vgic_v4_load(vcpu));
}
void vgic_v3_put(struct kvm_vcpu *vcpu)
@@ -735,6 +742,12 @@ void vgic_v3_put(struct kvm_vcpu *vcpu)
struct vgic_v3_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v3;
kvm_call_hyp(__vgic_v3_save_vmcr_aprs, cpu_if);
+
+ /*
+ * The vPE may already be nonresident if we're blocking (i.e. already
+ * called vgic_v4_put()) or in a nested state. Calling vgic_v4_put() on
+ * an already nonresdent vCPU is benign.
+ */
WARN_ON(vgic_v4_put(vcpu));
if (has_vhe())
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index f5172549f9ba..0b1b7b706227 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -434,6 +434,11 @@ int vgic_v4_load(struct kvm_vcpu *vcpu);
void vgic_v4_commit(struct kvm_vcpu *vcpu);
int vgic_v4_put(struct kvm_vcpu *vcpu);
+static inline bool vgic_is_nested_state(struct kvm_vcpu *vcpu)
+{
+ return false;
+}
+
/* CPU HP callbacks */
void kvm_vgic_cpu_up(void);
void kvm_vgic_cpu_down(void);
--
2.46.0.295.g3b9ea8a38a-goog
next prev parent reply other threads:[~2024-08-23 21:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 21:27 [PATCH 0/3] KVM: arm64: nv: Fix nested IRQ exception storm on NV+GICv4 Oliver Upton
2024-08-23 21:27 ` Oliver Upton [this message]
2024-08-23 21:27 ` [PATCH 2/3] KVM: arm64: Move host SVE/SME state flags out of vCPU Oliver Upton
2024-08-23 21:27 ` [PATCH 3/3] KVM: arm64: nv: Request vPE doorbell upon nested ERET to L2 Oliver Upton
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=20240823212703.3576061-2-oliver.upton@linux.dev \
--to=oliver.upton@linux.dev \
--cc=gankulkarni@os.amperecomputing.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.com \
/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