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 61B7DC282DE for ; Mon, 10 Mar 2025 12:01:41 +0000 (UTC) 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-Owner; bh=swqLJD1zmkibMtfSn6R9cMXCjmgdwOWTNzzjrsl2YnM=; b=Ea8A03Ue+3JipcUps/LJYe/6rO MHbpsTRXvUub2yx5WDXizZ74vicqQrLbyu/yzeYh5/gJAgoF4nqWqD8czPXwQGZLXr7NGAD4e+la+ 5PdAsc9P3PhiJ00V17LCuWosvyG8QfXBxXSY/2AmNMcLetr4S/3V9BB4Hmpcn24APDtGPrjnHcxvY 6K6fHVgSPqjZw03kdtv47OO2526HyENUHM8jj/k6tBGLv9SaJfSBIt8mOL/4bDrSLo6AgzvCqxh2E B661HtFelxkXX0nvZtzVEdxRGc9wVBCpG5o5+R4fQMJlTI87SHeh2mZyDgd8/+vVNH3CNzvnM8pX3 QKptjK6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1trbp3-00000002Via-14Si; Mon, 10 Mar 2025 12:01:29 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1trbX2-00000002Sxq-0Hf0 for linux-arm-kernel@lists.infradead.org; Mon, 10 Mar 2025 11:42:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9E3555C5D3C; Mon, 10 Mar 2025 11:40:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1608FC4CEE5; Mon, 10 Mar 2025 11:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741606971; bh=xypKLBSRK+f/hP1WP1Z/qtoHUvhbr3rrnxD0zz/vPi0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Bram9Ioq++dX2SLjUUUyVswCF6Rk9Ou8XjSu6yp70TNv3b11WBAuN2o2/BdZ08KNL Lo50Ux7k1hEwZJZ4/4Gtl77Ea9oNstZyxqBHPQY1b8ueiFOymzd8Wc7OBDWvJUwKa+ NPJygOZNQQDdqzsCYHdihQzS1IunX9yeaG8LAUB2H6cS2LEUydWJuDcfot8rw3/fGf 6fGjMl/DvlBewrnUSkNvD06BOcZfdNiB3xCxaHMlLbu2AWNVR/KjcH0JHhzOok4BFo bQlDEhqeBU6mnUnQnWVp0VZdhtoxNvpC50SbWrP/D/pLl8oeC5iEHA+Pk7E+YcA624 Y8aYSqp/wi6DQ== 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 1trbWy-00C9i8-I3; Mon, 10 Mar 2025 11:42:48 +0000 Date: Mon, 10 Mar 2025 11:42:48 +0000 Message-ID: <8634flp0w7.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Mark Rutland Subject: Re: [PATCH 07/18] KVM: arm64: Compute FGT masks from KVM's own FGT tables In-Reply-To: References: <20250210184150.2145093-1-maz@kernel.org> <20250210184150.2145093-8-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.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) 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: tabba@google.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, mark.rutland@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-20250310_044252_213535_34E50AE4 X-CRM114-Status: GOOD ( 24.84 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 04 Mar 2025 16:55:50 +0000, Fuad Tabba wrote: > > Hi Marc, > > On Mon, 10 Feb 2025 at 18:42, Marc Zyngier wrote: > > > > In the process of decoupling KVM's view of the FGT bits from the > > wider architectural state, use KVM's own FGT tables to build > > a synthitic view of what is actually known. > > synthitic -> synthetic > > > > This allows for some checking along the way. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/include/asm/kvm_arm.h | 4 ++ > > arch/arm64/include/asm/kvm_host.h | 14 ++++ > > arch/arm64/kvm/emulate-nested.c | 102 ++++++++++++++++++++++++++++++ > > 3 files changed, 120 insertions(+) > > > > diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h > > index 8d94a6c0ed5c4..e424085f2aaca 100644 > > --- a/arch/arm64/include/asm/kvm_arm.h > > +++ b/arch/arm64/include/asm/kvm_arm.h > > @@ -359,6 +359,10 @@ > > #define __HAFGRTR_EL2_MASK (GENMASK(49, 17) | GENMASK(4, 0)) > > #define __HAFGRTR_EL2_nMASK ~(__HAFGRTR_EL2_RES0 | __HAFGRTR_EL2_MASK) > > > > +/* Because the sysreg file mixes R and W... */ > > +#define HFGRTR_EL2_RES0 HFGxTR_EL2_RES0 (0) > > +#define HFGWTR_EL2_RES0 (HFGRTR_EL2_RES0 | __HFGRTR_ONLY_MASK) > > __HFGRTR_ONLY_MASK is a hand-crafted bitmask. The only bit remaining > in HFGxTR_EL2 that is RES0 is bit 51. If that were to be used as an > HFGRTR-only bit without __HFGRTR_ONLY_MASK getting updated, then > aggregate_fgt() below would set its bit in hfgwtr_masks. Could this be > a problem if this happens and the polarity of this bit ends up being > negative, thereby setting the corresponding nmask bit? This could become a problem indeed. But the only fix for that is to kill the HFGxTR stupidity and describe all the bits as needed so that we stop assuming things. I'm half tempted to do that next. Thanks, M. -- Without deviation from the norm, progress is not possible.