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=52.101.57.50 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796126499; b=H9O1IWpdpRuDbcZau0YxBPt/eK8okQAY/d3lIokSt37liWjRKvmCynnBLI/bBmFu9Z4m Dkhc1NOO+fs3MIv85w+Xq/O0DMB+KzxtsgYcwxKTs+FBgqG2Ez8QoIYdwEJDdjfV0GuYx tKjiRzrdZQrkmp26kbTRT4WaAokVws9sSkGvZQISIfnxMptyXDpZ82lf5gEwAlXXWPuKU 6HGex+dKHBsRT12oBQHaYCj714V5vUzqRUG1Bs90sqJHF8SfoPuuPlpr1Qm6SvDHvRGZ/ 2ZmIWPEvyEmrPD+fVutP/EgICPOkN/zoH88S8T/qw8BlX4rxs/qY8f5QFr4Y4p6JF2Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796126499; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Message-ID:Date:MIME-Version:User-Agent:CC:Subject:Content-Language: To:References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding: X-Originating-IP:X-ClientProxiedBy:X-EOPAttributedMessage: 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-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=Gs1qSRX3CJABvCHNKNygLcWGwHPxTB7L/2PH/Iqv4So=; b=Ssuo+Y30GG6RxkOQIewmyZSzo9/9YUoWLtyfKBBo8jAt2l8F1wyi0+3CK9pCqgy6thQ3 jjtkyAqBF9X1aVuC1xhbYH2hH6H2/MyoAfmLpKlrszJMxyb/ti3WrfEIxsuyURN48QeDV mlk2KXlOT8CjlOtqKibuvXtQq7GCXIKj1e4mCifZcGuGr67sXfNEitVBXUgz+8B8OtN2o XvpCTh9wps/5SYFJR+JeuqpzU7lRfMNLptxJRyD1UeNeikAlp95nfE3L09sT0jTXSMjL0 5SkS2lkwy4HNEBMxVrr7NIk5vR7r4Hw7Y9z+49S/Oj39Ot67sxw8O6dtpZJU3Rfg7XA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=0743L7o2; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.50 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011050.outbound.protection.outlook.com [52.101.57.50]) (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 7E375606A31A for ; Tue, 1 Dec 2026 12:01:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7E375606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=0743L7o2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R9W/q2mTXVaB/Zy6GFpZBGHN5M64Hh/H5Nzi+utYodYxodTa3WVZ0BhpUo3J990Td22Mjp9PILI3J4jGBTA7QJ64t59qurPhWxAeZwK72KezLRlHBL9o1Na4AVilXrz+UqmdddosQPVkaEK6H3sG+xGnQIFLFBja0YCE+WzswJE2qzJzP58rZeokw70n/ko62w06PdNTigy1uwu26egcW5FOeq/N5Gaj1kVfUsW/zCwiJrqVhsayr1bK9LVCTnuq1cjby6nGQUPrzzogu287nnFdBrzazpbWv/JWDlYlkALoAgMtF5eI7I3YOYBAWPVyaweSc494kJAZL7YaMKqhbw== 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=Gs1qSRX3CJABvCHNKNygLcWGwHPxTB7L/2PH/Iqv4So=; b=DHIx3FPRSO9kNUkyuasO6oHHYqUt4N2kWqngVN9Z+pDcEkFRWbgyMeavItJfHel6cYxlcTKtpq4qgsOOATpbf+RUs5jG/oMqxkJ8obEkVEf3YHyR7QT/MFQ60etun48M5E0dHQSHCu2yOyAyEm5MnEXCV0Q/FvkTprtmIHXmjn9Z9e8HEMlw21r+Jg8Jl8T8MJQdYbZAO0pPI4a2cpSd7e6R7EwZh7zzlH9rQzMQdawhSYyGD+u5O+p2LtMf3LLPwdWjAzVjYKeuwj+aqaUFrve/mrBARfOlbRmcJQja/JRml1WR3oIbSVRNhE5nrCoR/k7UmWjGusdoLT7OTIrnvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=8bytes.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=Gs1qSRX3CJABvCHNKNygLcWGwHPxTB7L/2PH/Iqv4So=; b=0743L7o2OgoK1t158tCXHtPXlTksLtbIFn4WJVF6BNlS0DyJNR8eFtkWdorbMqrZA46t1Fha2TPQDcYZpD40/UT6zgzuQtMqIQ9/PEm6kySNzUQtp3L3+FEm9Dsl6ZixiRLAAO6urg2CzDqGYFjHkC1m/VD6D2uIp+zPb7I7t8o= Received: from PH8PR22CA0002.namprd22.prod.outlook.com (2603:10b6:510:2d1::26) by CH3PR12MB9078.namprd12.prod.outlook.com (2603:10b6:610:196::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.11; Tue, 1 Dec 2026 12:01:27 +0000 Received: from PH3PEPF0005961B.namprd05.prod.outlook.com (2603:10b6:510:2d1:cafe::41) by PH8PR22CA0002.outlook.office365.com (2603:10b6:510:2d1::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 12:01:26 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by PH3PEPF0005961B.mail.protection.outlook.com (10.167.243.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 12:01:26 +0000 Received: from [192.168.1.3] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 06:01:22 -0600 Message-ID: Date: Tue, 1 Dec 2026 17:31:20 +0530 X-Mailing-List: iommu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , Baoquan He , Jerry Snitselaar Subject: Re: [PATCH v5 2/3] iommu/amd: Do not convert IVMD exclusion range to unity range Content-Language: en-US To: Vasant Hegde , "Joerg Roedel (AMD)" , Adrian Huang , Joerg Roedel , Robin Murphy , Suravee Suthikulpanit , Will Deacon , References: <20261127100414.6980-1-sarunkod@amd.com> <20261127100414.6980-3-sarunkod@amd.com> <7f3cc0b4-075e-48b4-b36e-012a5423025c@amd.com> From: Sairaj Kodilkar In-Reply-To: <7f3cc0b4-075e-48b4-b36e-012a5423025c@amd.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH3PEPF0005961B:EE_|CH3PR12MB9078:EE_ X-MS-Office365-Filtering-Correlation-Id: f0d102a9-e12d-42f0-51d4-08df4fa2d39a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700016|1800799024|23010399003|11063799006|4143699003|6133799003|261009223027099003|22082099003|18002099003|10067099003|56012099006|261102123227099003|261026140227099003|261026121527099003|261021121427099003|261021123027099003|261028144727099003|261022105027099003|261022075727099003; X-Microsoft-Antispam-Message-Info: 6rI4lZJlWZfRAuC516rwmbL9hpX6aK10xAe/li2NZ6mr6JTYDwEI4tFt8lCM41EUXIuMbQl1CPtPevSPzhQZba0fblI7euThNUQDMWFFLIYZidenUnGpjmI0NzDTmIpSR0I1VHlcMqyq3oANNlQMlpMjFz1UsQ4A+ofxLF5eMlaKf+md1SSHwl9SmHe7k6yYqlSMpoZnYVqjzCpNZ9RILNprluG6mdI7zD5V6YIRy2e023VzBjaAbpuAzd0/c4UqjbPSTkgx1oZzOvK/yKUc9BXLJZzbxoTxatSVlW/GfYHPnDEQAlBTbPOoGj5VYbyhWOYRZNVQcjYW3ZI2QpvT2fuXu8LnWB6W/acE0UYWwq5B7zwf0Jwkb6m5LtVeng1TjeNlgSJ7lx1uWXXER777ToEFge+99c4rHhGqPUwg7EchxwodRl9bN7Id7SrR3FW7y2NBBHx+Ritmvn8AZXIiasJYACY7C57j0xYz5bNphpsO7c1455ZJY1wQ4OHCoGi0b+XSnSYn+fjS0ZiKoNXeut9wtea2lUR31MxdO46CVzSOuECZnE19moROY23OZqk8IiYUqvAMDJSslhoV8f5h1S08J7w/2Hi356UCiZNFxUAilCE1AFKffmFiAVaqoUoScZTM2OL17ZvyQT/Wpeiw9UB+HjAwj0ENkroy79LOCI3BSCH7LiPQd+q80Io7nQ1TMNuJBt8OCNnFlxWVYCgFEg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700016)(1800799024)(23010399003)(11063799006)(4143699003)(6133799003)(261009223027099003)(22082099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261026140227099003)(261026121527099003)(261021121427099003)(261021123027099003)(261028144727099003)(261022105027099003)(261022075727099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U8p0MzW0GKyrBbB9HCayHzxo5mCeIEaT13poJViB3GCtNLWtJhaUYiK6LTxnmWP6nX+bq5UGI4gxKw3w5uli6nvkAmsbdmKdQXULlIrJn9gqTRSwc6IOf7WD/JvTIoAYs1gsWDe34wJpmB57nROSMoiaeKQr/4uWasIyioTAX0bBM3XJgzUtFbcXW/Sh+AJKJrItirrSVDNzzV/b8KNU+FVE8qPiwQgk9tSRAWioKZXg6IzsAciqXysH0xJxj4+6uJmJSZ93JoUZX0W9GsBH8AO1dC0X79YbtLzrMCRd2vyWxXJlSuMEU6nqJ+G15/2rwd7kNRnI6F67jjUXPzK+gqHZ/IcJAKRK1HljYoAXFE4DybHSkzoqcAlnnoLGZdJb0rROzXY+JTEBSx9SkVfq6FAMuK0C16ocu+VyIE37RHsLrTrSkyLFMkyopKmeiDiW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 12:01:26.2642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0d102a9-e12d-42f0-51d4-08df4fa2d39a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: PH3PEPF0005961B.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9078 On 12/1/2026 2:20 PM, Vasant Hegde wrote: > Hi All, > > > On 11/27/2026 3:34 PM, Sairaj Kodilkar wrote: >> From: Suravee Suthikulpanit >> >> Original problem was there could be multiple IVMD exclusion entries >> conflicting over a single exclusion range supported in older Linux >> kernel. The fix was first introduced in commit 387caf0b759a ("iommu/amd: >> Treat per-device exclusion ranges as r/w unity-mapped regions") and in >> commit 0bbe4ced53e3 ("iommu/amd: Fix the overwritten field in IVMD header") >> , where IVMD exclusions are converted to separate unity_map_entry objects >> in pci_seg->unity_map so amd_iommu_get_resv_regions() treated every such >> entry as IOMMU_RESV_DIRECT with R/W. >> >> The driver no longer programs the exclusion base/limit registers and >> relies on the kernel to keep the IOVA ranges named by exclusion IVMDs >> unmapped. Stop forcing exclusion entries to RW-unity. Store the raw >> IVMD flags in struct unity_map_entry instead of a pre-shifted >> protection value, and derive the reserved region from those flags. >> Exclusion entries are now reported as IOMMU_RESV_RESERVED with no >> read/write permission. >> >> Reject unity entries that grant neither IR nor IW with a FW_BUG >> message, and entries with unknown flag bits. Warn about invalid flag >> combinations. >> >> Fixes: 0bbe4ced53e3 ("iommu/amd: Fix the overwritten field in IVMD header") >> Cc: Baoquan He >> Cc: Adrian Huang >> Cc: Jerry Snitselaar >> Signed-off-by: Suravee Suthikulpanit >> Signed-off-by: Sairaj Kodilkar >> Reviewed-by: Adrian Huang >> --- >> drivers/iommu/amd/amd_iommu_types.h | 12 ++++++---- >> drivers/iommu/amd/init.c | 36 ++++++++++++++++------------- >> drivers/iommu/amd/iommu.c | 24 +++++++++++++++++-- >> 3 files changed, 49 insertions(+), 23 deletions(-) >> >> diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h >> index d1602144c160..0f4c3c65188c 100644 >> --- a/drivers/iommu/amd/amd_iommu_types.h >> +++ b/drivers/iommu/amd/amd_iommu_types.h >> @@ -371,9 +371,11 @@ >> /* DTE[128:179] | DTE[184:191] */ >> #define DTE_DATA2_INTR_MASK ~GENMASK_ULL(55, 52) >> >> -#define IOMMU_PROT_MASK 0x03 >> -#define IOMMU_PROT_IR 0x01 >> -#define IOMMU_PROT_IW 0x02 >> +#define IVMD_FLAG_UNITY_MAP BIT(0) >> +#define IVMD_FLAG_IR BIT(1) >> +#define IVMD_FLAG_IW BIT(2) >> +#define IVMD_FLAG_EXCL_RANGE BIT(3) >> +#define IVMD_FLAG_MASK GENMASK_U32(3, 0) >> >> /* IOMMU capabilities */ >> #define IOMMU_CAP_IOTLB 24 >> @@ -890,8 +892,8 @@ struct unity_map_entry { >> /* end address to unity map (including) */ >> u64 address_end; >> >> - /* required protection */ >> - int prot; >> + /* IVMD flags for the entry */ >> + u8 flags; >> }; >> >> /* >> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c >> index f8cf37a471f8..6d92fb5c81a7 100644 >> --- a/drivers/iommu/amd/init.c >> +++ b/drivers/iommu/amd/init.c >> @@ -70,11 +70,6 @@ >> #define IVHD_FLAG_RESPASSPW_EN_MASK 0x04 >> #define IVHD_FLAG_ISOC_EN_MASK 0x08 >> >> -#define IVMD_FLAG_EXCL_RANGE 0x08 >> -#define IVMD_FLAG_IW 0x04 >> -#define IVMD_FLAG_IR 0x02 >> -#define IVMD_FLAG_UNITY_MAP 0x01 >> - >> #define ACPI_DEVFLAG_INITPASS 0x01 >> #define ACPI_DEVFLAG_EXTINT 0x02 >> #define ACPI_DEVFLAG_NMI 0x04 >> @@ -2742,6 +2737,25 @@ static int __init init_unity_map_range(struct ivmd_header *m, >> struct amd_iommu_pci_seg *pci_seg; >> char *s; >> >> + if (m->flags & ~IVMD_FLAG_MASK) { >> + pr_err(FW_BUG "IVMD type %#x devid %#x range %#llx+%#llx: Unknown flags\n", >> + m->type, m->devid, m->range_start, m->range_length); >> + return -EINVAL; > > We should print the actual flags here. > >> + } >> + >> + if ((m->flags & IVMD_FLAG_UNITY_MAP) && >> + !(m->flags & (IVMD_FLAG_IR | IVMD_FLAG_IW))) { >> + pr_err(FW_BUG "IVMD type %#x devid %#x range %#llx+%#llx: Unity set without IR/IW, ignoring\n", >> + m->type, m->devid, m->range_start, m->range_length); >> + return -EINVAL; >> + } >> + >> + if ((m->flags & IVMD_FLAG_EXCL_RANGE) && >> + (m->flags & (IVMD_FLAG_UNITY_MAP | IVMD_FLAG_IR | IVMD_FLAG_IW))) { >> + pr_err(FW_BUG "IVMD type %#x devid %#x range %#llx+%#llx: Invalid IVMD flag combination %#x\n", >> + m->type, m->devid, m->range_start, m->range_length, m->flags); >> + } > > May be I was not clear last time. Spec doesn't stop adding other flags, but it > says all other flags are ignored. So above error message is not valid. Please drop. > > >> + >> pci_seg = get_pci_segment(m->pci_seg, ivrs_base); >> if (pci_seg == NULL) >> return -ENOMEM; >> @@ -2771,17 +2785,7 @@ static int __init init_unity_map_range(struct ivmd_header *m, >> } >> e->address_start = PAGE_ALIGN(m->range_start); >> e->address_end = e->address_start + PAGE_ALIGN(m->range_length); >> - e->prot = m->flags >> 1; >> - >> - /* >> - * Treat per-device exclusion ranges as r/w unity-mapped regions >> - * since some buggy BIOSes might lead to the overwritten exclusion >> - * range (exclusion_start and exclusion_length members). This >> - * happens when there are multiple exclusion ranges (IVMD entries) >> - * defined in ACPI table. >> - */ >> - if (m->flags & IVMD_FLAG_EXCL_RANGE) >> - e->prot = (IVMD_FLAG_IW | IVMD_FLAG_IR) >> 1; >> + e->flags = m->flags; >> >> DUMP_printk("%s devid_start: %04x:%02x:%02x.%x devid_end: " >> "%04x:%02x:%02x.%x range_start: %016llx range_end: %016llx" >> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c >> index 41ee4ad1dcf8..a417bfce0c89 100644 >> --- a/drivers/iommu/amd/iommu.c >> +++ b/drivers/iommu/amd/iommu.c >> @@ -3153,10 +3153,30 @@ static void amd_iommu_get_resv_regions(struct device *dev, >> >> type = IOMMU_RESV_DIRECT; >> length = entry->address_end - entry->address_start; >> - if (entry->prot & IOMMU_PROT_IR) >> + if (entry->flags & IVMD_FLAG_IR) >> prot |= IOMMU_READ; >> - if (entry->prot & IOMMU_PROT_IW) >> + if (entry->flags & IVMD_FLAG_IW) >> prot |= IOMMU_WRITE; >> + if (entry->flags & IVMD_FLAG_EXCL_RANGE) { >> + /* >> + * Each IOMMU has only one exclusion base/limit >> + * register pair (MMIO 0x0020/0x0028). Older kernels >> + * programmed that pair with the exclusion range, >> + * which assumed at most one range per IOMMU. Some >> + * buggy BIOSes list several exclusion IVMD entries for >> + * the same IOMMU. Writing them all to the single >> + * register overwrites the earlier ranges, so they >> + * were lost. >> + * >> + * Reporting each range as a reserved region removes >> + * the one-range limit. The IOMMU core keeps these >> + * IOVAs out of allocation and never maps them, so any >> + * number of exclusion ranges is supported without >> + * touching the register. >> + */ >> + type = IOMMU_RESV_RESERVED; >> + prot = 0; > > Last time, I didn't realize that this flag causes us to skip populating the page > table. > > Below comment is generated using AI: > > The spec describes the exclusion range register (MMIO 0020h) like this: > "Device accesses that target addresses in the exclusion range are > neither translated nor access checked". So an exclusion IVMD asks for > untranslated access to that range, which in a paging domain means a > read/write identity mapping. That is what 387caf0b759a ("iommu/amd: > Treat per-device exclusion ranges as r/w unity-mapped regions") emulated. > > IOMMU_RESV_RESERVED does the opposite. The range is left out of the > IOVA allocator and never mapped, so a device in a DMA domain that > accesses it now gets an IO_PAGE_FAULT. 387caf0b759a fixed exactly that > for the Broadcom RAID controllers, whose disks were not detected. > > The spec does define a "never map" IVMD, but it uses different flags. > The text above Table 111 says: "If IR = 0b and IW = 0b in the IVMD flags > field, then the memory range is not to be mapped into the peripheral > device address space". It is not ExclusionRange. > > So the comment's claim that any number of exclusion ranges "is > supported" does not seem right. The ranges are no longer clobbered, but > the access they ask for is now blocked instead of granted. > > -- > > May be we should use IOMMU_RESV_DIRECT_RELAXABLE so that we can handle handle > both buggy BIOS (See commit 387caf0b759a) and ability to passthrough device. > > Is that fine? Anyone sees issue with this? AI reported same thing in review for me. But I was not sure about this issue, I confused P2P DMAs with the exclusion range DMA accesses. This makes sense and we should use IOMMU_RESV_DIRECT_RELAXABLE flag Thanks Sairaj > > -Vasant >