From: Fuad Tabba <fuad.tabba@linux.dev>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>
Cc: "Will Deacon" <will@kernel.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Joey Gouly" <joey.gouly@arm.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"Raghavendra Rao Ananta" <rananta@google.com>,
"Sascha Bischoff" <Sascha.Bischoff@arm.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Sebastian Ene" <sebastianene@google.com>,
"Bartłomiej Grzesik" <bgrzesik@google.com>,
"Mostafa Saleh" <smostafa@google.com>,
"Vincent Donnefort" <vdonnefort@google.com>,
"Vladimir Murzin" <vladimir.murzin@arm.com>,
"Zenghui Yu" <yuzenghui@huawei.com>,
"Zenghui Yu" <zenghui.yu@linux.dev>,
"Steffen Eiden" <seiden@linux.ibm.com>,
"Radu Rendec" <radu@rendec.net>, "Fuad Tabba" <tabba@google.com>,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v4 03/13] irqchip/gic-v3: Disable GICv4 features in pKVM
Date: Wed, 18 Nov 2026 15:18:54 +0000 [thread overview]
Message-ID: <20261118151904.4099560-4-fuad.tabba@linux.dev> (raw)
In-Reply-To: <20261118151904.4099560-1-fuad.tabba@linux.dev>
From: Bartłomiej Grzesik <bgrzesik@google.com>
In subsequent patches the hypervisor takes the ITS from the host and
checks each command the host queues. Those patches don't emulate the
vLPI commands, as VMAPP's VPT_base, for one, is a host-chosen address
the ITS and the redistributors write to.
Clear has_vlpis and has_rvpeid at redistributor probe in protected mode,
so the host never issues a vLPI command, and print that GICv4 is off.
The host loses GICv4 direct injection for its non-protected guests, a
feature that's off unless kvm-arm.vgic_v4_enable is set. A guest
migrated from a host with GICD_TYPER2.nASSGIcap set can't be restored
either, as KVM rejects that GICD_TYPER2 value without GICv4.1. Document
the loss of direct injection in kernel-parameters.txt.
Add gic_is_protected_kvm() to irq-gic-common.h to test for protected
mode, as the ITS driver uses it too from the next patch on. It calls
kvm_get_mode(), so the header now includes linux/kvm_host.h.
Signed-off-by: Bartłomiej Grzesik <bgrzesik@google.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
Documentation/admin-guide/kernel-parameters.txt | 8 +++++---
drivers/irqchip/irq-gic-common.h | 13 +++++++++++++
drivers/irqchip/irq-gic-v3.c | 8 ++++++++
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0b3c140babd94..3e63e44609522 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3275,8 +3275,9 @@ Kernel parameters
hardware (with FEAT_NV2).
Defaults to VHE/nVHE based on hardware support. Setting
- mode to "protected" will disable kexec and hibernation
- for the host. To force nVHE on VHE hardware, add
+ mode to "protected" will disable kexec, hibernation and
+ GICv4 direct LPI injection for the host. To force nVHE
+ on VHE hardware, add
"arm64_sw.hvhe=0 id_aa64mmfr1.vh=0" to the
command-line.
"nested" and "protected" are experimental and should be
@@ -3296,7 +3297,8 @@ Kernel parameters
kvm-arm.vgic_v4_enable=
[KVM,ARM,EARLY] Allow use of GICv4 for direct
- injection of LPIs.
+ injection of LPIs. Has no effect when
+ kvm-arm.mode=protected.
kvm-arm.wfe_trap_policy=
[KVM,ARM] Control when to set WFE instruction trap for
diff --git a/drivers/irqchip/irq-gic-common.h b/drivers/irqchip/irq-gic-common.h
index 710cab61d9195..3ce1dc7abf648 100644
--- a/drivers/irqchip/irq-gic-common.h
+++ b/drivers/irqchip/irq-gic-common.h
@@ -10,6 +10,9 @@
#include <linux/irqdomain.h>
#include <linux/msi.h>
#include <linux/irqchip/arm-gic-common.h>
+#ifdef CONFIG_ARM64
+#include <linux/kvm_host.h>
+#endif
struct gic_quirk {
const char *desc;
@@ -29,6 +32,16 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,
void gic_enable_of_quirks(const struct device_node *np,
const struct gic_quirk *quirks, void *data);
+#ifdef CONFIG_ARM64
+/* is_protected_kvm_enabled() can't be used, as the GIC probes before the cpucaps are final. */
+static inline bool gic_is_protected_kvm(void)
+{
+ return kvm_get_mode() == KVM_MODE_PROTECTED;
+}
+#else
+static inline bool gic_is_protected_kvm(void) { return false; }
+#endif
+
#define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0)
#define RDIST_FLAGS_RD_TABLES_PREALLOCATED (1 << 1)
#define RDIST_FLAGS_FORCE_NON_SHAREABLE (1 << 2)
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 94873646d46fb..f02c568d95653 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -1123,6 +1123,14 @@ static void gic_update_rdist_properties(void)
gic_iterate_rdists(__gic_update_rdist_properties);
if (WARN_ON(gic_data.ppi_nr == UINT_MAX))
gic_data.ppi_nr = 0;
+
+ /* pKVM doesn't emulate the vLPI commands. */
+ if (gic_is_protected_kvm() && gic_data.rdists.has_vlpis) {
+ pr_info("GICv4 features disabled in protected KVM mode\n");
+ gic_data.rdists.has_vlpis = false;
+ gic_data.rdists.has_rvpeid = false;
+ }
+
pr_info("GICv3 features: %d PPIs%s%s\n",
gic_data.ppi_nr,
gic_data.has_rss ? ", RSS" : "",
--
2.47.3
next prev parent reply other threads:[~2026-11-18 15:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:18 [PATCH v4 00/13] KVM: ITS hardening for pKVM Fuad Tabba
2026-11-18 15:18 ` [PATCH v4 01/13] KVM: arm64: Donate MMIO to the hypervisor Fuad Tabba
2026-11-18 15:18 ` [PATCH v4 02/13] KVM: arm64: Take host-registered MMIO regions at pKVM finalisation Fuad Tabba
2026-11-18 15:18 ` Fuad Tabba [this message]
2026-11-18 15:18 ` [PATCH v4 04/13] irqchip/gic-v3-its: Page-align ITT allocations in pKVM Fuad Tabba
2026-11-18 15:18 ` [PATCH v4 05/13] irqchip/gic-v3-its: Compute the wait target under the ITS lock Fuad Tabba
2026-11-18 15:18 ` [PATCH v4 06/13] KVM: arm64: Share the ITS command field accessors with the hypervisor Fuad Tabba
2026-11-18 15:18 ` [PATCH v4 07/13] KVM: arm64: Deprivilege the host under stop_machine() Fuad Tabba
2026-11-18 15:18 ` [PATCH v4 08/13] irqchip/gic-v3-its: Add the pKVM takeover entry points Fuad Tabba
2026-11-18 15:19 ` [PATCH v4 09/13] KVM: arm64: Emulate the ITS command queue Fuad Tabba
2026-11-18 15:19 ` [PATCH v4 10/13] KVM: arm64: Take the ITS tables and restrict GITS_BASER<n> Fuad Tabba
2026-11-18 15:19 ` [PATCH v4 11/13] KVM: arm64: Take the ITT of every device the host maps Fuad Tabba
2026-11-18 15:19 ` [PATCH v4 12/13] KVM: arm64: Reject ITS commands whose IDs are out of range Fuad Tabba
2026-11-18 15:19 ` [PATCH v4 13/13] Documentation: KVM: arm64: Describe the ITS hardening 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=20261118151904.4099560-4-fuad.tabba@linux.dev \
--to=fuad.tabba@linux.dev \
--cc=Sascha.Bischoff@arm.com \
--cc=bgrzesik@google.com \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=radu@rendec.net \
--cc=rananta@google.com \
--cc=sebastianene@google.com \
--cc=seiden@linux.ibm.com \
--cc=smostafa@google.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=tglx@kernel.org \
--cc=vdonnefort@google.com \
--cc=vladimir.murzin@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
--cc=zenghui.yu@linux.dev \
/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.