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 BCA47D778AE for ; Fri, 23 Jan 2026 19:16:55 +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-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=x96k+viorH0nU4fz8uuUkKaH/mxn5xDYQeODZFatZKg=; b=T4h+qUuQxuLiKPAgbvAzQ85LXg rNXbAOJLw2P52x2WqO0UWPRhjEmd6QxXr2RjKeoQLdEhx8MXJsq36JIpK4NAUQW7e1b48DL1cdb8I ATRPoFF7vu/7S7251DCSdte5LUHHmPRAec0zS8mWTr5IubiLV+BpS5s4Limge8gVouIZbKAMiKriv 5eE8j2QsHCaozlhYINuoMKZ8/Z+EaigNDQNxmEuD1o02dU3iNbH8m6Lmi4cNTJxHQUFkBxYyRRrPS oopo7D63q1LoQCRFx125nfpAr6pEpo3AfYplG4KxEJpUNhymPhXrUA0fdrYXs6UCecFxyynBgLB8C 2pfsRwhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vjMeH-00000009O2A-2ual; Fri, 23 Jan 2026 19:16:49 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vjMeB-00000009Nzc-2vgx for linux-arm-kernel@lists.infradead.org; Fri, 23 Jan 2026 19:16:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 0E42443BF6; Fri, 23 Jan 2026 19:16:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA4DBC4CEF1; Fri, 23 Jan 2026 19:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769195802; bh=XxB6UOz64bCcf9pmfvZiOwm4zMTUPBq+6kKgJ7LtMiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oogvoKpFPuV7RpbQn6CLNwFSkDa8ewZGdc7U82/x3VToh1JYSjMd4sI4wIDF0aEHf CV1l0vkIXpF2DanpXkzkLHHq0ty3X+2ZHb1HRdqqTyVzei26GI0BsA6RXFNTUtkSaI CR4rNcJa0LfKBN5t8jTs0vQTEIAvO1kmAGa9UJ2hwvqqoUJbd9vpK69Itsw9GdVWHw 2+n9zSTzsOQ/VT7BDmemvo5BKhgkkUgMPt7ULjWs5H0dA5+cKkOU9vZ1ZuTPcXQH+O G+Y+zl+n+s4QfNBd5GK2j9UjnTv7kJ4z86e8AMt9RiXxZ5xGaOAMM5XgYAqBNQl+Wl Bs9XPMp/9toAA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) 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 1vjMe8-00000005A2V-3NGw; Fri, 23 Jan 2026 19:16:40 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org Cc: Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Will Deacon , Quentin Perret , Fuad Tabba , Alexandru Elisei Subject: [PATCH v2 1/5] arm64: Add MT_S2{,_FWB}_AS_S1 encodings Date: Fri, 23 Jan 2026 19:16:33 +0000 Message-ID: <20260123191637.715429-2-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260123191637.715429-1-maz@kernel.org> References: <20260123191637.715429-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, will@kernel.org, qperret@google.com, tabba@google.com, alexandru.elisei@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-20260123_111643_778273_A929EEA0 X-CRM114-Status: GOOD ( 13.72 ) 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 pKVM usage of S2 translation on the host is purely for isolation purposes, not translation. To that effect, the memory attributes being used must be that of S1. With FWB=0, this is easily achieved by using the Normal Cacheable type (which is the weakest possible memory type) at S2, and let S1 pick something stronger as required. With FWB=1, the attributes are combined in a different way, and we cannot arbitrarily use Normal Cacheable. We can, however, use a memattr encoding that indicates that the final attributes are that of Stage-1. Add these encoding and a few pointers to the relevant parts of the specification. It might come handy some day. Reviewed-by: Joey Gouly Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/memory.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 9d54b2ea49d66..a2b7a33966ff1 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -175,19 +175,24 @@ #define MT_DEVICE_nGnRE 4 /* - * Memory types for Stage-2 translation + * Memory types for Stage-2 translation when HCR_EL2.FWB=0. See R_HMNDG, + * R_TNHFM, R_GQFSF and I_MCQKW for the details on how these attributes get + * combined with Stage-1. */ #define MT_S2_NORMAL 0xf #define MT_S2_NORMAL_NC 0x5 #define MT_S2_DEVICE_nGnRE 0x1 +#define MT_S2_AS_S1 MT_S2_NORMAL /* - * Memory types for Stage-2 translation when ID_AA64MMFR2_EL1.FWB is 0001 - * Stage-2 enforces Normal-WB and Device-nGnRE + * Memory types for Stage-2 translation when HCR_EL2.FWB=1. Stage-2 enforces + * Normal-WB and Device-nGnRE, unless we actively say that S1 wins. See + * R_VRJSW and R_RHWZM for details. */ #define MT_S2_FWB_NORMAL 6 #define MT_S2_FWB_NORMAL_NC 5 #define MT_S2_FWB_DEVICE_nGnRE 1 +#define MT_S2_FWB_AS_S1 7 #ifdef CONFIG_ARM64_4K_PAGES #define IOREMAP_MAX_ORDER (PUD_SHIFT) -- 2.47.3