Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.27 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796378261; b=LEgmgPFWda3GQFN8+pOKo7dChkxHb/4QMjWBQ/ViE6T5ILyrw4Fj9CAs5nS+xxwQoSAn DGiH5iyDMzZuP/sDrsdnjkC2rPoZdpt8o/JPaftpqwPTzs1D4gu0DRkKIADc5Vbzk9ppG /HaQfHoiRFjdmMS0vGFSL0+mrVs7jxMDb5Acep89a1N7TT8PbFPviSxuobUsfytTN0bBB iCY6Hrq79fciFInJBYBZbgxsV+FlAZcr7HK3dqJIjeiW+iBG8rrVr3quZaavhyxfOmR04 JJBuupIWJ2aQV9lsqIdFSPxxOc8OPzuHESy2FFoxa43VR/Xh1+rTzdblHVT+ccVfSCg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796378261; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type: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=+lj7gYC/1phZ2HR8j9HcH75TelyUwKnuPzSkF6Cm0eM=; b=y0PD3Ucx1YkMyCTyGe1p4aMPGLxU6nWDvrHYSt9wNpOCdQpCCB7+u6QfKRmEcj42bec3 GSv2O30vnMZLVh59aVgHlGr6lchPWfVhbhrgUt7u+ynV9LpaCx7AeQjjKnZDv7ooId/+9 NUkKdF/0UadAtXhlIYhSEGQN4ilP0iCbRNUegM/ife2GX1U60h6WlBfvnVOsEPWNCHC4P weSBWmEH0WVtrh4+hDSFAb5e+ArQOL5BlMj5DFZIvSpy/JQ+3eMJGxilJJbzdYsgUtC4c GOpQ7dGcNb7WNjuqVMo0buAKeCMwXL7YBf+p7+U0h3yMdjfpQ0Ot9B/2HOSwNUbLPHg== 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=bmKOKQEy; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.27 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010027.outbound.protection.outlook.com [52.101.61.27]) (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 BD4C4606A33C for ; Fri, 4 Dec 2026 09:57:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BD4C4606A33C 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=bmKOKQEy ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nddBw/ER3M+xLtSyBJYp8a6Mni23rJnpA2GVVFog6US3IWEVZx/WuM160zu7gkuFH4h82VtP/2mpy1x3KSENQ4BphlkADnZ4DPap72/UOYuP6Cw8Lv21z77+vRcrzAQgok/ijiB6YqTL+E18T3iLB7fGgIc3nWrplf/d0bU0eOtFy69agxsrezSwPCsW41xULGq0XNcicd0EpUSbydJO0x6Foh0pbqpZTf3YOei6mlOdK3wHt2cN7pnEEQhyBQe+RtCCTCmB9iIy1x1wDlc1MEw1GRkrW2v0PjodLPeVeohmpcTqQtrYlOHR9TGN+etSI2FzFPIRe6v3bmNQSpi2DQ== 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=+lj7gYC/1phZ2HR8j9HcH75TelyUwKnuPzSkF6Cm0eM=; b=kal62wri16u3LUFTRKGFMlpHmXaRpYPfedRF61catuZ4ck+UCXIPqlu/T6K2iuGqFftf5ZAgNdmYmkfECNkZtQt22ZOoEQSBcyTIq6h7rMqsjhXm36Ol7L1jReTRIrqJnW467XXx2sGWk0O/2Y1MKYr6MTzg4bTeaEgILUPPbSHPokgnxyNyLmEoqwyd9mu7teBHrNapnSxUrujcw955yiKCEll3s7vFUW4qPSWiF7Of6pNNVzEsjn1+xEc7kLE4RKOXWDA9MdGIO3HcI+6lEtT30w6cBOlSl2679vAgY4tDlfJ4NmeAOV1u1QkwzMk/LJpLJcg5ADhYWxrMfcLsOA== 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=+lj7gYC/1phZ2HR8j9HcH75TelyUwKnuPzSkF6Cm0eM=; b=bmKOKQEyI5cBiUuDkLGubPb5z8da6AE/6D/zvlny6WwqfDK7BHhAtxSKYFKQdVrNpyS5xKFp451LxLgoV3VAf3GpEqER5KeGeKHBLc/dLSwDGWX7z+OKdrbw9mt0G81sfYP3H5Jjwu9ak13J4ycgjLcN4/qInH8p7pnpn9u1cAE= Received: from CH5PR04CA0017.namprd04.prod.outlook.com (2603:10b6:610:1f4::17) by PH7PR12MB7355.namprd12.prod.outlook.com (2603:10b6:510:20e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 09:57:35 +0000 Received: from CH2PEPF00016D49.namprd02.prod.outlook.com (2603:10b6:610:1f4:cafe::76) by CH5PR04CA0017.outlook.office365.com (2603:10b6:610:1f4::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Fri, 4 Dec 2026 09:57:35 +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 CH2PEPF00016D49.mail.protection.outlook.com (10.167.244.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 09:57:35 +0000 Received: from kali.amd.com (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; Fri, 4 Dec 2026 03:57:33 -0600 From: Vasant Hegde To: CC: Subject: [PATCH 03/38] iommu/amd: Adhere to IVINFO[PAsize] for output address limits Date: Fri, 4 Dec 2026 09:56:01 +0000 Message-ID: <20261204095636.335222-4-vasant.hegde@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261204095636.335222-1-vasant.hegde@amd.com> References: <20261204095636.335222-1-vasant.hegde@amd.com> 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: CH2PEPF00016D49:EE_|PH7PR12MB7355:EE_ X-MS-Office365-Filtering-Correlation-Id: 99102114-3f83-4fac-ec59-08df51ed059c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700016|1800799024|23010399003|11063799006|6133799003|261009223027099003|22082099003|18002099003|10067099003|56012099006|261102123227099003|261028144727099003|261021121427099003|261026121527099003|261026140227099003|261021123027099003|261022105027099003; X-Microsoft-Antispam-Message-Info: io+T6NWSxsLlO10dQD2K54CQxM0ry6fWn4/CBtLRNo1vVzDhbMvA1+nt0y8wNFSNN7utx11l3Pw1SDJdKYgICYUT2eLBxOlKtk73DT123IZEzlt0vG8aMAWRAAEkaY5eCL6DfG4Ii5AIzx2OQXE7GE01l4cuyqY4WjGbMu6iPPKlygZw7JQ57u2i+LljfAa5q5iwGS9kxcYEmHBEBVD+DCOa0R1wL01bRAW8Osxa+bpDl2mTn3KmzmDSmC2koNT2ZAJiUhnmaKjrMRHd/ujLISNl/yxka3qSOgNA6l3htNKRXkHGOVILerwn3+127R+DG5zwvVYL79P//SsO1s/oqFetsAeM5gsQJ68md10lYpnzoulipwsUxg6NvLXwCoIei31sHPlimA3+LaVhphI/5KFiq+yK70E63/YQxjsZavkprjre3FvJGKQp673Xg6ScGoRtXRfVptlbgu9/qBLitLPyPl7sYQU8AVi4ag98J56eQM+Me2HB0fVU94Cwb6oS7wZK8/ZWai6bi9eMVo+TFQxdpbecE1z0yCk6ObSrmEJRe8IxNDAINmEyXMrqApxq0nPd00StgvYADBz9lNlti0wG+YFxAJcs2QcDC1H2Z8ZoOu6QgxUaD5STR/Hwa0Rk+LFHqWHJ8NtmYet8yg0uk4LIqhldx7MY5qGFUQvfkYb0L02xOufCsxjsaPkmx+M6dRCl0rvEhavxoE5hp1j1OA== 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)(376014)(82310400026)(36860700016)(1800799024)(23010399003)(11063799006)(6133799003)(261009223027099003)(22082099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261028144727099003)(261021121427099003)(261026121527099003)(261026140227099003)(261021123027099003)(261022105027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zc7Iz8KnOYnX711+obtsv2idjpM84J2sc7ONdY60yZ8VbnN9umgmnG6aIMLtcZQCVFCyOBBlI/P/tcQQyFPUaVAuuONCShMi41WcOoAERqw07SJGGjL55LAkcvVNOYdIA9c6lYDo106pFWb/Ee9HzS+h8nRiUG2ccjdCu+EmMGoWW3pKcyty0m4wN3ZzIMBHmARe7YVbwqbwC7oOc01k0cVUN0mG6HeEhi5CWfqjKEpMQo5LYlHXeLiRg2SfaUW6idaHhWWqyAsKrv2l9zGfcUX2TJrXoW7Qhl3ui2c5vgXT+Z5z1gr6SLnh6fWAxbCtcrb7dfhOAOmErs2hvbjHxp1+eN+I59KD4Zc5asjv6yBBkAcdajrfHswMp2p0s30ZsQo/clNadmN1JKymM1UYdgAHc6nbbroAH0BoqD3+n+Tg0IO6OuErBQr77ommKSvh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 09:57:35.2594 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99102114-3f83-4fac-ec59-08df51ed059c 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: CH2PEPF00016D49.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7355 From: Ankit Soni ACPI IVRS IVinfo reports the maximum physical address size (PAsize) supported by the IOMMU. The AMD IOMMU driver currently hardcodes 52 bits when configuring paging domains. On systems where firmware or a VM advertises a smaller limit, the driver may over-advertise capabilities and create domains outside the hardware's actual bounds. Signed-off-by: Ankit Soni Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 1 + drivers/iommu/amd/init.c | 9 ++++++++- drivers/iommu/amd/iommu.c | 4 ++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h index 29355810db7c..315ec397333b 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -45,6 +45,7 @@ extern int amd_iommu_guest_ir; extern enum protection_domain_mode amd_iommu_pgtable; extern int amd_iommu_gpt_level; extern u8 amd_iommu_hpt_vasize; +extern u8 amd_iommu_pasize; extern unsigned long amd_iommu_pgsize_bitmap; extern bool amd_iommu_hatdis; diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h index f98770db0090..dab2a423b296 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -385,6 +385,7 @@ #define IOMMU_IVINFO_EFRSUP BIT(0) #define IOMMU_IVINFO_DMA_REMAP BIT(1) #define IOMMU_IVINFO_VASIZE GENMASK_ULL(21, 15) +#define IOMMU_IVINFO_PASIZE GENMASK_ULL(14, 8) /* IOMMU Feature Reporting Field (for IVHD type 10h */ #define IOMMU_FEAT_GASUP_SHIFT 6 diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index b63a5e69279e..1a72e35cdafd 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -157,6 +157,8 @@ bool amd_iommu_irq_remap __read_mostly; enum protection_domain_mode amd_iommu_pgtable = PD_MODE_V1; /* Virtual address size */ u8 amd_iommu_hpt_vasize; +/* Physical address size */ +u8 amd_iommu_pasize __ro_after_init; /* Guest page table level */ int amd_iommu_gpt_level = PAGE_MODE_4_LEVEL; @@ -3305,7 +3307,12 @@ static void __init ivinfo_init(void *ivrs) static void __init init_pgtable_params(void) { - u8 vasize, efr_hats; + u8 pasize, vasize, efr_hats; + + pasize = FIELD_GET(IOMMU_IVINFO_PASIZE, amd_iommu_ivinfo); + if (!pasize) + pasize = 52; + amd_iommu_pasize = min_t(u8, pasize, 52); vasize = FIELD_GET(IOMMU_IVINFO_VASIZE, amd_iommu_ivinfo); if (!vasize) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 60aeb10362f2..61b3191136e4 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2758,7 +2758,7 @@ static struct iommu_domain *amd_iommu_domain_alloc_paging_v1(struct device *dev, cfg.common.features |= BIT(PT_FEAT_FLUSH_RANGE); cfg.common.hw_max_vasz_lg2 = amd_iommu_hpt_vasize; - cfg.common.hw_max_oasz_lg2 = 52; + cfg.common.hw_max_oasz_lg2 = amd_iommu_pasize; cfg.starting_level = 2; domain->domain.ops = &amdv1_ops; @@ -2833,7 +2833,7 @@ static struct iommu_domain *amd_iommu_domain_alloc_paging_v2(struct device *dev, cfg.common.hw_max_vasz_lg2 = 47; cfg.top_level = 3; } - cfg.common.hw_max_oasz_lg2 = 52; + cfg.common.hw_max_oasz_lg2 = amd_iommu_pasize; domain->domain.ops = &amdv2_ops; ret = pt_iommu_x86_64_init(&domain->amdv2, &cfg, GFP_KERNEL); -- 2.31.1