From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66B8E606A325 for ; Thu, 19 Nov 2026 16:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=xpplCgVy; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SEdJ2gix DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=Y4L+6oVmWqwrFfx2LJ3E+02/7jmDMc+Yi0esheg1PZo=; b=xpplCgVyjWi13jUT8rQcIqcrYX t38/6Muh4gF0zHnJIuBluAQOwsOmIeX+t/o9XZRMTfqzjpcurZFzFoCsHYHQGq5p66qJw/l5FFkFP 64ID/3Iu9nIe27n/QuqCHWty9ihh9TaRUPJNJb7b8YNUTmUWBhPravP74yCB3w55UxGleSwcvLGuO UtZjqPBhCPdLvBtgghBs9yYZy6q0XrYsvWpRM/8BKpMku5nMnOX7CS7cIz0MezCMNSK/cIk2QZnJj gOrtlkSWG9GR1+Wn3k16lt2kswwMfkA6Wq1Px7MlpTX1Cm2petp2a4s1sG8JBilABb/AbMSr2T1JF q9WrTF5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xU53N-0000000CeKb-0STi; Thu, 19 Nov 2026 16:32:05 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xU53M-0000000CeKM-0xUl for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2026 16:32:04 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 7FFB144D2F; Thu, 19 Nov 2026 16:32:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EBC61F000C8; Thu, 19 Nov 2026 16:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795105923; bh=Y4L+6oVmWqwrFfx2LJ3E+02/7jmDMc+Yi0esheg1PZo=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=SEdJ2gixFVuzYzP+ru8fvUB8Cxdv+1ZP3Q959zolej54XHbW4rtTZnq0Ix6KsegGj OPVIpR0lDjbq0cTNq9cqVCvRO9dN21mIAHyMnjGdEagvszWaPna26n4KeUJN//PiDY TN7YnyDOOJewc9wkFPhusCjjRHuRfYN5tJagEh4ZyQwpzBeF2rLLF0g0kTgfbQ3TbU cbwEQHLSiFcijQ7SxQEvzN44a/RwkuO/Aj0wQ+lbp3wOeHETY84qIsAM99zvcL4GX4 663rlB1T0xPt23bVZezzy8uQJjbZoQZOcZimguv3zI7/K5SPxS/dClhuAZbxU0eSfz Y9tm075JDb0HQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xU53I-00000000Yep-3czz; Thu, 19 Nov 2026 16:32:00 +0000 Date: Thu, 19 Nov 2026 16:32:00 +0000 Message-ID: <86wlq8zssf.wl-maz@kernel.org> From: Marc Zyngier To: Dan Carpenter Cc: Oliver Upton , Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Jintack Lim , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Karthik Bhargavan , =?UTF-8?B?Q2zDqW1lbnQ=?= Blaudeau , stable@vger.kernel.org Subject: Re: [PATCH v2 2/4] KVM: arm64: Trap TCR2_EL1 writes when S1PIE or S1POE is hidden In-Reply-To: <20261119-nv-tcr2-v2-2-3deb1a6cdba8@pereq.eu> References: <20261119-nv-tcr2-v2-0-3deb1a6cdba8@pereq.eu> <20261119-nv-tcr2-v2-2-3deb1a6cdba8@pereq.eu> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-Archived-By: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: dan@pereq.eu, oupton@kernel.org, fuad.tabba@linux.dev, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, jintack.lim@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, karthik@pereq.eu, clement@cryspen.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, 19 Nov 2026 13:25:35 +0000, Dan Carpenter wrote: > > A VMM can offer FEAT_TCR2 to a guest but hide FEAT_S1PIE or FEAT_S1POE, > for example this is done to keep the VM migratable. KVM then stops > loading the PIR_EL1, PIRE0_EL1 and POR_EL1 registers for that guest. But > the guest's writes to the TCR2_EL1 register don't trap, and the CPU still > acts on its PIE, POE and E0POE bits. > > If a guest turned these features on, it would run with the permission > settings another VM left on the CPU. Technically this is a kind of > information leak and a guest could figure out another guests permission > setting based on which accesses fault. > > For these VMs, set the TCR_EL1 bit in HFGWTR_EL2 so that writes to > TCR_EL1 and TCR2_EL1 trap, and clear the hidden bits in a new > access_tcr2_el1() handler. > > Fixes: 58627b722ee2 ("KVM: arm64: Make PIR{,E0}_EL1 UNDEF if S1PIE is not advertised to the guest") > Fixes: b86c9bea6349 ("KVM: arm64: Save/restore POE registers") > Cc: stable@vger.kernel.org > Signed-off-by: Dan Carpenter > --- > v2: This is a new patch > > This is only a partial fix, I will update nested virtualization in the > next patch and the !vcpu_has_nv(vcpu) condition in __compute_hfgwtr() will > go away. No, I really don't want to go down that road. Trapping TCR_EL1 is an absolute performance sink, and at this point it is not worth running VMs (it puts everyone at the level of AmpereOne). It also puts the penalty on well behaved guests which should be able to access TCR_EL1 as much as they want without penalties. Yes, the architecture is terrible, and we have to work around it. I can see two ways to address this: - load PIR/PIRE0/POR unconditionally so that they do not contain any state that logically belong to another guest, preferably with values that prevent any access (0 is a good candidate for the permissions). It means that if the guest plays with us, it will lose permission to its own memory accesses. - Move TCR2_EL1 to the sanitised set, and make sure that these bits are never evaluated by KVM, and will be cleared on each entry (we already do this for TCR2_EL2). Thanks, M. -- Without deviation from the norm, progress is not possible.