All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: Steffen Eiden <seiden@linux.ibm.com>,
	Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Oliver Upton <oupton@kernel.org>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Fuad Tabba <fuad.tabba@linux.dev>
Subject: [PATCH 2/3] KVM: arm64: Add GIC idregs sanitisation to common framework
Date: Mon, 23 Nov 2026 19:24:56 +0000	[thread overview]
Message-ID: <20261123192457.8700-3-maz@kernel.org> (raw)
In-Reply-To: <20261123192457.8700-1-maz@kernel.org>

It takes no least than 3 ID registers to describe whether a GICv3 or
GICv5 is supported. Define the sanitisation tables for the relevant
fields and the set of relevant callbacks.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/config.c | 56 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/arch/arm64/kvm/config.c b/arch/arm64/kvm/config.c
index 40965513ebacf..7e702ce587a48 100644
--- a/arch/arm64/kvm/config.c
+++ b/arch/arm64/kvm/config.c
@@ -436,6 +436,23 @@ static bool feat_vmid16(struct kvm *kvm)
 	return kvm_has_feat_enum(kvm, ID_AA64MMFR1_EL1, VMIDBits, 16);
 }
 
+static bool feat_gicv3(struct kvm *kvm)
+{
+	return (irqchip_in_kernel(kvm) &&
+		kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3);
+}
+
+static bool feat_gicv3_aarch32(struct kvm *kvm)
+{
+	return (kvm_supports_32bit_el0() && feat_gicv3(kvm));
+}
+
+static bool feat_gcie(struct kvm *kvm)
+{
+	return (irqchip_in_kernel(kvm) &&
+		kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V5);
+}
+
 static const struct reg_bits_to_feat_map hfgrtr_feat_map[] = {
 	NEEDS_FEAT(HFGRTR_EL2_nAMAIR2_EL1	|
 		   HFGRTR_EL2_nMAIR2_EL1,
@@ -1357,6 +1374,42 @@ static const struct reg_bits_to_feat_map id_aa64mmfr3_el1_feat_map[] = {
 static const DECLARE_IDREG_FEAT_MAP(id_aa64mmfr3_el1_desc, ID_AA64MMFR3_EL1,
 				    id_aa64mmfr3_el1_feat_map, FEAT_AA64EL1);
 
+static const struct reg_bits_to_feat_map aa64pfr0_gicv3[] = {
+	ENUM_FEAT(ID_AA64PFR0_EL1_GIC_IMP, feat_gicv3 ),
+	ENUM_FEAT(ID_AA64PFR0_EL1_GIC_NI, NULL ),
+};
+
+static const struct reg_bits_to_feat_map id_aa64pfr0_el1_feat_map[] = {
+	NEEDS_FEAT_FIELD(ID_AA64PFR0_EL1_GIC, aa64pfr0_gicv3),
+};
+
+static const DECLARE_IDREG_FEAT_MAP(id_aa64pfr0_el1_desc, ID_AA64PFR0_EL1,
+				    id_aa64pfr0_el1_feat_map, FEAT_AA64EL1);
+
+static const struct reg_bits_to_feat_map pfr1_gicv3[] = {
+	ENUM_FEAT(ID_PFR1_EL1_GIC_GICv3, feat_gicv3_aarch32),
+	ENUM_FEAT(ID_PFR1_EL1_GIC_NI, NULL),
+};
+
+static const struct reg_bits_to_feat_map id_pfr1_el1_feat_map[] = {
+	NEEDS_FEAT_FIELD(ID_PFR1_EL1_GIC, pfr1_gicv3),
+};
+
+static const DECLARE_IDREG_FEAT_MAP(id_pfr1_el1_desc, ID_PFR1_EL1,
+				    id_pfr1_el1_feat_map, FEAT_AA64EL1);
+
+static const struct reg_bits_to_feat_map aa64pfr2_gcie[] = {
+	ENUM_FEAT(ID_AA64PFR2_EL1_GCIE_IMP, feat_gcie),
+	ENUM_FEAT(ID_AA64PFR2_EL1_GCIE_NI, NULL),
+};
+
+static const struct reg_bits_to_feat_map id_aa64pfr2_el1_feat_map[] = {
+	NEEDS_FEAT_FIELD(ID_AA64PFR2_EL1_GCIE, aa64pfr2_gcie),
+};
+
+static const DECLARE_IDREG_FEAT_MAP(id_aa64pfr2_el1_desc, ID_AA64PFR2_EL1,
+				    id_aa64pfr2_el1_feat_map, FEAT_AA64EL1);
+
 static const struct reg_bits_to_feat_map ich_hfgrtr_feat_map[] = {
 	NEEDS_FEAT(ICH_HFGRTR_EL2_ICC_APR_EL1 |
 		   ICH_HFGRTR_EL2_ICC_IDRn_EL1 |
@@ -1468,6 +1521,9 @@ void __init check_feature_map(void)
 
 static const struct reg_feat_map_desc *idreg_feat_maps[] = {
 	&id_aa64mmfr3_el1_desc,
+	&id_aa64pfr0_el1_desc,
+	&id_aa64pfr2_el1_desc,
+	&id_pfr1_el1_desc,
 };
 
 static struct resx compute_idreg_field_deps(struct kvm *kvm,
-- 
2.47.3


  parent reply	other threads:[~2026-11-23 19:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 19:24 [PATCH 0/3] KVM: arm64: Convert GIC idreg sanitisation to the confic framework Marc Zyngier
2026-11-23 19:24 ` [PATCH 1/3] KVM: arm64: Add enum support to idreg sanitisation Marc Zyngier
2026-11-23 19:34   ` sashiko-bot
2026-11-24  8:35   ` Fuad Tabba
2026-11-25 15:50   ` Wei-Lin Chang
2026-11-23 19:24 ` Marc Zyngier [this message]
2026-11-24  9:05   ` [PATCH 2/3] KVM: arm64: Add GIC idregs sanitisation to common framework Fuad Tabba
2026-11-23 19:24 ` [PATCH 3/3] KVM: arm64: Drop open-coded GIC idreg sanitisation Marc Zyngier
2026-11-24  9:38   ` Fuad Tabba
2026-11-24 10:50     ` Marc Zyngier
2026-11-24 12:02       ` Fuad Tabba
2026-11-24  9:44 ` [PATCH 0/3] KVM: arm64: Convert GIC idreg sanitisation to the confic framework Fuad Tabba

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=20261123192457.8700-3-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=oupton@kernel.org \
    --cc=seiden@linux.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.