From patchwork Tue Feb 4 18:34:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13959790 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 A9088C02193 for ; Tue, 4 Feb 2025 20:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3GTPLak2TZx5f4D3Hf1Bthq2Af11RRFvh3yStKUu2Kg=; b=LPnZt4nGvdQtsy ny+lvU7rALrd+ROShrpSazcoic7mSX+kvusXCuCEZUuiDRG3ms3H/0IQ0yPnv3/YO8DrmUtJlcBtH 2xgC8oB8myAg4oqi708X8Z3gIJes10Zo8lUJSCmpsvRy5LUFeRz6H3N74FQTf9Vj+gpFVP1wMjsYe wGXrLkZRASyhXxLoUXJ8/agpRYOGDpS/1QqAFGfsJhE6q/Fa++d9zPbYVwGXGkQvVBv3KSJ/IytAK 6qZNdgda83jhnkvRhh+B4zMZxToQdw8TChmI51pVjMiGKr6MBbr2katl4/oJXbyt2HXkhjYyX2Ukf DAmXJuaRonGjtOdpjBJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tfP6g-00000001Smc-2WTt; Tue, 04 Feb 2025 20:01:14 +0000 Received: from mail-bn1nam02on2060c.outbound.protection.outlook.com ([2a01:111:f403:2407::60c] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tfNlX-00000001EIa-1C7i; Tue, 04 Feb 2025 18:35:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Nn+jePi8T1HDxzmqtBWhdd1id/UwcV2sE2hL/05bHAk7zQmkxz4Q9GRAjX7fGkSWlo53OwHGhYZGdqBw4Fx8peTc9wp4GlGKR8iG++SqzyFwa1bgrfkX8ew6qyJ/5rFPQ52UJLGF2u+GxvpmuFQwf3W9HAup4iB1sqOH2s5o/JnLAsqtjG1nxmUCL4uNDyEPHMSG6CV9Bg2uf5YGajweCqedlhVWGCG4Vl+HmrxQ1wSe5pZrfgUZBOz8bwAxFjzedJjeVdc3P4jq6dR6mHsE8/P6ylujHykVJdXFTPEoMUVHpKmhnpoqAYTakhnwyW75xGnd+qu3NTsCInz7iVnOHQ== 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=3+Jd9ZOr7iF7NB50mSaOh8isl5yH0slEur+V0mVwQ0c=; b=RetAxVy9FDbzGW1gQkJS6vIJUVkxRpnyJT7lYvoNHhpzBtEVhR4rZg1TXiudGOiR8nAQPD8sRxtNis58mzGx4+6M5DnujXDl3/fal11ImkDeKNGs4CFltFZBu4FsV2XOPONV9CEqrRkTqnrqAC4vLcaOqc2FNDVwO0+XwrlSkSRRTkprATMJ0zSiDbg9G/3f+41T9ZiTwsHdCWmTxDxfbuxtMG+SXZ8DpLWdKbWQCaWTyPbXTW3eeYPDZ1dWvaGkzxyJrF0Aw6FTTWnECTvZ2AaFTpA/YMD45s1aV/C5zrlk7gj4ITh/8TnGCAMR9EA3mgdf40DSzEP4CRNHVpuDlQ== 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=3+Jd9ZOr7iF7NB50mSaOh8isl5yH0slEur+V0mVwQ0c=; b=qL5qL9kwJfMvAlE9vm8iV8gcIeVbRhWsKhSxYOSi4SCnD8u/jsD34GdiqzKLkTqVO5+Qt7+hLZWDXyaJUb4xYG7RZZTbBttRvKOF3a9vW0GPPEo1CLAvr1dsBUOQoBYkA3TLHRmzZdre5ZZerduj1zGBkb0h8/qHrbU3jvpjIjnmkp3Asrxaa9Ndnelfpcrx47OG7+I3mu5h/aezfdM88pXTjm4wLYmb/2Dtd5ssjXj/Ec20gyTmcOyeeVbiosYhtmvpRay3AYscnK02BwK68oOJ6w34gP9RjTNPr7mPohgz3A8aSa07NpJnzTVrbFJRmUpJfWFB3p6zDcBOAoH2Pw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) by CY5PR12MB6573.namprd12.prod.outlook.com (2603:10b6:930:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.24; Tue, 4 Feb 2025 18:35:07 +0000 Received: from CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732]) by CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732%6]) with mapi id 15.20.8398.025; Tue, 4 Feb 2025 18:35:07 +0000 From: Jason Gunthorpe To: Alim Akhtar , Alyssa Rosenzweig , Albert Ou , asahi@lists.linux.dev, Lu Baolu , David Woodhouse , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Marek Szyprowski , Hector Martin , Palmer Dabbelt , Paul Walmsley , Robin Murphy , Samuel Holland , Suravee Suthikulpanit , Sven Peter , Thierry Reding , Tomasz Jeznach , Krishna Reddy , Chen-Yu Tsai , Will Deacon Cc: Bagas Sanjaya , Joerg Roedel , Pasha Tatashin , patches@lists.linux.dev, David Rientjes , Matthew Wilcox Subject: [PATCH 14/19] iommu/pages: Move the __GFP_HIGHMEM checks into the common code Date: Tue, 4 Feb 2025 14:34:55 -0400 Message-ID: <14-v1-416f64558c7c+2a5-iommu_pages_jgg@nvidia.com> In-Reply-To: <0-v1-416f64558c7c+2a5-iommu_pages_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR05CA0001.namprd05.prod.outlook.com (2603:10b6:208:91::11) To CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8659:EE_|CY5PR12MB6573:EE_ X-MS-Office365-Filtering-Correlation-Id: 757083d8-0006-4863-e83d-08dd454aa3b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016|921020; X-Microsoft-Antispam-Message-Info: CCiSO6yA7O0GBIFiBqdEucm+zwwlnplPcduQjTr1lL8DLScvsr8gAmAVhPCnx+SEm9fFrpohnR8dVOiuydFJqsDOvUm7Uy3kuGN50rRvhXs/qTaSI+OH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MMeNIlM3poC4joodJ30VV/kyYJHqKjSYRKnycxcm+KPH8VE09JkFlFtD9ZSyMIABwJ3p/O5FxzwaGd0D4rNaGYLFcmIbbdYrBF1QaDKupt8tKMuvZiQa7oSA7bX9nmwSi1zpcoEai0epLXk1tn/d5RyOLq3tkbMjZ7PzGnxiP0YEFdudIdS7DiIX0A40jxCX2P/ntmENg4+JW6juSAXQ4c5BT8pawnMXupf1CDD6vdbNj8avFQ06ZKoNnaclMleA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB8659.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KIHvuaFMh7T4Mb/PcetrFtffVfBurxM2FSrYKzDwnAQf8azpsXk0VIuySPy10xYM6/Tb5GRhZv0ne3XTwrm1Hn2audUSEquuJY3d9q8kaLUKTJHxhwvumK/Zk4poRSYmBoSQEdjCVEyiQoIJPWnkO9bzqiPZH6n95SXQQuaE8xDs8XDS99VzPIUgI0hggB4uy3MAg0NsY+yaxQc/dWW5klsKKlu0kdWS2cL29p+NYNeMZ0tlDfIWC3KUjDxfSLrLIT2g7fqcgzbPv2a133acE99FLoOiNS73WD0FDasCyzQP4YzbLcyuEOdwSfRfZfm2DcsN07kD+YG2B7RQ+3p4fm0tCnWkeT8DhyFCb0lgckHLuxAOmMi4x3CT79YujAhKvbSxew5HdQ/vQ6LbtcmYyq7NA2MZ5s6yEot0KWOAiMfjwq6cFbxvYv8emITWCFcULLGE1yDBp+Ak1p+mS0jBGN306qX2WX83NcB0vYP+NUfFFV9RCjZiYXq136At1pVVKHwCvtI6In/XWrFt84Beiw8TZd8Snu2jaHsl3ZLOFI6a2AD4CJ4EAWJvn5lfwCksb7vpuji8xURD4jgPgyaPPOAoPSzaOB7DKOVcjegbvGfuStSnmK/zsexuqD3F0ONqeU6H3T8blLQK5XJYywiZv+Mt3A6H6m3e9sC5YsJ7gFpZ7w6sloGyHeapcVmnZ55/GztUC8WSz7dTQBk93BipBQQTkeDyMop2SR9+QYasFWSxkyZtCEm/iORd5YgKYXtDo7Gydp29jCOwe6X7jii0d+wPcP13sUjy6DCKU0+QPVKYQmo5rCfqFLspi+G2wdF42cU/h9uKPqIaRDwl6MEJouTYHom3+FvLsMyH4MmZOwLcxKzNpLTbJMEMrRDnLNNKCDoyXx2D8UtBK+jtRc4jPZO7ys+tgXgM7PASgChRW4VByWpBveFz+T+0mf8kdztRekjWeQf588TocvLfEfMWcXf1ELbTG08KCsidok7fJclk9xbLg1aMUw/XdZMdHz/v2VYoX1BBbxCJWihuWoYhkck3j6EHMo0NZHX8Owc9J5ABqrokzWoBORlskP2lwJQ7RzshgoIb+zgLMZioPHpCmUImgYbhWTXl1Ur2ZRU2OUGY8Nm2zSwEJd19jW4iy3xBNM+19dnMA5ZJQYoBJRDc02/BiFetIE/r6QViVvgr8F3BQ6fnrV9qlxbq6844kLqyNISumzvvptx17Pl+N8kWxcuHmahVEzORp2H+24GlNbn7VgnwSrTPU7tY9W7PO1DmO1RlKJR0BMH3pespZHWRcO9FntI6dTYl9UbcSSeH3YOYZ9pDQLNtS1Lq3Px46O4emv2i9q7DfJf/adqP6ID1LmiAmuiNhHT/qsm7kSMHvoaStHpPVqHj8URGck4+lIA3QCN2c4twvKTifzJHlkJDGLJ8SglOH9Q7CEvITyZ20i4Ot8dJ6DtUYGaroaDFjw6aX+gnkkjNkqrDypCzocsqOoBBjtVCO/5ZIdlDKm073hwDWyBdKcabAfqtXZ/qhjsa/MHDkzEhnLy5Yetk4yoLyUjWYCimxNe81KWqZSk6liE= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 757083d8-0006-4863-e83d-08dd454aa3b2 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8659.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2025 18:35:03.5720 (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: y+j5iHn58pM1HrzgzldRtaO8d5QfwXcs1Yqd9k+jqHbWENBOHbtoa2iUC8ApWhwy X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250204_103519_371079_6FA5B74D X-CRM114-Status: GOOD ( 13.47 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The entire allocator API is built around using the kernel virtual address, it is illegal to pass GFP_HIGHMEM in as a GFP flag. Block it in the common code. Remove the duplicated checks from drivers. Signed-off-by: Jason Gunthorpe --- drivers/iommu/io-pgtable-arm.c | 2 -- drivers/iommu/io-pgtable-dart.c | 1 - drivers/iommu/iommu-pages.c | 4 ++++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index b4c3729076376b..8727d8e1e02f45 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -267,8 +267,6 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, dma_addr_t dma; void *pages; - VM_BUG_ON((gfp & __GFP_HIGHMEM)); - if (cfg->alloc) pages = cfg->alloc(cookie, size, gfp); else diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c index f7b939d4b7d0b9..a4cbd8a8a2976e 100644 --- a/drivers/iommu/io-pgtable-dart.c +++ b/drivers/iommu/io-pgtable-dart.c @@ -111,7 +111,6 @@ static void *__dart_alloc_pages(size_t size, gfp_t gfp) { int order = get_order(size); - VM_BUG_ON((gfp & __GFP_HIGHMEM)); return iommu_alloc_pages(gfp, order); } diff --git a/drivers/iommu/iommu-pages.c b/drivers/iommu/iommu-pages.c index f7def716997af4..47ee9ad4a40d4d 100644 --- a/drivers/iommu/iommu-pages.c +++ b/drivers/iommu/iommu-pages.c @@ -37,6 +37,10 @@ void *iommu_alloc_pages_node(int nid, gfp_t gfp, unsigned int order) const unsigned long pgcnt = 1UL << order; struct folio *folio; + /* This uses page_address() on the memory. */ + if (WARN_ON(gfp & __GFP_HIGHMEM)) + return NULL; + /* * __folio_alloc_node() does not handle NUMA_NO_NODE like * alloc_pages_node() did.