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 D21B2C636EE for ; Wed, 28 Aug 2024 19:49:01 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:CC:To:From: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=/kMWr+JM6EHaPoCU9Pu7dCGEQ2cPpjuKSvSsnsL3r9c=; b=QMXyZYE0Usn7EVOypdILqXHLya zJPZWcvHBI+DsmBWDsHV2Mg5ToQmmkN6jIYvRXgSO2ZBl6D0Vps2eNj4Vh3ff+G3PyopfM94UKrhg bUS1H/MhPegmIQu+mwRWNofICwsbVL3RLL99bUylCpiCyEHL/zoBT+R9HlnTMD1mJiVnh/4FRBch5 Ra2qDDGWhJC4tU2YkN1d+djatrAk7l7Oe3yx8+FcjZ6f/EQKYucxV7EQCfKladLxE3ns/4dxCTmeI zVvLlGjumC050RMEL5EAcbFxz6Gn1cOMQh/btHdta0Zb7EJe3YWZmVBfCN6JURxXKS6q3qQKwdux0 pZm1NL7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjOev-0000000GmU0-1wvf; Wed, 28 Aug 2024 19:48:49 +0000 Received: from mail-dm6nam10on20606.outbound.protection.outlook.com ([2a01:111:f400:7e88::606] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjOe4-0000000GmJ6-3j4f for linux-arm-kernel@lists.infradead.org; Wed, 28 Aug 2024 19:47:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MxbBurpFvkGFo/0j70qQ+kDfK5FfapAudGxhBfQ4k+m16MrHRSghieppBCJH75S6bl6/ThC8zKBocoqOwZMLvwoPOc9LWn7ebQl6xbj3MLq169WuGyYMrF6U81qS9fZ6jhK+DNMAcg3Gib48v4itUXbvDZS/E1Fv/0fav/75Ft0u+90lOFTQBQDafPW4dckhJV3UPB90HlaUp7m0Gsh2eg5CBh3z6SG/qS/UaGZ70UDKJ42LNM2wgcvakTOwq0viP/pdukZBlcOyLqJfex9HsJNWUiMWGgmJGOraqPuoPi+KhVdtgyElSmC3p3kfMe/VSqr7ZZWZO1q4mIaq8XltCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/kMWr+JM6EHaPoCU9Pu7dCGEQ2cPpjuKSvSsnsL3r9c=; b=OBhpx+NpNsXYDxkCF7N5d5pJb1CYzPBNp+D20wyuSpHm6OtiCccH1ODZIZj53s+xYyNfJE9UUIlP+iWXGKYHQQAUcPvT4lewRyNaRP/W0j6C+Ykkq/g41ZtFdw5eNZicsHh3qWVzCamwMq2Ijv5vztGYNdWq9gfHwLmAUNF4PqDNIg8rUgE4ImYoXAdmcsaE7MeIcBbMtg5Jl6CdaUtzlNyTyKVzMRsRmNE6lOPEplHqxcLH3rd/luNzyMcFKMIjL3Vg2k08eXVvJHW4VkkXRITJ/1uEmq6wpQza/lXzYr9zXeD0Bc/FBYjOkuG29CSFRFNyjquyCZuFo0fGG76SDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=lists.linux.dev smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/kMWr+JM6EHaPoCU9Pu7dCGEQ2cPpjuKSvSsnsL3r9c=; b=mwe8p9L1AYlSNbPvCriDWTUmJiF/vjmJAfiXTEfEfxQOKwRxuRxN01wu1gTtOBpXB/kW/Casng2R8MhYQ2fA8C6HdFWm2DJA5kcWKDV/EwNADxkfjuZsYWrZWGbZdFaBxB8w1VIJ/tUHWy7xMEa2Ytmq8J7AfEq9XsxmzkpJC/C0jMLdDtHpjVJZntZf7GHN0JtsmdVNsDlt0jDRpEiY0Zjek0ZiJAMp0DwWkWLQD5r/efxROjyPgaOCfTx1QA/k5Kka5bEZjrpPsBbQN4kpoMbprXGxryINOEHHzd6xjD0lHFkn/MIGovhewHEowoT5JxW4EbNbTolreOShSCAEwQ== Received: from PH8PR07CA0015.namprd07.prod.outlook.com (2603:10b6:510:2cd::20) by PH7PR12MB9103.namprd12.prod.outlook.com (2603:10b6:510:2f5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.26; Wed, 28 Aug 2024 19:47:44 +0000 Received: from MWH0EPF000A672E.namprd04.prod.outlook.com (2603:10b6:510:2cd:cafe::74) by PH8PR07CA0015.outlook.office365.com (2603:10b6:510:2cd::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.29 via Frontend Transport; Wed, 28 Aug 2024 19:46:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by MWH0EPF000A672E.mail.protection.outlook.com (10.167.249.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 28 Aug 2024 19:47:43 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 28 Aug 2024 12:47:37 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 28 Aug 2024 12:47:37 -0700 Received: from Asurada-Nvidia (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Wed, 28 Aug 2024 12:47:36 -0700 Date: Wed, 28 Aug 2024 12:47:35 -0700 From: Nicolin Chen To: Jason Gunthorpe CC: , Hanjun Guo , , Joerg Roedel , Kevin Tian , , Len Brown , , , "Lorenzo Pieralisi" , "Rafael J. Wysocki" , Robert Moore , Robin Murphy , Sudeep Holla , Will Deacon , "Alex Williamson" , Eric Auger , Jean-Philippe Brucker , Moritz Fischer , Michael Shavit , , Shameerali Kolothum Thodi , Mostafa Saleh Subject: Re: [PATCH v2 2/8] iommu/arm-smmu-v3: Use S2FWB when available Message-ID: References: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> <2-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> <20240828183037.GC3773488@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240828183037.GC3773488@nvidia.com> X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672E:EE_|PH7PR12MB9103:EE_ X-MS-Office365-Filtering-Correlation-Id: e1b884fb-2178-40ad-96f1-08dcc79a48b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UrzA1/nVyJet2Dbg93TJP05rMzT2O2nq8GzVB+VWpf3UEgr/5QzlYdF6DtaA?= =?us-ascii?Q?An6/EsSviM2gNoJYBq65jTEoYQvs4VDQtVm7hJX0+c7ScOob8CaCx/BLXe0a?= =?us-ascii?Q?UOZKUFgOO958GJfNPgaImqVtGGorg0BWuIpz1lKUvhN72IhNMsKjS0Vk/Lzc?= =?us-ascii?Q?Yx5gw8ra+XXGFF5B7O1muW+N5BRvOVMEjhDDoxqlYeh6e24XAmfjYs+ehf1v?= =?us-ascii?Q?UMNFVFzNjUnJz/Xs+BG9fZKY/pWMY5QYu8m6KArhSSSuy7JNM7NxK97QYcWi?= =?us-ascii?Q?zIgNLAeIw8VaUnCPyuZw+Du0jQqJWYb3PxYNZXG8WoAb+NPs7osa4D7TRHyl?= =?us-ascii?Q?Ce//i+W40kXW1SiQUNkLZyKXW3uvMK+CCZtyRnWjWlZoYkDEgwVK9RsmhKVT?= =?us-ascii?Q?dDbAThxQ3fMyC4QjpnzGA2rKaslFOW0KHWYlr6m5JgMqf6SAQl+4PQSoen4i?= =?us-ascii?Q?nTiLtRscX+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QbvJxTAAgN?= =?us-ascii?Q?FKibgsK2aHBu8CswvGySk+IW5zqhaPbhQuaM96SFYhf8bhZeLnjWbT21Qsub?= =?us-ascii?Q?o+FeozyKIRj9V5vxFCFsk4V9g9O7ff2z?= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 19:47:43.7566 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1b884fb-2178-40ad-96f1-08dcc79a48b0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A672E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9103 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240828_124756_960036_B29C11C3 X-CRM114-Status: GOOD ( 26.14 ) 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 Wed, Aug 28, 2024 at 03:30:37PM -0300, Jason Gunthorpe wrote: > On Tue, Aug 27, 2024 at 12:48:13PM -0700, Nicolin Chen wrote: > > Hi Jason, > > > > On Tue, Aug 27, 2024 at 12:51:32PM -0300, Jason Gunthorpe wrote: > > > diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c > > > index f5d9fd1f45bf49..9b3658aae21005 100644 > > > --- a/drivers/iommu/io-pgtable-arm.c > > > +++ b/drivers/iommu/io-pgtable-arm.c > > > @@ -106,6 +106,18 @@ > > > #define ARM_LPAE_PTE_HAP_FAULT (((arm_lpae_iopte)0) << 6) > > > #define ARM_LPAE_PTE_HAP_READ (((arm_lpae_iopte)1) << 6) > > > #define ARM_LPAE_PTE_HAP_WRITE (((arm_lpae_iopte)2) << 6) > > > +/* > > > + * For !FWB these code to: > > > + * 1111 = Normal outer write back cachable / Inner Write Back Cachable > > > + * Permit S1 to override > > > + * 0101 = Normal Non-cachable / Inner Non-cachable > > > + * 0001 = Device / Device-nGnRE > > > + * For S2FWB these code: > > > + * 0110 Force Normal Write Back > > > + * 0101 Normal* is forced Normal-NC, Device unchanged > > > + * 0001 Force Device-nGnRE > > > + */ > > > +#define ARM_LPAE_PTE_MEMATTR_FWB_WB (((arm_lpae_iopte)0x6) << 2) > > > > The other part looks good. Yet, would you mind sharing the location > > that defines this 0x6 explicitly? > > I'm looking at an older one ARM DDI 0487F.c > > D5.5.5 Stage 2 memory region type and Cacheability attributes when FEAT_S2FWB is implemented > > The text talks about the bits in the PTE, not relative to the MEMATTR > field, so 6 << 2 encodes to: > > 543210 > 011000 > > Then see table D5-40 Effect of bit[4] == 1 on Cacheability and Memory Type) > > Bit[5] = 0 = is RES0. > Bit[4] = 1 = determines the interpretation of bits [3:2]. > Bits[3:2] == 10 == Normal Write-Back > > Here Bit means 'bit of the PTE' because the MemAttr does not have 5 > bits. > > > Where it has the followings in D8.6.6: > > "For stage 2 translations, if FEAT_MTE_PERM is not implemented, then > > FEAT_S2FWB has all of the following effects on the MemAttr[3:2] bits: > > - MemAttr[3] is RES0. > > - The value of MemAttr[2] determines the interpretation of the > > MemAttr[1:0] bits. > > And here the text switches from talking about the PTE bits to the > Field bits. MemAttr[3] == PTE[5], and the above text matches D5.5 > > The use of numbering schemes relative to the start of the field and > also relative to the PTE is tricky. I download the version F.c, and the chapter looks cleaner than the one in K.a. I guess the FEAT_MTE_PERM complicates that... I double checked the K.a doc, and found a piece of pseudocode that seems to confirm 0b0110 (0x6) is the correct value: MemoryAttributes AArch64.S2ApplyFWBMemAttrs(MemoryAttributes s1_memattrs, S2TTWParams walkparams, bits(N) descriptor) MemoryAttributes memattrs; s2_attr = descriptor<5:2>; s2_sh = if walkparams.ds == '1' then walkparams.sh else descriptor<9:8>; s2_fnxs = descriptor<11>; if s2_attr<2> == '0' then // S2 Device, S1 any s2_device = DecodeDevice(s2_attr<1:0>); memattrs.memtype = MemType_Device; if s1_memattrs.memtype == MemType_Device then memattrs.device = S2CombineS1Device(s1_memattrs.device, s2_device); else memattrs.device = s2_device; memattrs.xs = s1_memattrs.xs; elsif s2_attr<1:0> == '11' then // S2 attr = S1 attr memattrs = s1_memattrs; elsif s2_attr<1:0> == '10' then // Force writeback Thanks Nicolin