[PATCH v2 10/13] KVM: arm64: Restrict host updates to GITS_CTLR

From: Sebastian Ene

Date: Fri Aug 07 2026 - 13:10:36 EST


Prevent unpredictable hardware behavior when the host tries to enable
the ITS while it is not in quiescent state.

Signed-off-by: Sebastian Ene <sebastianene@xxxxxxxxxx>
---
arch/arm64/kvm/hyp/nvhe/its_emulate.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

diff --git a/arch/arm64/kvm/hyp/nvhe/its_emulate.c b/arch/arm64/kvm/hyp/nvhe/its_emulate.c
index 5629e2a070df..b9b71aa18d48 100644
--- a/arch/arm64/kvm/hyp/nvhe/its_emulate.c
+++ b/arch/arm64/kvm/hyp/nvhe/its_emulate.c
@@ -403,8 +403,35 @@ static void cwriter_read(struct pkvm_protected_reg *region, u64 offset, u64 *rea
*read = readq_relaxed(its->base + GITS_CWRITER);
}

+static void ctlr_read(struct pkvm_protected_reg *region, u64 offset, u64 *read)
+{
+ struct its_priv_state *its = region->priv;
+ *read = readl_relaxed(its->base + GITS_CTLR);
+}
+
+static void ctlr_write(struct pkvm_protected_reg *region, u64 offset, u64 value)
+{
+ struct its_priv_state *its = region->priv;
+ bool is_quiescent, is_enabled;
+ u32 ctlr;
+
+ ctlr = readl_relaxed(its->base + GITS_CTLR);
+ is_quiescent = !!(ctlr & GITS_CTLR_QUIESCENT);
+ is_enabled = !!(ctlr & GITS_CTLR_ENABLE);
+
+ /*
+ * If it's disabled and not in quiescent state and it tries to enable
+ * it, bail out.
+ */
+ if (!is_enabled && (value & GITS_CTLR_ENABLE) && !is_quiescent)
+ return;
+
+ writel_relaxed(value, its->base + GITS_CTLR);
+}
+
static struct its_handler its_handlers[] = {
ITS_HANDLER(GITS_CWRITER, sizeof(u64), cwriter_write, cwriter_read),
+ ITS_HANDLER(GITS_CTLR, sizeof(u32), ctlr_write, ctlr_read),
{},
};

--
2.55.0.654.g21b8a5bc05-goog