From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.13.136.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796165462; b=RnGahprVZsT3l2Cfug7eBmohsXS+/ZbVELZonkJ4vyccMTWs081bjm4kRDyw0eUWLdfw CJftG5FQZRAESdFTXfymzFouPO0Cl4rujMlsr9f4GMBBl2cqjmfDuVREMd6mFcEhJT192 eXBt9Yjcx7ZxnWgnLuehBdmHfYvaK68+ggslE0oeedpMwDJDMEPUdAT4zjOV4sXufm67T vhvyXt0vKBWm26B5tSkHFDnTso0cipWepaJrURGDh3wsvbevW4U89w14UADFBUg0w01MU D9mfL1Lyfqozwe9gzhXaY7Fbf1W9Ff2yTfSX9/ADDVPBTzz31ky1N6SR/yzFUuNeYCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796165462; h=DMARC-Filter:Received:DKIM-Signature:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-Server-Quench:X-Auth-PaT:X-AuthReport-Spam:X-AuthRoute: X-Authentic-SMTP:X-AuthFastPath:X-AuthVirus-Status; bh=xDDSXL+Rfn779zO4MYfMQ7nfDGBkfUKW7+gyMpmLnCI=; b=ldiKfR79ksAKIhTr4g8eh8pRKiYVnZL0vR74FaPgqseOi/X5H1TXHRxXdNn4CkPS5scA Bf69eT0FXJ9o2GOMjfW/degqf7jci7yKfcyPccHlNEw1HqG0rB/y+tS8spu9wP44QVDBR Apd/j3mUKQiVTFOamwKa9xIxy33ViIZNmc3VUB6FCgOG4YCEZNpCZVGuJGw8SIuviJ2WN w3JqK8syNiAGNycczzZlUXGZlAepfQwtxIxv9JsAYBsGUpg91Wa8+81s92Cc0owuGBnkX XZshq9zLNLh9ogS4L9fNBkJgjYR4blpYB6tUvaqZRzkOZErPoEDfqMh4bTasUdJ4dYA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=riscosopen.org; spf=pass smtp.mailfrom=riscosopen.org; dkim=pass header.d=riscosopen.org header.i=@riscosopen.org header.a=rsa-sha256 header.s=authsmtp header.b=ktgcUMoB; arc=none smtp.remote-ip=62.13.136.48 Received: from mta481g.authsmtp.com (mta481g.authsmtp.com [62.13.136.48]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1755606A31A for ; Tue, 1 Dec 2026 22:50:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1755606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscosopen.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscosopen.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=riscosopen.org header.i=@riscosopen.org header.a=rsa-sha256 header.s=authsmtp header.b=ktgcUMoB Received: from mail-c232.authsmtp.com (mail-c232.authsmtp.com [62.13.128.232]) by punt20.authsmtp.com. with ESMTPS id 6B1MovUZ005329 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 1 Dec 2026 22:50:57 GMT (envelope-from bavison@riscosopen.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscosopen.org; s=authsmtp; t=1796165457; bh=xDDSXL+Rfn779zO4MYfMQ7nfDGBkfUKW7+gyMpmLnCI=; h=Date:From:To:Subject; b=ktgcUMoBshY1DW1x0sTjGnAy9xCLF8vVKBR+VV4lS4kswslfmm+S9P93ysyW0LwPk Ueq+GRF0WFUMGJLJ0dBi6+av9GVM4rPyV8mtzOXl2P+uUWQVpigi2iKf/VIbRBzGV9 b7hptR3bU4tgg4Q/YQ0tiwIJz3eFZ7ZVbGkgPTml8hX2Vwvb089mGsKjFNpktxAZoL Xg9Ik36YBe03L0pl2H3Y0MkyZEV4wtB+q0gsz30AxjB6M9x4fwOqqFntJFCA5K46Bx gj6W9uDvZ3hYyTRL4/jNgoenOueyQmmB3OarqtnbR01I9Ngo4DdaCh0Zs4mRFozF6T Y2CMn1NUgdf9g== Received: from riscosopen.org (customer.lndngbr1.isp.starlink.com [9.246.111.41] (may be forged)) (authenticated bits=0) by mail.authsmtp.com with ESMTPSA id 6B1Mou35051102 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 1 Dec 2026 22:50:56 GMT (envelope-from bavison@riscosopen.org) From: Ben Avison To: Marc Zyngier , Oliver Upton Cc: Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Akihiko Odaki , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ben Avison , stable@vger.kernel.org Subject: [PATCH] KVM: arm64: Give AArch32 guests' CLIDR reads the vCPU's CLIDR_EL1 Date: Tue, 1 Dec 2026 22:50:16 +0000 Message-ID: <20261201225016.62335-1-bavison@riscosopen.org> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Server-Quench: abe0cbc3-edd9-11f1-9a18-7cd30ad786ce X-Auth-PaT: 10 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCd1YggXA1ZfRRob ESQCJDVBUg4iPRpU DBlFKhFVNl8UURhQ KkJXbgMIcUtEHBZ1 VjUUWVRWVk1zW2lw awBUaktUfEhKWRtr UUlXRlNNEQ1vHh1P AGwfL0Y3dABGfX9x ZUQsWnhbX0E0JBQo Qh0GRm4bMDM0YX0e URZZagoFcQtXeUwR aVAuAHQFZzZSKBEA NjMYHwV5Hgt6emxc WARTcQBabkcVE3YV bgoJHW51VUIYSj4v NFNuAXo9MHxZKEg7 PUBpRVIVewE5MjAR BAlmJA51HW4sY3ND X-Authentic-SMTP: 61633632303230.1037:9715 X-AuthFastPath: 0 (Was 255) X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. Since commit 7af0c2534f4c ("KVM: arm64: Normalize cache configuration"), access_clidr() returns __vcpu_sys_reg(vcpu, r->reg), but the cp15_regs[] entry for the AArch32 CLIDR (MRC p15, 1, , c0, c0, 1) names no register, so r->reg is 0 (__INVALID_SYSREG__) and a 32-bit EL1 guest reads 0: no caches, LoC 0. The register is trapped (HCR_EL2.TID2, or TID4 with FEAT_EVT), so the hardware's value never shows either. The AArch32 CLIDR is architecturally mapped to CLIDR_EL1[31:0], so it should read what the vCPU's CLIDR_EL1 holds, as 64-bit guests already do. Name CLIDR_EL1 in the entry, as its neighbour CSSELR does with CSSELR_EL1. Seen on a Raspberry Pi 4 (Cortex-A72) with QEMU -cpu host,aarch64=off: my guest kernel stops in its CPU set-up because CLIDR doesn't report separate L1 instruction and data caches. With this patch the guest reads 0x09200003 (separate L1 I and D; LoUIS, LoC and LoUU 1), the value KVM fabricates for CLIDR_EL1 on that machine. The bug was found, and this patch written, with the help of an AI coding assistant (Claude, in Claude Code); I have reviewed and tested it. Fixes: 7af0c2534f4c ("KVM: arm64: Normalize cache configuration") Cc: stable@vger.kernel.org Signed-off-by: Ben Avison --- Testing: on a Raspberry Pi 4 Model B (Cortex-A72: nVHE, no FEAT_EVT or FEAT_S2FWB) with the Raspberry Pi kernel tree (rpi-6.18.y, 6.18.65) plus this patch, QEMU 10.0.13, -accel kvm -cpu host,aarch64=off. A minimal AArch32 guest that reads its ID registers at EL1 sees CLIDR 0x00000000 under the stock 6.18.50 kernel and 0x09200003 with the patch; CTR and MIDR read the same under both. My 32-bit kernel now gets past the CLIDR check in its CPU set-up. 64-bit guests (bare-metal test kernels and benchmarks under -cpu host) behave as before. On v7.4-rc1, the base here, it was only build-tested (clang, arm64 defconfig, W=1: no warnings). Not run: the KVM selftests and kvm-unit-tests (as far as I know, none of them reads CLIDR from a 32-bit EL1 guest). Only nVHE was tested: the A72 has no VHE. checkpatch --strict flags the changed line's "CRn( 0)" spacing and the Op1/CRn/CRm/Op2 macro names: that is the style of every entry in the table, kept as it is. arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 850eba167..955bf1e4e 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -4809,7 +4809,7 @@ static const struct sys_reg_desc cp15_regs[] = { { CP15_PMU_SYS_REG(DIRECT, 0, 14, 15, 7), .access = access_pmu_evtyper }, { Op1(1), CRn( 0), CRm( 0), Op2(0), access_ccsidr }, - { Op1(1), CRn( 0), CRm( 0), Op2(1), access_clidr }, + { Op1(1), CRn( 0), CRm( 0), Op2(1), access_clidr, NULL, CLIDR_EL1 }, /* CCSIDR2 */ { Op1(1), CRn( 0), CRm( 0), Op2(2), undef_access }, base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 -- 2.43.0