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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 D01FBCD98F9 for ; Thu, 18 Jun 2026 04:45:39 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4ggp7k2bxqz2yNn; Thu, 18 Jun 2026 14:45:38 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=pass smtp.remote-ip="2a01:111:f403:c111::9" arc.chain=microsoft.com ARC-Seal: i=2; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1781757938; cv=pass; b=HOmawIAZdXq3t/f0ICWUIZncePM3iWl6vigetZU3ZfBzmsefiXWTLIPw4X0LRJa3DKmSyqLZ8BrdaYgTjmeh7jCDngo4vLbxpxq5aZ7GAShmFkbrkCrbGt0grQZVKreXyHIXKKYOKYxR9ayXyq4hldBqRqL9RcyPK1CHWMc0K6CVr2nQEMCO7mv4cScsSRO4zgVqRnY45ea9JvuPx6aQOren5gTuCtqspyIYtoAHE3mSfaeXDxO7ERDAtgQeSoc+jxcJ8nQE9seb5p56RXM7i4vDPFLO/P6aacYi5fFacDHahCqt3/vXwuy8d02sR+2cjsDrVJwtFiUO95XHPOkQ6Q== ARC-Message-Signature: i=2; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1781757938; c=relaxed/relaxed; bh=7335j7KHV3WiqitjlGpo/Mer3Lc36auTU7z9836cfhw=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=SKdzAWQuvlsO2xCa9TdzXBMRyNFrplvu7oMOktwNZojiVrwh+i5XH0tB8l2iyWXgvkSb+HLOEiPysiiH/WvoVnUpEXin0Uy2KuFGL8tnSsTlc44PG0892+2h91+qWq7PUL/NqS+dElYYJzepZ80qCqc6WliXp/A/uSIDhj3zzE1co54rAJjgeeR14NhKTGdLbUGxcUzxkC+1nkPms3ehQqqor5Ke/VfYZGsR/R8JeSd/RkNUklwHXYRmOeEDn9zXyhz5qypooty7WWvtbSdXV3J0M/0YFwiwQSsMBElewS0UCUQ940tDCeWxZsSzNTjPxFfh+5Qi7u1NAYtCoOu66g== ARC-Authentication-Results: i=2; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Tn2L8ICK; dkim-atps=neutral; spf=pass (client-ip=2a01:111:f403:c111::9; helo=dm5pr21cu001.outbound.protection.outlook.com; envelope-from=alexey.kardashevskiy@amd.com; receiver=lists.ozlabs.org) smtp.mailfrom=amd.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Tn2L8ICK; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=amd.com (client-ip=2a01:111:f403:c111::9; helo=dm5pr21cu001.outbound.protection.outlook.com; envelope-from=alexey.kardashevskiy@amd.com; receiver=lists.ozlabs.org) Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazlp170110009.outbound.protection.outlook.com [IPv6:2a01:111:f403:c111::9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4ggp7h1kmGz2xLm for ; Thu, 18 Jun 2026 14:45:35 +1000 (AEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GQuwm+fIlOZ1YCjC2T0UPeQ4/p1m4f+L10fKU5CvI5AaMwawSN6or4OhjMj/Bl0o+EgvesBCDBaDiPU0pipghl7sfstjSnPnt7S23hPa8V3b9rcwh05gTsWzDRWu2CmD4W51N3kguKUdWD4tweebrqGVgfEETpN5SiFQDKQhs+IzLe6udzUWyCyxXYAm9uDKRJZSUQiykDX5CUejnNU1XHINdk+hgtkWQ7x/UbICjntKttqbH1dyCbLiS3qW+yKeEp/kyrXvbrddzKX0ElP014oVVKx2cx19MH+2tyE5M1J6NpLeip+2ozh+eGRWmr8fQhL+b+5jJMLvmOkjK8Sfgg== 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=7335j7KHV3WiqitjlGpo/Mer3Lc36auTU7z9836cfhw=; b=iWUeaVinU9SYe/aP7Dpb6GIr/Fq11oKzJz0fXlpjoqgGXlCqlB++XtWfhZnemjjit9aTdgB18HY812wAUBwnAjlI+4lF9eYxWZHuiZ0b9ro5hlK3aBnHlnsxT+b5ipXRTqKR1uC/wEBt5b7QO4rl5wRJ3LjwVFo6pnd+fVwvmQzGduqJ+L7VI+GtBuvTPTHeJLTzQALJCHRtaDYEa/9AwcGmqq+yauJ0nBB6RbE2sZFOaY0f+ODMeF3o+e1VKv6AjZV5pFVVnX9dMkiEvekZbnObuw1sW2o31LUu9jSVdJ8IfLFn3juNc1lSZfos6kxMCbLBukTlBVQs6l1elY0dVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7335j7KHV3WiqitjlGpo/Mer3Lc36auTU7z9836cfhw=; b=Tn2L8ICKDuDhKRjj7RosC/EfC0j4y0hKfIn2iSmeWNiiYKFmnWZiZFZVGkPFwAo+NedmpbJhAvgOyzL581hHxF2Ym9o3fURgxwczqp1hvgK07Htud3DqXFeD2i4DAPqA+YRTobfFzRZ6yHmwPxO8qbSLf/fsOiaupwn+9h0ZDtk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from SA1PR12MB999228.namprd12.prod.outlook.com (2603:10b6:806:4db::10) by CY5PR12MB6347.namprd12.prod.outlook.com (2603:10b6:930:20::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.14; Thu, 18 Jun 2026 04:45:05 +0000 Received: from SA1PR12MB999228.namprd12.prod.outlook.com ([fe80::4dba:119e:8e7c:37b3]) by SA1PR12MB999228.namprd12.prod.outlook.com ([fe80::4dba:119e:8e7c:37b3%4]) with mapi id 15.21.0113.015; Thu, 18 Jun 2026 04:45:05 +0000 Message-ID: <2ecfa1a8-6202-4319-9692-a6ffeb5a3dbf@amd.com> Date: Thu, 18 Jun 2026 14:44:56 +1000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 00/20] dma-mapping: Use DMA_ATTR_CC_SHARED through direct, pool and swiotlb paths To: Jason Gunthorpe , Catalin Marinas Cc: "Aneesh Kumar K.V (Arm)" , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, Robin Murphy , Marek Szyprowski , Will Deacon , Marc Zyngier , Steven Price , Suzuki K Poulose , Jiri Pirko , Mostafa Saleh , Petr Tesarik , Dan Williams , Xu Yilun , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , x86@kernel.org References: <20260604083959.1265923-1-aneesh.kumar@kernel.org> <20260609144746.GL2764304@ziepe.ca> Content-Language: en-US From: Alexey Kardashevskiy In-Reply-To: <20260609144746.GL2764304@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SY6PR01CA0084.ausprd01.prod.outlook.com (2603:10c6:10:110::17) To SA1PR12MB999228.namprd12.prod.outlook.com (2603:10b6:806:4db::10) X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR12MB999228:EE_|CY5PR12MB6347:EE_ X-MS-Office365-Filtering-Correlation-Id: b79d3294-2263-4ddc-d59c-08deccf45da7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|23010399003|56012099006|6133799003|4143699003|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: tqsiRuttotqwkOwQtSi2UNS0cTqdSo6zBZzUYfUnZampfmReHessoEkIJ/0RbAN64Ax8m/3YZYUfFsATZEyscht92WZJZwm3F5uFCSg7khSJ+/5qU3hhhL22vSVgkOkt1iDTwnn6fBfGfNccrq3RGjxJnD1k7KW0QPBS1bdf7i2ldG2JdgVdNZUL3ZGH0abPgJ7H4wvFWkNCkzeVSp85yaHoTfG0GS7nqf6YDmQ+ipoOC6bObPJLYFeNN/BeBbqhQlzPq7guUdm6R0z1kaMSvhM/NSnQLpftyipLIbPI48aGhJyudnskz5qp4UeIWeHvq+pwrIcznvBxDKIbKP0yuPSpGoLr2WA171bJT/MgKp1NuCehGpyPodzUM/xudyG4gYZwgGycf99+8QlYFWYV9mtR0mbydjwqFZ2KQGEGLzdrNZ17fkrbQvJtXe+NzcfmuUWrCwMM6XICemberQ7v3P/L0tHtIfI6JLwtrcEWDE99FbAvnMLamzkFMElOzMX1qdmm06o+MFjWetZwcaPigh8t31l6mLVhr+NezXq0cVNyQ5R88V3Zoc98mjOZPv6zsvoqRv9s//hLrOcmZJk478s5f0I/+ERtT7o3lZR5E7Gmf0TO1+L2fmES0YKGFaVh/g1pLcTgfh00q/NDIRLAzA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR12MB999228.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024)(23010399003)(56012099006)(6133799003)(4143699003)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YnZyeklJVjgwWmxseFloTVM0OTZWV1hOTlRPRWgrclJvY0FjT0RZNnBvSzlo?= =?utf-8?B?cjd5eS9XK0tsRVhKMWJKM2lZeVlJbmFIMTEvd0VUaUgvdTJZZDFWQXlXOXZI?= =?utf-8?B?N2NwaGVqcDZyRHFPTTlHOXBEcE5vbWtIcDlzWjhBcEdOMk02UW1LN2xTVlJN?= =?utf-8?B?eWxGeGFrYkpvd253Y0ZRYWdIQm9QcVBOSGR0RCtuL3ZRb0xQTDZqQ0Z3VUFw?= =?utf-8?B?TnVtM0VVeEZRV2tJWCtjQVNZalhkMEdaRjByS3lBQXNocU91eEhKMTNkdWpV?= =?utf-8?B?WUo5d0p6UEhzcWEvcUM2VlMvSjAxamM5cTBrc2k1SVpPNDlWQzBJckJyWUZi?= =?utf-8?B?Vm00WXhIL2s2aTE3TzQwNzhlWWZ2SXhXWTQrNnlaSlcxR2NFd2kxWmlkR2hM?= =?utf-8?B?RXYwekVTclV5ZUNOWFNGcn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HVEtKcHM5Vldo?= =?utf-8?B?RExsS1ZTYU02Y2Q2aEdJbEhQc1Q0YUVMNVczaEhMYlZpeFloQnF3RjlYZkxR?= =?utf-8?Q?4ljBzlj+FbgZ5aqaLd?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b79d3294-2263-4ddc-d59c-08deccf45da7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR12MB999228.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2026 04:45:05.0752 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KSmzSkjGmpJwDZBn/XOkry3NFyDaEQdGcWt7J6581k1bro8ib9fW/E5LlT5lmDwn2MZEe/3O3z5Jyp+YCxPkCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6347 On 10/6/26 00:47, Jason Gunthorpe wrote: > On Tue, Jun 09, 2026 at 02:43:08PM +0100, Catalin Marinas wrote: >> On Thu, Jun 04, 2026 at 02:09:39PM +0530, Aneesh Kumar K.V (Arm) wrote: >>> This series propagates DMA_ATTR_CC_SHARED through the dma-direct, >>> dma-pool, and swiotlb paths so that encrypted and decrypted DMA buffers >>> are handled consistently. >>> >>> Today, the direct DMA path mostly relies on force_dma_unencrypted() for >>> shared/decrypted buffer handling. This series consolidates the >>> force_dma_unencrypted() checks in the top-level functions and ensures >>> that the remaining DMA interfaces use DMA attributes to make the correct >>> decisions. >> >> Please check Sashiko's reports, it has some good points: >> >> https://sashiko.dev/#/patchset/20260604083959.1265923-1-aneesh.kumar@kernel.org >> >> I think the main one is the swiotlb_tbl_map_single() changes which break >> AMD SME host support. There cc_platform_has(CC_ATTR_MEM_ENCRYPT) is true >> but force_dma_unencrypted() is false. Normally you'd not end up on this >> path but you can have swiotlb=force. > > IMHO that's an AMD issue, not with the design of this series.. > > The series is right, a device that is !force_dma_decrypted() must be > considerd to be a trusted device and we must never place any DMA > mappings for a trusted device into shared memory. swiotlb=force forces swiotlb, not decryption. > That AMD has done somethine insane: > > bool force_dma_unencrypted(struct device *dev) > { > /* > * For SEV, all DMA must be to unencrypted addresses. > */ > if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) > return true; > > /* > * For SME, all DMA must be to unencrypted addresses if the > * device does not support DMA to addresses that include the > * encryption mask. > */ > if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) { > u64 dma_enc_mask = DMA_BIT_MASK(__ffs64(sme_me_mask)); > u64 dma_dev_mask = min_not_zero(dev->coherent_dma_mask, > dev->bus_dma_limit); > > if (dma_dev_mask <= dma_enc_mask) > return true; > } So when I try "mem_encrypt=on iommu=pt swiotlb=force" with this patchset, it fails to boot. But it boots with a hack like this: === @@ -39,7 +41,7 @@ bool force_dma_unencrypted(struct device *dev) return true; } - return false; + return swiotlb_force_bounce; } === Or we say "mem_encrypt=on iommu=pt swiotlb=force" combo is just weird and we won't be supporting which bit in this? Thanks, > > Is an AMD issue. We already have an address mask limit system built > into the DMA API, arch code should not be co-opting the CC mechanism > to create a special pool for address limited devices. > > The correct thing is to ensure the DMA API is checking any address > limits on the actual true dma_addr_t, not on an intermediate like a > phys_addr before it is adjusted with any C bit. Then it is a normal > low address swiotlb bounce like any other. > > I think we can ignore this Sashiko remark, in real systems the use of > swiotlb for 64 bit devices is very rare. Though it would be good to > remove this code from AMD...> > Jason -- Alexey