From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18C9EC48BF6 for ; Thu, 29 Feb 2024 18:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a3pOgHcsqj8bGQyXkT4V+4S61Ky57vP1Tva+0KP11pY=; b=ErxQHF/p4PUB2z l9sCLGv18l6Q+8dBOTVIFsQIQDP7KLQQrM+jDBtAXlM5zYw8IArCkZ6tChiZbB8QjMX2+qBSTEuBv jOMUIhoBE2WQO8wt22H1njgjukAIRPe7vx1439RVkqTiO3Y/6dfH4Btr9RjOUgYE9HuEIrTmdhTIO hwqSkvDlpJBeh19MDS6ZGUgudT/gNyvpmuhhlN50zvbe0pjw06jnoRZXJVfV2yjm9kfX4qp1Nnvgf MROmTss3z6OH/cox6R2NPzYDDTysQu23gjZVwRhO1slKuz7ltYFcbhUkOBLdpmnMSKMEbDCN29Mmm X8aPSJ7FNzj+42NdohBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfl5I-0000000Ehfr-2cME; Thu, 29 Feb 2024 18:24:44 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfl5E-0000000Ehdi-302D for linux-arm-kernel@lists.infradead.org; Thu, 29 Feb 2024 18:24:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 36B7460AC7; Thu, 29 Feb 2024 18:24:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5E30C433F1; Thu, 29 Feb 2024 18:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709231079; bh=djivfC0fMA7FF09Y1zo65j9t8YhyySEZcKWiLhmxvqQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AVa8AwGOMwnS0YIZ9bWOWt60pTx0ndN3pNV5X1TuFNy/3JN2w6nlqO1iKQBEzRRj1 1x5u4eejF4L/5PIG5VfvtXe4T/q130l/tKQbBb1Re+/adh6exvUfOu8+UWFHTbb2vo B2V7eLTlQK5tu3P1seIjNo5n7DXgXexUig8AtNN7aKYxaN3d6cf37jfnZwBgNxh9Ap ruChnaKibGGLWAUb35b2OySoRvr0irrgLYrn8UTFBMxUOqmKVPi1IGlevd23Txws5g J75iuh4qvXGwt69VcEf7FWe/nl+Zq5zwn+It5fhrDoS8XDu+PV9ZqhXk2vnxyXkze6 0RkBWqt47cSFg== 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.95) (envelope-from ) id 1rfl5B-0087lh-F4; Thu, 29 Feb 2024 18:24:37 +0000 Date: Thu, 29 Feb 2024 18:24:37 +0000 Message-ID: <864jdr2knu.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , James Clark , Anshuman Khandual Subject: Re: [PATCH] KVM: arm64: Fix TRFCR_EL1/PMSCR_EL1 access in hVHE mode In-Reply-To: References: <20240229145417.3606279-1-maz@kernel.org> 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/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, james.clark@arm.com, anshuman.khandual@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240229_102440_905855_3CA67FE1 X-CRM114-Status: GOOD ( 28.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 29 Feb 2024 17:37:08 +0000, Oliver Upton wrote: > > Hey, > > On Thu, Feb 29, 2024 at 02:54:17PM +0000, Marc Zyngier wrote: > > When running in hVHE mode, EL1 accesses are performed with the EL12 > > accessor, as we run with HCR_EL2.E2H=1. > > > > Unfortunately, both PMSCR_EL1 and TRFCR_EL1 are used with the > > EL1 accessor, meaning that we actually affect the EL2 state. Duh. > > > > Switch to using the {read,write}_sysreg_el1() helpers that will do > > the right thing in all circumstances. > > I was wondering if there was a way to surface these screw-ups at compile > time, but there's nothing elegant that comes to mind. Guess we need to > be very careful reviewing "nVHE" changes going forward. My take on this is that there should hardly be any read_sysreg_s() in the KVM code at all. We should always use read_sysreg_el*() so that there is no ambiguity about the state we're dealing with (that's, of course, only valid for registers that have both an EL1 and an EL2 counterpart -- registers that are shared across ELs must still use the read_sysreg_s() accessor). It would also free the drive-by hacker from having to understand the subtleties of the E2H redirection. The macros do the right thing everywhere (they are context aware), and they should be the first port of call. > > > Note that the 'Fixes:' tag doesn't represent the point where the bug > > was introduced (there is no such point), but the first practical point > > where the hVHE feature is usable. > > > > Cc: James Clark > > Cc: Anshuman Khandual > > Fixes: 38cba55008e5 ("KVM: arm64: Force HCR_E2H in guest context when ARM64_KVM_HVHE is set") > > Signed-off-by: Marc Zyngier > > Reviewed-by: Oliver Upton Thanks. What should we do about it? Fix for 6.8, or part of the 6.9 drop? hVHE+tracing is a pretty niche thing, and I don't have any other fix for the time being... M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel