From: Marc Zyngier <maz@kernel.org>
To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
kvm@vger.kernel.org
Cc: James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Zenghui Yu <yuzenghui@huawei.com>,
Alexander Potapenko <glider@google.com>
Subject: [PATCH v2 01/11] KVM: arm64: Move GICv3 trap configuration to kvm_calculate_traps()
Date: Tue, 27 Aug 2024 16:25:07 +0100 [thread overview]
Message-ID: <20240827152517.3909653-2-maz@kernel.org> (raw)
In-Reply-To: <20240827152517.3909653-1-maz@kernel.org>
Follow the pattern introduced with vcpu_set_hcr(), and introduce
vcpu_set_ich_hcr(), which configures the GICv3 traps at the same
point.
This will allow future changes to introduce trap configuration on
a per-VM basis.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/kvm/sys_regs.c | 1 +
arch/arm64/kvm/vgic/vgic-v3.c | 9 +++++++++
arch/arm64/kvm/vgic/vgic.h | 2 ++
3 files changed, 12 insertions(+)
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 31e49da867ff..257c8da23a4e 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -4551,6 +4551,7 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu)
mutex_lock(&kvm->arch.config_lock);
vcpu_set_hcr(vcpu);
+ vcpu_set_ich_hcr(vcpu);
if (cpus_have_final_cap(ARM64_HAS_HCX)) {
/*
diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c
index 3eecdd2f4b8f..11718412921f 100644
--- a/arch/arm64/kvm/vgic/vgic-v3.c
+++ b/arch/arm64/kvm/vgic/vgic-v3.c
@@ -292,6 +292,15 @@ void vgic_v3_enable(struct kvm_vcpu *vcpu)
/* Get the show on the road... */
vgic_v3->vgic_hcr = ICH_HCR_EN;
+}
+
+void vcpu_set_ich_hcr(struct kvm_vcpu *vcpu)
+{
+ struct vgic_v3_cpu_if *vgic_v3 = &vcpu->arch.vgic_cpu.vgic_v3;
+
+ if (!kvm_has_gicv3(vcpu->kvm))
+ return;
+
if (group0_trap)
vgic_v3->vgic_hcr |= ICH_HCR_TALL0;
if (group1_trap)
diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h
index 8532bfe3fed4..c72c38b44234 100644
--- a/arch/arm64/kvm/vgic/vgic.h
+++ b/arch/arm64/kvm/vgic/vgic.h
@@ -346,6 +346,8 @@ void vgic_v4_configure_vsgis(struct kvm *kvm);
void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val);
int vgic_v4_request_vpe_irq(struct kvm_vcpu *vcpu, int irq);
+void vcpu_set_ich_hcr(struct kvm_vcpu *vcpu);
+
static inline bool kvm_has_gicv3(struct kvm *kvm)
{
return (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif) &&
--
2.39.2
next prev parent reply other threads:[~2024-08-27 15:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 15:25 [PATCH v2 00/11] KVM: arm64: Handle the lack of GICv3 exposed to a guest Marc Zyngier
2024-08-27 15:25 ` Marc Zyngier [this message]
2024-08-27 15:25 ` [PATCH v2 02/11] KVM: arm64: Force SRE traps when SRE access is not enabled Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 03/11] KVM: arm64: Force GICv3 trap activation when no irqchip is configured on VHE Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 04/11] KVM: arm64: Add helper for last ditch idreg adjustments Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 05/11] KVM: arm64: Zero ID_AA64PFR0_EL1.GIC when no GICv3 is presented to the guest Marc Zyngier
2024-08-28 23:22 ` Mark Brown
2024-08-29 0:48 ` Oliver Upton
2024-08-27 15:25 ` [PATCH v2 06/11] KVM: arm64: Add ICH_HCR_EL2 to the vcpu state Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 07/11] KVM: arm64: Add trap routing information for ICH_HCR_EL2 Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 08/11] KVM: arm64: Honor guest requested traps in GICv3 emulation Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 09/11] KVM: arm64: Make most GICv3 accesses UNDEF if they trap Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 10/11] KVM: arm64: Unify UNDEF injection helpers Marc Zyngier
2024-08-27 15:25 ` [PATCH v2 11/11] KVM: arm64: Add selftest checking how the absence of GICv3 is handled Marc Zyngier
2024-08-27 17:01 ` [PATCH v2 00/11] KVM: arm64: Handle the lack of GICv3 exposed to a guest Oliver Upton
2024-08-27 17:41 ` Marc Zyngier
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=20240827152517.3909653-2-maz@kernel.org \
--to=maz@kernel.org \
--cc=glider@google.com \
--cc=james.morse@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=oliver.upton@linux.dev \
--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;
as well as URLs for NNTP newsgroup(s).