From nobody Thu Apr 9 07:16:34 2026 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C9F3D8912 for ; Tue, 10 Mar 2026 12:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773146998; cv=none; b=phdmaQZvBPSYhLYf2v+f/tQkTz66sLkHFXG3wzkUtbwpqqji1jc10PRS10pFgeyIiLXU5Czd//kb4LPaz0QrsOimMQq/IkW7zdRLN9FJ5S/sps8XdalK3IBL2PVyMJNGAsrJ1PwKMEeIeiKLACyZF1jFqzPEiZkF9HfxnLjRXNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773146998; c=relaxed/simple; bh=LsNi7e8n3RFGuOzyrWgX5uI+Z/GYNBc3tYFBs+03ZZM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JHeleHZY2fT4H8ZsHnIZXjZ24YgdRfJpYUyYevx/vf4O+mcTiW2edmvU5BjgoZ1eNjQQEH1w2FpSGMRZvZ1+WWcXMcJEwNWqTytEYzCt5COV2mX4n6vBC6eh5KuAuGjzgH/sSIiIuaQ2b0B7ubB6FDi8xFfc2VSex1FrKv8unPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qOCXypch; arc=none smtp.client-ip=209.85.208.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qOCXypch" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-662a61be7a5so1565036a12.3 for ; Tue, 10 Mar 2026 05:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773146996; x=1773751796; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6R0MEPExNqGukuDQgEpxXtxN4aPLVf9h/otxBvo9VYk=; b=qOCXypchmSF0PtKC7gXYISxp5Yw6M29bEojg1MLwGSU1U8E4UWDi3Bjkf/Aa0zzy7N DwTiC6gAVign0+9PInmmubcAoko2DXzB+iHSnK0nAdX7f5rPWy1tqO7n8uuS2zEwKr0Z E12fBy3I6eFe+MMqkgqzoyUc+6bW7eDcFBAsbJv8EZxlmmBQxjFcLT03DYD+1UTXEVIs NjtgenoOdx+h5vdZY38eMGht5afq8AjoPMxUNvyVzAJ92GZBsns0Tdy9NBFCyJJdQ2bk gdWzvaNtqEAsW9hTkG3yqy+RxgNcHyVl8kYRBn8PypQxZYOXH5jAH+H7fMH8npa1+uL8 gOOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773146996; x=1773751796; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6R0MEPExNqGukuDQgEpxXtxN4aPLVf9h/otxBvo9VYk=; b=cW3RcwqDqrqghGgCXS2rpYlKGCizI90E4j90hQzP/8F57bDcBwjRZTH7IlpeGbb7lj xeT8yfjcbQmvUf4hOHjipMEiaXiwODWfPkjzoZnk7TuSeRrUf3kZLG9XL4XZ1qukAyUJ qcK1ZWDwRNcFtKn1yFSPzsK2mHuAjHF1+9nm5ec5FpDtTyjbW22IGH6r89TrDEPPsELx yOBuUHTvi7GgmF/3hZIrvZrG2ZNLsf3YW+71YsyB7Ho7YJNLnTMC1gl6otN39SLDaeTC ZpECcSGXX4BpUn+UXBwx7YRvAXb1hpJ+LB1bCh+gkqt35ZRts6R59A+gRdRy37wdCBzn lnBg== X-Forwarded-Encrypted: i=1; AJvYcCW1PO5ueqUo4wonmv77RxJNql+WC2fLTI5YUXk/J675IUjTZvGy+ZDLZCyigJ8DLfq0bKmIMa+Mjdj6cJs=@vger.kernel.org X-Gm-Message-State: AOJu0YwMkjrL3eUXTz2MLpsJT4CSwIU4uX1Jse5fs5u8GP4cHNsf7o3R T8kQPmxHvW7o854wffCr4bUTb7ssHxCRTvPoMnnfcadVlG3PRqB9EWSzYQaabao4Ns50olGVqz9 YUS9jelT9gt5SxZYzcB0XYbm8mgbDqQ== X-Received: from edtb1.prod.google.com ([2002:aa7:c901:0:b0:662:85d8:35f8]) (user=sebastianene job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:1463:b0:662:bd98:890a with SMTP id 4fb4d7f45d1cf-662bd988b1bmr1727440a12.25.1773146995409; Tue, 10 Mar 2026 05:49:55 -0700 (PDT) Date: Tue, 10 Mar 2026 12:49:30 +0000 In-Reply-To: <20260310124933.830025-1-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260310124933.830025-1-sebastianene@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260310124933.830025-12-sebastianene@google.com> Subject: [PATCH 11/14] KVM: arm64: Restrict host updates to GITS_CTLR From: Sebastian Ene To: alexandru.elisei@arm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com Cc: catalin.marinas@arm.com, dbrazdil@google.com, joey.gouly@arm.com, kees@kernel.org, mark.rutland@arm.com, maz@kernel.org, oupton@kernel.org, perlarsen@google.com, qperret@google.com, rananta@google.com, sebastianene@google.com, smostafa@google.com, suzuki.poulose@arm.com, tabba@google.com, tglx@kernel.org, vdonnefort@google.com, bgrzesik@google.com, will@kernel.org, yuzenghui@huawei.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prevent unpredictable hardware behavior when the host tries to enable the ITS while it is not in quiescent state. Signed-off-by: Sebastian Ene --- arch/arm64/kvm/hyp/nvhe/its_emulate.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/its_emulate.c b/arch/arm64/kvm/hyp/nvh= e/its_emulate.c index 4782a9a24caa..539d2ee3b58e 100644 --- a/arch/arm64/kvm/hyp/nvhe/its_emulate.c +++ b/arch/arm64/kvm/hyp/nvhe/its_emulate.c @@ -274,6 +274,23 @@ static void cwriter_read(struct its_priv_state *its, u= 64 offset, u64 *read) *read =3D readq_relaxed(its->base + GITS_CWRITER); } =20 +static void ctlr_read(struct its_priv_state *its, u64 offset, u64 *read) +{ + *read =3D readq_relaxed(its->base + GITS_CTLR); +} + +static void ctlr_write(struct its_priv_state *its, u64 offset, u64 value) +{ + u64 ctlr =3D readq_relaxed(its->base + GITS_CTLR); + bool is_quiescent =3D !!(ctlr & GITS_CTLR_QUIESCENT); + bool is_enabled =3D !!(ctlr & GITS_CTLR_ENABLE); + + if (!is_enabled && (value & GITS_CTLR_ENABLE) && !is_quiescent) + return; + + writeq_relaxed(value, its->base + GITS_CTLR); +} + #define ITS_HANDLER(off, sz, write_cb, read_cb) \ { \ .offset =3D (off), \ @@ -284,6 +301,7 @@ static void cwriter_read(struct its_priv_state *its, u6= 4 offset, u64 *read) =20 static struct its_handler its_handlers[] =3D { ITS_HANDLER(GITS_CWRITER, sizeof(u64), cwriter_write, cwriter_read), + ITS_HANDLER(GITS_CTLR, sizeof(u64), ctlr_write, ctlr_read), {}, }; =20 --=20 2.53.0.473.g4a7958ca14-goog