From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.201.25 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796279645; b=gE/5xCLrl/AHyuvtzSvP6148TqquT8CIlXTWbHNc7MJQ8LFdUGpX4HlayBRnBJ6DCy95 Dx2+ErPKQy7blVxBEUPwZrYFTbTxfagr6F2mxAcC4xUIKS5KV0nHPExrwlw5eC/Xc2u+z c8U45cml7HgawBKy4JzUDCZroWLkzWfmzFJ8EGf6lmnJmdDRe23L6sbUFvErzH/n2Iq8p q2pMvttbtKK4pFizK33nt9+BBs79dWnICJycxPuvp/UExlU6yyDz1S42Qj6V8i89LIuw2 gUq1wHn+Hh3GS3K7qxa7MujjvyQPK67Jma+Obal2ib/ksT7yKyB5kmUQa9gJGwAjTdw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796279645; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:Content-Type:Content-Disposition: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=keRK7+KZfIW8xPc35KM2WWFMpQ/BSzj/IaSmIrIb50c=; b=5Im/Op8yQHyv9O4wFj0oHxEBH2oPtI0rRRilnjv1sciMowAZXB2XUlQXSeBhip1x/14+ W13B4DieNCfrb3jmLx7v0vzf65SyXknzM79k70N5Eg6/vLKJiutiSpHpUbFUNUdWm1yg7 W3kKznRBGgivaozSCm0oWk1AahRHghH9Owf6RiCE7OrHUHND20FqjfVc9IcDjNBzRLy07 XUpVkqBsu1Cn95MpS5isk0/8Q8bxHwquZKn64bbdeqWe1t9Bdgg0U+saogZ3IhVSfI8TB F22jVCtZuPfvtEjU8YiA6bdaXnaMBzJeh50zKoAS2vlwZ4yovpRi27DHjpKrKcR2efQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=QZzAndUr; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.201.25 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013025.outbound.protection.outlook.com [40.93.201.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 472EC606A32C; Thu, 3 Dec 2026 06:34:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 472EC606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=QZzAndUr ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C0hOw8TVFMJL0fIectVoLKwYM7bYqS5GjMC7QrXppltTXKrLJnwHgDCEP9dpLIgL654RCaDMUyNEM/moZBtkmKlq9Uqh6LyzYt6Ho7MbvlL/4h0arPf8dZFWOkCrHD3g0myl8dXh3ZKyW8J0+/tdeEM4UICr0AKcPwBNmZb3TXH8y4q5LIIvh7FCaldDWp55vabV/rt2IsCQleRLkuk+wlbxjtx+71d+hsbRE9VRIHuwmTKicD4Dt1m3OHKbTRlmSV+MWLPWM4RV0IgT7nhlCgDoN2gohQPSxybby/WKBqcb+6OiaPRurnc376x9f1nM+JyYH0SFUHfSX/RWyWAtGw== 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=keRK7+KZfIW8xPc35KM2WWFMpQ/BSzj/IaSmIrIb50c=; b=IriGqDFT/qeIGKCY9PwCSYMS0dZmxLqpnL0kFCp9c09A4+/DInvSJOGKDkMRn0sMiRvANkFeixO4RFmwMboAjkH+hw9/8PALtG54rxSrBFv8A4im8TFx4TRmjqTzow5nrQrJSrJQ7eA1+o6wH1ZpwH+ZPvaJvw2dKhO/FT1zOwEE+Pl6imED7dw7+Cf13HhNgli8Yn3k+2wJ7IzMppML4QsIpRGVbVztRdjITM8y3CZlduMuwJWBGEJF1WIHfNXCbb3U7AoUFI/2vdw2VU7DnwmrzZ0wB2KmzLX8yPqqWMLYFQcdL72/yrgE1RMwUcQvQpaWDaUq9fFz/X0NFUxodw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none 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=keRK7+KZfIW8xPc35KM2WWFMpQ/BSzj/IaSmIrIb50c=; b=QZzAndUrcU5s/fQgSy27M7mxIILMHtlCjG4cpX7A5PSK8pXTrrJaP5a0helttuo6bxXR/w/mE8lVI7gv/mwGCninb3BaQ0Pvnlpvuhhi+I/sIsgQ/pongYnmqEn/OtedyowiXOkd4e0njPapYj9X52zUmLL9IBDThSsumWf8ZfF0PqlVGEQ/r++ao2DCn/ltCU0H1Hf9dp2l1QAA0NQEv7UAcUHvuhM6XWUdG1J2GI6SR3qTrZ2ZhgBbkykS4RRUBFa/sF9YB825djz+q1kDTuNvhCThegQCk7XU3J7DzzKVNNzM4QKhXWZ0WA7zXCXwCIffXBDQmEmGktl9of2wOw== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SA3PR12MB598757.namprd12.prod.outlook.com (2603:10b6:806:52d::14) by CY5PR12MB6178.namprd12.prod.outlook.com (2603:10b6:930:25::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Thu, 3 Dec 2026 06:33:59 +0000 Received: from SA3PR12MB598757.namprd12.prod.outlook.com ([fe80::e206:100:5946:a777]) by SA3PR12MB598757.namprd12.prod.outlook.com ([fe80::e206:100:5946:a777%5]) with mapi id 15.21.0688.010; Thu, 3 Dec 2026 06:33:59 +0000 Date: Thu, 3 Dec 2026 17:33:54 +1100 From: Alistair Popple To: Dave Airlie Cc: Jason Gunthorpe , Christian =?utf-8?B?S8O2bmln?= , Sumit Semwal , Thomas =?utf-8?Q?Hellstr=C3=B6m?= , Simona Vetter , Matthew Brost , Vivek Kasireddy , Dongwon Kim , Kevin Tian , Xu Yilun , Karl Mehltretter , Baolu Lu , Felix Kuehling , Alex Deucher , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Mina Almasry , netdev@vger.kernel.org, Alexey Kardashevskiy , zhipingz@meta.com, treding@nvidia.com, jhubbard@nvidia.com, chaitanyak@nvidia.com, Leon Romanovsky Subject: Re: [PATCH v3 03/24] dma-buf: Add the SGT DMA mapping type Message-ID: References: <20f5fb10-b71a-40f9-bbb2-f99b4002bf08@amd.com> <53a32383-4cf6-42ac-bbd5-476e69a3be5f@amd.com> <20261202013043.GC351887@ziepe.ca> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SY6PR01CA0096.ausprd01.prod.outlook.com (2603:10c6:10:111::11) To SA3PR12MB598757.namprd12.prod.outlook.com (2603:10b6:806:52d::14) X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA3PR12MB598757:EE_|CY5PR12MB6178:EE_ X-MS-Office365-Filtering-Correlation-Id: fb1c69c4-7871-4536-8204-08df510769ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|366016|7416014|376014|1800799024|4143699003|6133799003|20046099003|18096099006|22082099003|18002099003|261026130827099003|10067099003|11063799006|56012099006|261102130727099003|261102123227099003|261026140227099003|261026121527099003|261028144727099003|261022105027099003|261021135927099003|261022075727099003|261021123027099003|261022115727099003|261021130227099003|261022113327099003|261021121427099003; X-Microsoft-Antispam-Message-Info: dheQK7yLULNkShgu1oSja4x0soNB3F2M269ZF0zrAztc3He2LcgMGpT/XIQ35bzgLx+pS0HDium8tl3rjjqJU8nYufhqNV3Co+BehLviR9rA1N83zXXPE644+pBtRifMJax75edIh+p4kCNYJ2ysQy4JmqogTEw+cdU2fBuBgc75RLq/aJ7hQxXyNRMhkp0xFM6Wh3zLjncKqT/X46iVwq6dQgr2P3c7btcPsz9+3CcJNHtq0cQ+BpA0IFXCcmFCLOYyxR3pHH1+XmS6AbIbkUUQXISo7tdnwi4ydLmXv1oeN6qHWt9F0AChgf0vtXplXv21GB+QFDgI2rkqg7cL8BhJ6Q+jO5QzUzAhknfSZ+Kqw4K+5IyAaZH3mn2JTUHPbLZacm0qEq6jGcXBDZjlos3WLTfcUCxIXygC+iU4gJwBxTwNIoyVvbBQoQV7S/Ig8HgFjgtpy2s0h8vaNhk9YYNaYfzEsOIRzs4z3sGL0cWCOlyqcQJRBCu09PVXHrDXepfPU8q+vHAiBl0e2FS7vteA0igiekUbCvryGl2O33n4KhLtvxpvpLm+jy1HFzCg22voWmmoKRifgxo65laY519kz5q9wu9AGdLiskohJwAi43rcuyLWYwlRhsTlciOtDADg5oejCMcfd6nBhdWB05Prp1IgNq7X/PXExuMYY8E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA3PR12MB598757.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(366016)(7416014)(376014)(1800799024)(4143699003)(6133799003)(20046099003)(18096099006)(22082099003)(18002099003)(261026130827099003)(10067099003)(11063799006)(56012099006)(261102130727099003)(261102123227099003)(261026140227099003)(261026121527099003)(261028144727099003)(261022105027099003)(261021135927099003)(261022075727099003)(261021123027099003)(261022115727099003)(261021130227099003)(261022113327099003)(261021121427099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iNKZ5285mWohBWgC+t/4Vle/HH5Suf9vnPdjrSOWyCVDBhhTlB4Zi5WPjY1k?= =?us-ascii?Q?UO92UoAoVqEU8H2IO5fjuUs1b4pu0Cm/rZnLZN7jZga6y7o0KG50Z18oNXLv?= =?us-ascii?Q?2/XK+ue6B2NQeIF8l0qL+T152lpXdUUstj2S8GO1EFrMpFh+I6TzMNIM7p8+?= =?us-ascii?Q?rJ4v7r4mYLkO7Fvo2bNrSIHTmf4akaCcioJXSNp1T2ULJpm4g9Kmp9BV+O0X?= =?us-ascii?Q?U4CrZXw2EJGqgYSuHFFxocidSdUkRmdKc5FJxEukEdGc7hBAwxhEMyC0UCId?= =?us-ascii?Q?BL0UuaLo5i7TJDfKtb76xG0xUgbfJjhZ5KGSYYC1vmRrq08XhVYMvSq/2e3R?= =?us-ascii?Q?EC+OL9N+8475M2MDDZwS7dHIb1Nzqc7bjbqK9LZ/xEC4YaIUplElIg0/e4WJ?= =?us-ascii?Q?vlz/a0b2smles2HZ1Njt27Bq8kHLwsM0R6qOIhyGRwDt2t1a2y/OC3j8ty1A?= =?us-ascii?Q?hLtGrh5EjrUExnH7g8tX/jWYA1bP13XsuwnxfulpdEALyrgQtms/5I5kAdLu?= =?us-ascii?Q?mF7AYPCKg/5sCPPgpVriv99Hbx9KnDcD6vLM2VO2z5kMs0UdYMWUAswmav0J?= =?us-ascii?Q?dM/HL0QpdOnnX/NlrOhCgbhhnOnSXU2VWYsoRQL8OAZR67J2MhNAqQwJ3njT?= =?us-ascii?Q?E9ChiPzui36//bVCPls9dQ/BhFZKBQ1o6u1hqJuGhIoTHDDm7UHJg1h5sGkl?= =?us-ascii?Q?X7/edmZ8k6JwngikB7kq2Gy7SD4J6kcfPKl5UvFuVgI0Ae0DfcmYcEjqiBsk?= =?us-ascii?Q?X4LYlrEL7jWn4dwqXPXT2jdpSDDkSTVJ1pyEAxRD9PZznBYyvJZTgG128HGh?= =?us-ascii?Q?LtF7IyxKIN2aF1X1+xkz8IEDuS1ke85qQGbJIkXKihDYteM4NbMNrKe2HMxB?= =?us-ascii?Q?cINk5zCEP0LfF7E8Z8wBmw1yFulP5ZqkO91GcsVosbfoAYS1UIRI33c7aJh6?= =?us-ascii?Q?r9fIIhGUe5I/iXa/BET6yVpW+19KjH4tospk35+G8f0xzUDitRFjHOAdYATq?= =?us-ascii?Q?igK20k531lB2+SOLhXnH1PK+8LTKqXnVMsSHvfmePPvbtbcuHmvqfM2HUmaq?= =?us-ascii?Q?+guVICd5Qq/uNS3eaAZfwdTQYsKUZu61N4swzaUJDER2qjVxYMIt4UvrpTzl?= =?us-ascii?Q?Gv9apwxQjI1E0cfYwkg14KWJEuKlmENPS6hglLyxgBJ724Aw2bx4xO9uUyPD?= =?us-ascii?Q?QPWNbMaABR06HMEirzmCL6EY/rKt97CWg57QdOMVbuwfGlu8/LUTPQJ/BmrQ?= =?us-ascii?Q?NfZoove6MwaFi/q3Pn5QEJYxSeAOqK0p77rHGcqdBeqv4EMRvnXyAbMsY2Db?= =?us-ascii?Q?lLR/kKiCfOA9OCdRFumL+F8CJ78tpZA9U55iGXYyEtb1tO26MuKfvj43IZcG?= =?us-ascii?Q?gBM4IrXHl1d2OhWOnSIL0a0HfJ1vRG9tc22P5v8XkYKvA11YRsEVxBnqst23?= =?us-ascii?Q?PrPuLGhnbBJW29azglAp3xllCAhrUAg4Re/ACWHY8c+NHEUcqIlKCGUxM5xe?= =?us-ascii?Q?wge11jrfuyJoWFq5dW3jlHUjFs+r/zZZD/c5HUYmTqxdjhk3XZS7A5ztAu2s?= =?us-ascii?Q?TAuhdb9loto9XvsQTtlYM6n17HGHYukQXWzl5eTD8s1bN50uYHV3VEfwHgWa?= =?us-ascii?Q?iw88GzMFJz8qz6tDPIqJRQ1uj59lqa9AYth1jrZLmjnQyTU0Vd188R/MjrZC?= =?us-ascii?Q?MMBcd8wn4zktxQM08c2age5yv65N2ZRTItMWtQclA7fOl+whnxWeGBOuqV4l?= =?us-ascii?Q?3dcVAa2CdQ=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb1c69c4-7871-4536-8204-08df510769ef X-MS-Exchange-CrossTenant-AuthSource: SA3PR12MB598757.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 06:33:59.6469 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7vVPoNh5oBJPKH3jlvRj52RCTaIqsuuXo54jbm4qXfkqo9FqD8sayCmLmLHCOsRszxvyrLR4h3AkvrRNHpdO3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6178 On 2026-12-03 at 14:44 +1100, Dave Airlie wrote... > On Wed, 2 Dec 2026 at 13:54, Alistair Popple wrote: > > > > On 2026-12-02 at 12:41 +1100, Dave Airlie wrote... > > > On Wed, 2 Dec 2026 at 11:30, Jason Gunthorpe wrote: > > > > > > > > On Wed, Dec 02, 2026 at 10:47:28AM +1000, Dave Airlie wrote: > > > > > > > > > I think this is clearly where the divide is. I'm with Christian here, > > > > > the exporter allocate the resource, then it owns the lifetime of the > > > > > resource. In order for it to have complete ownership of the lifetime > > > > > of the resource it needs the ability to remove the resource from other > > > > > users (i.e. importers). If the exporter wasn't to free some pages, it > > > > > should have all the information necessary to do so but traversing a > > > > > list of places the object has been imported and a method to forcible > > > > > unlink it from that side. > > > > > > > > If you change iommu mappings without telling the driver you will > > > > create data corruption as new mappings can fall to places the device > > > > is still doing DMA. > > > > > > > > The driver MUST be involved in any reclaim/move/revoke process and > > > > DMABUF already has APIs for that. Managing this lifetime is one of the > > > > main things it does. > > > > > > > > I don't like this notion we can trust one side more than the other, it > > > > isn't like the exporter drivers are amazing clean things either. There > > > > is a reasonable level of nannying.. > > > > > > This isn't just about trust, it's about lifetime and ownership. If the > > > exporter owns the resource, the exporter should have all necessary > > > information to invalidate the resource and give it back to the system. > > > > It does - that is what the reclaim/move/revoke callbacks are for - to tell the > > importer to stop using the resource and invalidate any mappings it holds to the > > resource because it's about to give it back to the system. > > > > That necessarily has to live in the importer. Take for example PCIe P2P - there > > might not be any IOMMU involved, so the only way to tear down the mapping is to > > program some importing devices specific MMU (or stop work or whatever importer > > specific thing needs doing). > > > > > > Importers are expected to unmap. I think we have to consider any one > > > > that doesn't to be broken. You can't fix broken with more broken > > > > things like force DMA unmapping and hoping that there is an iommu, > > > > then hoping no corruption happens to crash the system. > > > > > > But we should allow the exporter to tell the imported to invalidate, > > > wait for a response and then have the exporter free it. What the > > > importer does in the invalidate is up to it, but the exporter controls > > > the resource lifetime and any things bound to it. If the importer > > > fails to invalidate the resource then that is a clear problem. But an > > > exporter can at least control all the mappings for the resource and > > > tear them down without leaking things. > > > > I think we may be conflating two things here - the importer contract and a > > method of enforcing it. > > Actually I'd forgotten one more point, we are just talking about the > closing down end of the bargain. > > We also don't want to trust importers at the setup phase, giving > importers the physical addresses had led to problems in the past, > hence we why make sure we remap the pages through their struct device > before giving them the dma_addr_t pages back, it means the importer > can't just go remapping the physical addresses and bypass any iommu > etc. I think there are two main points of contention we need to resolve: 1) What owns the life-time of a DMA mapping - importing device or exporting device. 2) What data should be exposed to the importer. Though if there is no iommu or it's PCIe P2P how can we avoid exposing the physical addresses to the importer? I don't really think we should be designing an API around a constraint that needs to be violated to make things work. > In the past these have been buggy importers but they have happened, > they weren't caught in review, who even is on the hook to review a > dma-buf importer in another subsystem, like I get Jason isn't going to > write a bad importer on purpose, but the number of groups that can > write a good importer on purpose is small, it's more likely we get a > bad importer by accident. The resource belongs to the exporter, bugs > stop at it and anything we can do to make importers not open-code a > phys->ANYTHING else is worth doing, because it's clearly been broken > before so we are just opening up bugs that we spend years squishing. > > We don't worry about bad exporters because bad exporters will get the > bug reports for bad exports since the pages were allocated by it. Except they won't, if say they don't do the mapping correctly or teardown the mapping unexpectedly. Then the importer gets the bug report, because that's the thing that will crash the system or corrupt data if the exporter gets it wrong. The problems are symmetrical, and I think what you're really saying is exporters are more trusted than importers. But I agree with Jason - I don't think in a monolithic kernel it makes much sense to say one type of module is more trusted than another. I have seen plenty of bugs on both sides... > In that sense I do get the "Switzerland" idea. But I still think we > should lean into the exporter controlling what imports receive. But then the exporters have to recieve a bunch of importer private context, which Jason has NACK'ed for much the same reason. i.e. he doesn't want exporters screwing with things they shouldn't. My hope was we could define a helper that an importer would call to create a mapping that would act as "Switzerland". That helper would take importer specific context (eg. device, IOMMU domain, whatever) and call the exporter to obtain the list of physical addresses which it maps. This keeps both importer and exporter context isolated from each other. > Like we have a flow of > Exporter - advertises a shared-buf available as dma pages or iommufd or whatever > Importer asks for the buf under one of those categories, hands the > metadata to the exporter (could be completely opaque), exporter hands > all the info to the swiss border patrol, it returns the necessary info > for the importer and it gets sent back. I do think that's possible but it seems a bit odd to me because all exporters can advertise support for everything - dma pages or iommufd or PCIe P2P (depending on location, which is separate discussion) - all they need to provide to "Switzerland" is a physical location/address and "Switzerland" can figure out what it's available as. But I guess if the exporter absolutely must control the mapping without an importer going via "Switzerland" itself then we could pass some opaque struct into the exporter and create some API the exporter calls which knows how to decode what type the opaque importer struct is and map the physical address into it. > I can see this working for the common cross-device ones, but I'm not > really sure what to do about transport specific things like ualink or > protected VRAM. Since who would write/control the swiss piece of the > library in those cases? That might come back to what Christian was suggesting earlier - separate those cases out and for them dma-buf for ualink/nvlink/XGMI is really just a way to hand some opaque data back to the importer. - Alistair > Dave.