From patchwork Thu May 18 14:39:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246909 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 E1D37C7EE23 for ; Thu, 18 May 2023 14:40:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536392.834668 (Exim 4.92) (envelope-from ) id 1pzenG-0007Mb-Tt; Thu, 18 May 2023 14:39:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536392.834668; Thu, 18 May 2023 14:39:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzenG-0007MU-Qu; Thu, 18 May 2023 14:39:50 +0000 Received: by outflank-mailman (input) for mailman id 536392; Thu, 18 May 2023 14:39:49 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzenF-00074K-4e for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:39:49 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20608.outbound.protection.outlook.com [2a01:111:f400:7eaa::608]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d61c4b9f-f589-11ed-8611-37d641c3527e; Thu, 18 May 2023 16:39:47 +0200 (CEST) Received: from DS7PR03CA0179.namprd03.prod.outlook.com (2603:10b6:5:3b2::34) by BN9PR12MB5179.namprd12.prod.outlook.com (2603:10b6:408:11c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Thu, 18 May 2023 14:39:43 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::ee) by DS7PR03CA0179.outlook.office365.com (2603:10b6:5:3b2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:39:43 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.15 via Frontend Transport; Thu, 18 May 2023 14:39:43 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:39:42 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:39:41 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d61c4b9f-f589-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lxn6bxJ9FerscYp3grHBK2B0pUXcoeNVyjdBgNvThgGyKNEALTzfU17PsiFbOT2lG77rc8pFX07dyCuog2cv1WF3zmlSRwUgc/CZmbHYHrsnT51mR9VZRgPX2amK8T+BUVmyXNvtEIytCoBrHSModYYe2pZY1DsegMVCa7l3bf40ybP7innwTfZFOqL2xoX7F+t3n32o6BpUvz73muGw2AgPLjoJeWCHbL1zEGuh83PQMWP40Jsp0pCJaFGgWdLIfqfrHpI6+YuMMg2ZBY3ecQr2JrIUL91308TUoJXSUgwnF3F+aEEnaus0QhZvlrQwpjff/f0DlqldRbj0gRZ+fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=5fJWKj17VMd4J7OD9poo9yDrAqqLVEuS40vyYFKg3Cw=; b=Mikke4fJReDcL8VdETUDJEPJTlh97aslDxLn7mhwxEy5HdyuX0uK4/ewLn2mKE/JPizYydafvkHWn61SS2FSFPlg3pLHquoTycPXUfAea4mXsKxz4zD4+TkoXE664IBmcZkKiCu4Tq+b8PGjocVktXu6qNxmfbVOKkr0YfZIZu5SKq6XALk+H+nERAtft9V9CJA7Ax9MGviziMSX6qRjXSqNku9+XfkWUsbnlG1HMcEpyEA0Wq+khh1gbtLBXCEctIzvDGhTRmheSJqO+GdsPeqRMA0snIJFGHCQ4jMl2y3ArsxR2Kvwn9A02mJfl5wDRO5ro9xsTGMQl2x5ZHotLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=5fJWKj17VMd4J7OD9poo9yDrAqqLVEuS40vyYFKg3Cw=; b=Cwo6uug56mruDIseFPdUnK8HMVoCkAKspB28uOoMYsrUdAW0nmCQnpp32cEe511W1dH4768pKmFaM7A++JH6INVi8ADy4aQ45/E1tDRdlSi1fCV5FdSDy1Nc6iPDVMXMc1ffeadoxVtBk3c8LNbfnHEzJbrVtWhTNmnFXrcAk44= X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 01/11] xen/arm: domain_build: Track unallocated pages using the frame number Date: Thu, 18 May 2023 15:39:10 +0100 Message-ID: <20230518143920.43186-2-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT003:EE_|BN9PR12MB5179:EE_ X-MS-Office365-Filtering-Correlation-Id: e8295b1e-d244-40d7-87c6-08db57adb821 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yzlQW8HU0QhXF13+6fkD+BIJJyDB9q5BmFHDi0AtI3L1c0viVJqHgwFmoBPdnuGd4XcMpUBfvXK28chzRvYrOfB3W0PlqtSwSEkD7HJqlvF6ZUahdpRzCfzfCcDaD3PBgdy3YTL/2x+6VJY6vvatvwth1rysr3rq44drWufZ4ja2b3M5fHY3aOoJooIco3l22Brq4krBLwhxaajBwqfGuUbyuwH2y7cU5c95auuaeQ57FZ2DsroRnnRgviWeOUbjk/sSgwcWaaiKNmqNtAmngURLe0858O4/BnAwr2nxGEL4vvmx5/EdyrdxOFiXX4UOsDXG8Eq1cund4EDurSrEd+Z4bDITrf+pCNr5C5vOF4Y48jlzwYK8WkjgrCsFOwNRenJvGLZM7uFBIY6rrNRTu+TLDq1CAAy32eSfSzZQvtz6SqpbyzqUMk5E6AUczGqGA2wX5R09bkk1J4TYQRVQydTyAPvrd6c1tcDCvNaGAPKkP6HQtftrW7Elg/oPvneP9I7oTtmWVTbYlICdGAhkQ0+dK7xXF4WPYl135QFL2kbhvZanmrgx7iqasrKhxdZlXr4Q9XlVF5vkFyzJ+p7hGppCLUqIAV6dk5EC03lOKOKr8F71uA4FN1QvKj6XLpG3vKOP+BmLVUIWVesC5WLEz0htHcbVdyzfIRDXNGBMbZlry3ufvYjtofa8Gg/uXVoCzn2P7l1soylgdGIAE7iSDge++HKlxgedt7osKfYId2vTvV3UHNkTL+6kZXl9UmwYV7bsHm37B9eDg0nGjagDtpQAClsy678OQK5atyYQRVE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199021)(40470700004)(36840700001)(46966006)(86362001)(6916009)(8676002)(41300700001)(8936002)(4326008)(356005)(82740400003)(82310400005)(81166007)(54906003)(336012)(70586007)(70206006)(316002)(103116003)(7416002)(36756003)(2906002)(83380400001)(478600001)(47076005)(426003)(2616005)(36860700001)(40480700001)(6666004)(966005)(26005)(5660300002)(40460700003)(186003)(1076003)(21314003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:39:43.2283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8295b1e-d244-40d7-87c6-08db57adb821 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5179 rangeset_{xxx}_range() functions are invoked with 'start' and 'size' as arguments which are either 'uint64_t' or 'paddr_t'. However, the function accepts 'unsigned long' for 'start' and 'size'. 'unsigned long' is 32 bits for Arm32. Thus, there is an implicit downcasting from 'uint64_t'/'paddr_t' to 'unsigned long' when invoking rangeset_{xxx}_range(). So, it may seem there is a possibility of lose of data due to truncation. In reality, 'start' and 'size' are always page aligned. And Arm32 currently supports 40 bits as the width of physical address. So if the addresses are page aligned, the last 12 bits contain zeroes. Thus, we could instead pass page frame number which will contain 28 bits (40-12 on Arm32) and this can be represented using 'unsigned long'. On Arm64, this change will not induce any adverse side effect as the max supported width of physical address is 48 bits. Thus, the width of 'gfn' (ie 48 - 12 = 36) can be represented using 'unsigned long' (which is 64 bits wide). Signed-off-by: Ayan Kumar Halder Reviewed-by: Michal Orzel Acked-by: Julien Grall --- Changes from - v3 - 1. Extracted the patch from https://lists.xenproject.org/archives/html/xen-devel/2023-02/msg00657.html and added it to this series. 2. Modified add_ext_regions(). This accepts a frame number instead of physical address. v4 - 1. Reworded the commit message to use Arm32/Arm64 (32-bit/64-bit Arm architecture). 2. Replaced pfn with gfn to denote guest frame number in add_ext_regions(). 3. Use pfn_to_paddr() to return a physical address from the guest frame number. v5 - 1. Updated the commit message. Added R-b and A-b. v6 - 1. No changes. xen/arch/arm/domain_build.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 71f307a572..e0ac5db60d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1500,10 +1500,13 @@ static int __init make_resv_memory_node(const struct domain *d, return res; } -static int __init add_ext_regions(unsigned long s, unsigned long e, void *data) +static int __init add_ext_regions(unsigned long s_gfn, unsigned long e_gfn, + void *data) { struct meminfo *ext_regions = data; paddr_t start, size; + paddr_t s = pfn_to_paddr(s_gfn); + paddr_t e = pfn_to_paddr(e_gfn); if ( ext_regions->nr_banks >= ARRAY_SIZE(ext_regions->bank) ) return 0; @@ -1566,7 +1569,8 @@ static int __init find_unallocated_memory(const struct kernel_info *kinfo, { start = bootinfo.mem.bank[i].start; end = bootinfo.mem.bank[i].start + bootinfo.mem.bank[i].size; - res = rangeset_add_range(unalloc_mem, start, end - 1); + res = rangeset_add_range(unalloc_mem, PFN_DOWN(start), + PFN_DOWN(end - 1)); if ( res ) { printk(XENLOG_ERR "Failed to add: %#"PRIpaddr"->%#"PRIpaddr"\n", @@ -1580,7 +1584,8 @@ static int __init find_unallocated_memory(const struct kernel_info *kinfo, { start = assign_mem->bank[i].start; end = assign_mem->bank[i].start + assign_mem->bank[i].size; - res = rangeset_remove_range(unalloc_mem, start, end - 1); + res = rangeset_remove_range(unalloc_mem, PFN_DOWN(start), + PFN_DOWN(end - 1)); if ( res ) { printk(XENLOG_ERR "Failed to remove: %#"PRIpaddr"->%#"PRIpaddr"\n", @@ -1595,7 +1600,8 @@ static int __init find_unallocated_memory(const struct kernel_info *kinfo, start = bootinfo.reserved_mem.bank[i].start; end = bootinfo.reserved_mem.bank[i].start + bootinfo.reserved_mem.bank[i].size; - res = rangeset_remove_range(unalloc_mem, start, end - 1); + res = rangeset_remove_range(unalloc_mem, PFN_DOWN(start), + PFN_DOWN(end - 1)); if ( res ) { printk(XENLOG_ERR "Failed to remove: %#"PRIpaddr"->%#"PRIpaddr"\n", @@ -1607,7 +1613,7 @@ static int __init find_unallocated_memory(const struct kernel_info *kinfo, /* Remove grant table region */ start = kinfo->gnttab_start; end = kinfo->gnttab_start + kinfo->gnttab_size; - res = rangeset_remove_range(unalloc_mem, start, end - 1); + res = rangeset_remove_range(unalloc_mem, PFN_DOWN(start), PFN_DOWN(end - 1)); if ( res ) { printk(XENLOG_ERR "Failed to remove: %#"PRIpaddr"->%#"PRIpaddr"\n", @@ -1617,7 +1623,7 @@ static int __init find_unallocated_memory(const struct kernel_info *kinfo, start = 0; end = (1ULL << p2m_ipa_bits) - 1; - res = rangeset_report_ranges(unalloc_mem, start, end, + res = rangeset_report_ranges(unalloc_mem, PFN_DOWN(start), PFN_DOWN(end), add_ext_regions, ext_regions); if ( res ) ext_regions->nr_banks = 0; @@ -1639,7 +1645,7 @@ static int __init handle_pci_range(const struct dt_device_node *dev, start = addr & PAGE_MASK; end = PAGE_ALIGN(addr + len); - res = rangeset_remove_range(mem_holes, start, end - 1); + res = rangeset_remove_range(mem_holes, PFN_DOWN(start), PFN_DOWN(end - 1)); if ( res ) { printk(XENLOG_ERR "Failed to remove: %#"PRIpaddr"->%#"PRIpaddr"\n", @@ -1677,7 +1683,7 @@ static int __init find_memory_holes(const struct kernel_info *kinfo, /* Start with maximum possible addressable physical memory range */ start = 0; end = (1ULL << p2m_ipa_bits) - 1; - res = rangeset_add_range(mem_holes, start, end); + res = rangeset_add_range(mem_holes, PFN_DOWN(start), PFN_DOWN(end)); if ( res ) { printk(XENLOG_ERR "Failed to add: %#"PRIpaddr"->%#"PRIpaddr"\n", @@ -1708,7 +1714,8 @@ static int __init find_memory_holes(const struct kernel_info *kinfo, start = addr & PAGE_MASK; end = PAGE_ALIGN(addr + size); - res = rangeset_remove_range(mem_holes, start, end - 1); + res = rangeset_remove_range(mem_holes, PFN_DOWN(start), + PFN_DOWN(end - 1)); if ( res ) { printk(XENLOG_ERR "Failed to remove: %#"PRIpaddr"->%#"PRIpaddr"\n", @@ -1735,7 +1742,7 @@ static int __init find_memory_holes(const struct kernel_info *kinfo, start = 0; end = (1ULL << p2m_ipa_bits) - 1; - res = rangeset_report_ranges(mem_holes, start, end, + res = rangeset_report_ranges(mem_holes, PFN_DOWN(start), PFN_DOWN(end), add_ext_regions, ext_regions); if ( res ) ext_regions->nr_banks = 0; From patchwork Thu May 18 14:39:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246910 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 C0206C77B7D for ; Thu, 18 May 2023 14:40:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536397.834677 (Exim 4.92) (envelope-from ) id 1pzeo0-0000UH-70; Thu, 18 May 2023 14:40:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536397.834677; Thu, 18 May 2023 14:40:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeo0-0000UA-3t; Thu, 18 May 2023 14:40:36 +0000 Received: by outflank-mailman (input) for mailman id 536397; Thu, 18 May 2023 14:40:34 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeny-00074K-Pc for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:40:34 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20601.outbound.protection.outlook.com [2a01:111:f400:7e88::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f121d681-f589-11ed-8611-37d641c3527e; Thu, 18 May 2023 16:40:32 +0200 (CEST) Received: from BN0PR04CA0159.namprd04.prod.outlook.com (2603:10b6:408:eb::14) by IA0PR12MB7652.namprd12.prod.outlook.com (2603:10b6:208:434::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 14:40:28 +0000 Received: from BN8NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::82) by BN0PR04CA0159.outlook.office365.com (2603:10b6:408:eb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.20 via Frontend Transport; Thu, 18 May 2023 14:40:28 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT011.mail.protection.outlook.com (10.13.176.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:40:27 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:40:27 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 07:40:26 -0700 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:40:25 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f121d681-f589-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TxZxdQ0XkawVC9kho2WT2FtHwa6ZCNWyuezW2z/Uj+mESMKX9QPd4i3PbEZHDlWc/bOVthBsoiAfmGw+0ecW4LgNCxsOWSmHARpjOeGVkR6LXAtJfF3HyWd2178iTm3t/HsgKJWz7m43ZAKzkZX2lcwlF1dpN0uqiSy9xjKHbWlhdHXnZjdWPTouy7VA6s8QCrKO7+13aVOHwhHFmpC7oVjP90X8z+ftRaBYJOyCJ9rJYwMP6OzS1Uf7XKoSr0oyyDUaqOLkWK0eiI8tKGj5Zlx4nDv6MNFTnFwQqhiPKxzz3i7pMTPXt8dWSxeVgMhDyRvLyMEHxO9sI0p5UyWSJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=+tqVoZ2YFpUeNO52o/M+YkHJkClJ6m4riHukSRNfevU=; b=bvdvvcSU8MBiXFsivFtD8WxEBDOLU3FpX54Czf5jS1add0Me4UAwKEatyDma8Xb36EhGIdfNIXqbdoC8gg0hkqt8zUi+WNgMzV9MG0LKtUd+3yOOdcvUrXOcvEIY13rJj/wVQaXxxWJu/eq6OpH4ppdCGZ3Ea/MwpZbvQLzhJ1ajrXFn0hhwoy9+6Cuu9AchxYEt26Tav/EaeJJUtDMJqLBXfScH8VT+kOlKkfLcoFjVKtCekHjIWMKmQWZafDdU6uQgKFMniu958fkja+gkVk5NNOdPMGjanygmDrac0ICFvEn12tV21Kt50tI8GDt/JHa28Sz5r6odJoLVrhTP+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=+tqVoZ2YFpUeNO52o/M+YkHJkClJ6m4riHukSRNfevU=; b=HEPucOwMUXr1jCdrcHk3ZzgO7y00ebptZ1GsVhqsdyFmiQ8JjRZQhpoDNyYe1vWUV++vIHhT0thUv5CpZx2dHgGpceToHUtz1ud14VpA8Ov0vJrFUt1hgO0VA5kgQ94JFxrW9zytJusomjm0oSsYt+1ZWX/DRWoQtrYpsk9aXCY= X-MS-Exchange-Authentication-Results: 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=SATLEXMB03.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 02/11] xen/arm: Typecast the DT values into paddr_t Date: Thu, 18 May 2023 15:39:11 +0100 Message-ID: <20230518143920.43186-3-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT011:EE_|IA0PR12MB7652:EE_ X-MS-Office365-Filtering-Correlation-Id: d5892642-ee00-4618-7d35-08db57add2b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4JhO5bt6yWYYWGK41MCPgBxZQ1VZn44Z6/QsFTVshMTRmFamw7T/ocMf5b5JpxFUzWxNGm+c8LaBvlmPCX/inwyy0gYmTVz0rjFg3nsa+4CDGh6y4xNDqGvjrXZjR9HR7xDWnSuizJeWZn1TDaceWRJAMubXpGvd4/XH6ZCuG5pLZwQsfqoUjZbDBOka/9XO2N3Z65TI1o0D1ZFuEbOx5ck/+BxedMnEKTKvjsqlYS9uU1hHp6snM+b9j6sBXu7E8qw5GN+MFYdGx4gfy0x9W58QoJpRfFXrNnvI3WzzQdfXBVHn8X5StIbz4EwgkasQNwcjqDbwt7z/NGUS21wZeNNkC5HPgolEtcCCjxqyl9wT9+9mKz8Rkv7+fyIPnhh/lhMZ0VZM4Zl0v1qG4Q8F9tYHE1u4d3Q7NahHnthIjqkgwoyfUiHFcmOZ/wq0C/Isug8cLUlWvXmQQ30NTX//6hW1gdiF66ff/cpxBDj+lfqlraHFjXaGM0YtEK9mfq2qglNsQtGfmAc7umu0y/Z3d5vxghVo3/JaMC8LWnRmHM8A0WypKLgugz2li13hNkTrfzKqA+etya6Ppv3v6cdtjMWZFtmJQ0hu68ZHHXRQpjyNEYHLhZtU4Hq6t4VlmxnYs06b1DuhPxuH9b1XJPz/GbSKTqpbv0MB6aniXrlEUF6jt0ZP6HoAnYomN2DE3thnXsLEuYEhX9wyP/lKHdzvSvh8eqMVAQ4wp45vXnGfMfAfD5Ex+bt4GiVOniZZ4lJ71qgBruFAVf6NMO/t1OqbdGeGNtsPLiuSc8bpHuF6GKFGp+TIUCwy9ZT4R4aAbNMZ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(39860400002)(396003)(376002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(316002)(70206006)(70586007)(478600001)(4326008)(54906003)(6916009)(36756003)(103116003)(83380400001)(47076005)(1076003)(426003)(36860700001)(186003)(26005)(2616005)(86362001)(30864003)(2906002)(5660300002)(8936002)(8676002)(82310400005)(336012)(6666004)(40480700001)(7416002)(356005)(81166007)(41300700001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:40:27.8591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5892642-ee00-4618-7d35-08db57add2b4 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7652 The DT functions (dt_read_number(), device_tree_get_reg(), fdt_get_mem_rsv()) currently accept or return 64-bit values. In future when we support 32-bit physical address, these DT functions are expected to accept/return 32-bit or 64-bit values (depending on the width of physical address). Also, we wish to detect if any truncation has occurred (i.e. while parsing 32-bit physical addresses from 64-bit values read from DT). device_tree_get_reg() should now be able to return paddr_t. This is invoked by various callers to get DT address and size. For fdt_get_mem_rsv(), we have introduced a wrapper named fdt_get_mem_rsv_paddr() which will invoke fdt_get_mem_rsv() and translate uint64_t to paddr_t. The reason being we cannot modify fdt_get_mem_rsv() as it has been imported from external source. For dt_read_number(), we have also introduced a wrapper named dt_read_paddr() dt_read_paddr() to read physical addresses. We chose not to modify the original function as it is used in places where it needs to specifically read 64-bit values from dt (For e.g. dt_property_read_u64()). Xen prints warning when it detects truncation in cases where it is not able to return error. Also, replaced u32/u64 with uint32_t/uint64_t in the functions touched by the code changes. Signed-off-by: Ayan Kumar Halder Reviewed-by: Julien Grall Reviewed-by: Michal Orzel --- Changes from v1 - 1. Dropped "[XEN v1 2/9] xen/arm: Define translate_dt_address_size() for the translation between u64 and paddr_t" and "[XEN v1 4/9] xen/arm: Use translate_dt_address_size() to translate between device tree addr/size and paddr_t", instead this approach achieves the same purpose. 2. No need to check for truncation while converting values from u64 to paddr_t. v2 - 1. Use "( (dt_start >> (PADDR_SHIFT - 1)) > 1 )" to detect truncation. 2. Introduced libfdt_xen.h to implement fdt_get_mem_rsv_paddr 3. Logged error messages in case truncation is detected. v3 - 1. Renamed libfdt_xen.h to libfdt-xen.h. 2. Replaced u32/u64 with uint32_t/uint64_t 3. Use "(paddr_t)val != val" to check for truncation. 4. Removed the alias "#define PADDR_SHIFT PADDR_BITS". v4 - 1. Added a WARN() when truncation is detected. 2. Always check the return value of fdt_get_mem_rsv(). v5 - 1. Removed the initialization of variables in fdt_get_mem_rsv_paddr(). The warning has been fixed by checking "if (ret < 0)", similar to how it was being done for fdt_get_mem_rsv(). 2. Removed printing "Error:" before WARN(). 3. Added the note about implicit casting before dt_read_number() 4. Sanity fixes. v6 - 1. Added R-b. xen/arch/arm/bootfdt.c | 46 +++++++++++++++++++----- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/include/asm/setup.h | 4 +-- xen/arch/arm/setup.c | 14 ++++---- xen/arch/arm/smpboot.c | 2 +- xen/include/xen/device_tree.h | 27 ++++++++++++++ xen/include/xen/libfdt/libfdt-xen.h | 55 +++++++++++++++++++++++++++++ 7 files changed, 130 insertions(+), 20 deletions(-) create mode 100644 xen/include/xen/libfdt/libfdt-xen.h diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index e2f6c7324b..b6f92a174f 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,11 +52,37 @@ static bool __init device_tree_node_compatible(const void *fdt, int node, return false; } -void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, - u32 size_cells, u64 *start, u64 *size) +void __init device_tree_get_reg(const __be32 **cell, uint32_t address_cells, + uint32_t size_cells, paddr_t *start, + paddr_t *size) { - *start = dt_next_cell(address_cells, cell); - *size = dt_next_cell(size_cells, cell); + uint64_t dt_start, dt_size; + + /* + * dt_next_cell will return uint64_t whereas paddr_t may not be 64-bit. + * Thus, there is an implicit cast from uint64_t to paddr_t. + */ + dt_start = dt_next_cell(address_cells, cell); + dt_size = dt_next_cell(size_cells, cell); + + if ( dt_start != (paddr_t)dt_start ) + { + printk("Physical address greater than max width supported\n"); + WARN(); + } + + if ( dt_size != (paddr_t)dt_size ) + { + printk("Physical size greater than max width supported\n"); + WARN(); + } + + /* + * Xen will truncate the address/size if it is greater than the maximum + * supported width and it will give an appropriate warning. + */ + *start = dt_start; + *size = dt_size; } static int __init device_tree_get_meminfo(const void *fdt, int node, @@ -329,7 +355,7 @@ static int __init process_chosen_node(const void *fdt, int node, printk("linux,initrd-start property has invalid length %d\n", len); return -EINVAL; } - start = dt_read_number((void *)&prop->data, dt_size_to_cells(len)); + start = dt_read_paddr((void *)&prop->data, dt_size_to_cells(len)); prop = fdt_get_property(fdt, node, "linux,initrd-end", &len); if ( !prop ) @@ -342,7 +368,7 @@ static int __init process_chosen_node(const void *fdt, int node, printk("linux,initrd-end property has invalid length %d\n", len); return -EINVAL; } - end = dt_read_number((void *)&prop->data, dt_size_to_cells(len)); + end = dt_read_paddr((void *)&prop->data, dt_size_to_cells(len)); if ( start >= end ) { @@ -593,9 +619,11 @@ static void __init early_print_info(void) for ( i = 0; i < nr_rsvd; i++ ) { paddr_t s, e; - if ( fdt_get_mem_rsv(device_tree_flattened, i, &s, &e) < 0 ) + + if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &s, &e) < 0 ) continue; - /* fdt_get_mem_rsv returns length */ + + /* fdt_get_mem_rsv_paddr returns length */ e += s; printk(" RESVD[%u]: %"PRIpaddr" - %"PRIpaddr"\n", i, s, e); } diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e0ac5db60d..7bcd6a83f7 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -949,7 +949,7 @@ static int __init process_shm(struct domain *d, struct kernel_info *kinfo, BUG_ON(!prop); cells = (const __be32 *)prop->value; device_tree_get_reg(&cells, addr_cells, addr_cells, &pbase, &gbase); - psize = dt_read_number(cells, size_cells); + psize = dt_read_paddr(cells, size_cells); if ( !IS_ALIGNED(pbase, PAGE_SIZE) || !IS_ALIGNED(gbase, PAGE_SIZE) ) { printk("%pd: physical address 0x%"PRIpaddr", or guest address 0x%"PRIpaddr" is not suitably aligned.\n", diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h index 38e2ce255f..47ce565d87 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -159,8 +159,8 @@ const char *boot_module_kind_as_string(bootmodule_kind kind); extern uint32_t hyp_traps_vector[]; void init_traps(void); -void device_tree_get_reg(const __be32 **cell, u32 address_cells, - u32 size_cells, u64 *start, u64 *size); +void device_tree_get_reg(const __be32 **cell, uint32_t address_cells, + uint32_t size_cells, paddr_t *start, paddr_t *size); u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 6f9f4d8c8a..74b40e527f 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -222,11 +222,11 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e, { paddr_t r_s, r_e; - if ( fdt_get_mem_rsv(device_tree_flattened, i, &r_s, &r_e ) < 0 ) + if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &r_s, &r_e ) < 0 ) /* If we can't read it, pretend it doesn't exist... */ continue; - r_e += r_s; /* fdt_get_mem_rsv returns length */ + r_e += r_s; /* fdt_get_mem_rsv_paddr returns length */ if ( s < r_e && r_s < e ) { @@ -592,13 +592,13 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e, { paddr_t mod_s, mod_e; - if ( fdt_get_mem_rsv(device_tree_flattened, - i - mi->nr_mods, - &mod_s, &mod_e ) < 0 ) + if ( fdt_get_mem_rsv_paddr(device_tree_flattened, + i - mi->nr_mods, + &mod_s, &mod_e ) < 0 ) /* If we can't read it, pretend it doesn't exist... */ continue; - /* fdt_get_mem_rsv returns length */ + /* fdt_get_mem_rsv_paddr returns length */ mod_e += mod_s; if ( s < mod_e && mod_s < e ) diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 4a89b3a834..e107b86b7b 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -159,7 +159,7 @@ static void __init dt_smp_init_cpus(void) continue; } - addr = dt_read_number(prop, dt_n_addr_cells(cpu)); + addr = dt_read_paddr(prop, dt_n_addr_cells(cpu)); hwid = addr; if ( hwid != addr ) diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 19a74909ce..5f8f61aec8 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -241,6 +241,33 @@ static inline u64 dt_read_number(const __be32 *cell, int size) return r; } +/* Wrapper for dt_read_number() to return paddr_t (instead of uint64_t) */ +static inline paddr_t dt_read_paddr(const __be32 *cell, int size) +{ + uint64_t dt_r; + paddr_t r; + + /* + * dt_read_number will return uint64_t whereas paddr_t may not be 64-bit. + * Thus, there is an implicit cast from uint64_t to paddr_t. + */ + dt_r = dt_read_number(cell, size); + + if ( dt_r != (paddr_t)dt_r ) + { + printk("Physical address greater than max width supported\n"); + WARN(); + } + + /* + * Xen will truncate the address/size if it is greater than the maximum + * supported width and it will give an appropriate warning. + */ + r = dt_r; + + return r; +} + /* Helper to convert a number of cells to bytes */ static inline int dt_cells_to_size(int size) { diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h new file mode 100644 index 0000000000..a5340bc9f4 --- /dev/null +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * xen/include/xen/libfdt/libfdt-xen.h + * + * Wrapper functions for device tree. This helps to convert dt values + * between uint64_t and paddr_t. + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. All Rights Reserved. + */ + +#ifndef LIBFDT_XEN_H +#define LIBFDT_XEN_H + +#include + +static inline int fdt_get_mem_rsv_paddr(const void *fdt, int n, + paddr_t *address, + paddr_t *size) +{ + uint64_t dt_addr; + uint64_t dt_size; + int ret; + + ret = fdt_get_mem_rsv(fdt, n, &dt_addr, &dt_size); + if ( ret < 0 ) + return ret; + + if ( dt_addr != (paddr_t)dt_addr ) + { + printk("Error: Physical address greater than max width supported\n"); + return -FDT_ERR_MAX; + } + + if ( dt_size != (paddr_t)dt_size ) + { + printk("Error: Physical size greater than max width supported\n"); + return -FDT_ERR_MAX; + } + + *address = dt_addr; + *size = dt_size; + + return ret; +} + +#endif /* LIBFDT_XEN_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ From patchwork Thu May 18 14:39:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246911 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 C9238C7EE23 for ; Thu, 18 May 2023 14:40:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536399.834688 (Exim 4.92) (envelope-from ) id 1pzeo8-0000ne-JL; Thu, 18 May 2023 14:40:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536399.834688; Thu, 18 May 2023 14:40:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeo8-0000nX-Gf; Thu, 18 May 2023 14:40:44 +0000 Received: by outflank-mailman (input) for mailman id 536399; Thu, 18 May 2023 14:40:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeo6-0000Pw-Ts for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:40:43 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2061d.outbound.protection.outlook.com [2a01:111:f400:7eaa::61d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f5d7d34a-f589-11ed-b22c-6b7b168915f2; Thu, 18 May 2023 16:40:41 +0200 (CEST) Received: from MW4PR03CA0185.namprd03.prod.outlook.com (2603:10b6:303:b8::10) by CH2PR12MB4890.namprd12.prod.outlook.com (2603:10b6:610:63::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 14:40:35 +0000 Received: from CO1NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::26) by MW4PR03CA0185.outlook.office365.com (2603:10b6:303:b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:40:35 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT047.mail.protection.outlook.com (10.13.174.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:40:34 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:40:33 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:40:32 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:40:31 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f5d7d34a-f589-11ed-b22c-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MvWkuXgNPbtpKH2Gkd2ZJyIjskmVL09fkLWh5Cymxl4/43Xd7tElhhnP9g0qDZ9iE1Zxy4yo3rT/HuC3Cfs8K9EVeU1BmNgz3TTHlu7F/wFQq3kuZgmTI7qjB2VXHHnvPxr9FEutkAS05C47eqAyCWoAMNJA5ECzuch5OA7XthCgAITGC7a9Sm91wv5WHFutLlU3qQMXtBUr7Kpdb/yShnqugf5NvEfBlcAIvalSu0QL3pUEUFtxhSLDO9XtNJEpJe3neiEGEhJBLN5de1Dtehy7vVlOlf5yyXLrbBmuu4bc40fBuDKeIjVH7AiSuvr55/AiPBzFmsmxwGxtHfeL/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=/D5r9t1oiMhFvvPxy1K92f7LozAVsetKxtPVhdSX3ok=; b=WXyIHYEHoWxxMqJUxAnPoauyKFRlIIsMX3tcF1TUHetv8FzHFdV88z7VUHtk53Dok3RiIJPFWXVDh98gLeP4axrfa1vfPmryabu+gBzLZsNuRTORP5v5Kb+QNW+KY2HDQwe4EVDPBw6cGkpqO2UzBQxJpZEvtTMnjn1ACdbwXXiqo8uk/aqOY9kB5lTIXeqkC/9pX7iQM6t1LazsTQ8g5BVrapQgmjRrYOqmPkbTBXDtVYzefZ2Pk9YWHWjyX+ExiHpFso4ZDFMdEhjngrkwTb5vB0IZBYMdq8hIspyztW0WUKe5hZcdqMea2DlXmj+0urpeGAiez9lTceMyY169Eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=/D5r9t1oiMhFvvPxy1K92f7LozAVsetKxtPVhdSX3ok=; b=5dQCG+EaXmSaC0WtS+aLzRNpt6FUx0W9+GGpXQQZe+9t/o8TioTLokA21XHMGgtOWPyDYQWBNMw0KojTbwMjudXUiFm0eC4rSaxymKrrAhEJH6QeboatvhXuDtfW/Wx6xAp7YXf4nTR67IsH544+mmXqYBm27NTaWk1vgzW2ljg= X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 03/11] xen/arm: Introduce a wrapper for dt_device_get_address() to handle paddr_t Date: Thu, 18 May 2023 15:39:12 +0100 Message-ID: <20230518143920.43186-4-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT047:EE_|CH2PR12MB4890:EE_ X-MS-Office365-Filtering-Correlation-Id: f9d17b1f-6709-47fd-8dc5-08db57add6cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PFiDoQYP2q9przqJAZ+DalfZF6qpDfs0DBFJZJ0QqpHQoYOJfhDSY1XujaOMCRe4yTzpYkzz8Ofv4ns27VIo6wnxOb6dFA1CjVIASoar8GjBNOMozv5IcEVeULuJnAFbEAvqFdD6imwyLA9Neb3Mrrzw7GkdvC84L/9MiWPcUNlyuzWSaNWU9Wyu2eP3dEDO2HUJ5OyX57QfSo7uhxJIjJeuSsGaZrN00GlmeFXAIXYZLZXBx4rhBCiw8DGMbpL7LwCyE3Kh2A/yluOO+C1a4Qos2R5HEE/CmBpTysRaiG1/GWhwJ19mYL0SoaSTvXH9fEF8NFAVODLlLIFJGjDPopww0xle2cxZ9o7UQ1b1n/cv2ismhU0yptFFbWBw140hc43Rfj2YAzvA/j7wQ2zXKYWDOuLMoTuEINu8ewMxEyDUx5KFrK0r9y8GBk89LPOSTPQidDCgLQtgb+S/DCK1dtwD+WkszeAJtFpIf3v6b6zdjVcdhtRHSShEdm0dxN/9ZettuQ+4V56IweWXrsCPvrLRqCE5A9wLtiU9MELr/7KtmeTU19CJRPxVKbKYIPO2mx+aGZpJSeSwlvNyzb0EdfS5CZTSaIRRYlWMkYa4AX4oGvXdZyhfk+Bfc2ReAyxwM+U5N8WP0c4VgnNM8WazMhbsbAr8EPgAMykF53nIuaQY4exJtokFT5sUwTELxRGtWy9I1jLUXt8vIsYXVb/byAiomiv0eU00MWm/xcnQV4ZfIwa6B0JTQgbNQQUedf2o X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199021)(36840700001)(46966006)(40470700004)(86362001)(2616005)(336012)(426003)(4326008)(6666004)(26005)(1076003)(40480700001)(6916009)(70586007)(70206006)(316002)(40460700003)(36756003)(47076005)(81166007)(186003)(478600001)(8936002)(82310400005)(8676002)(54906003)(82740400003)(103116003)(2906002)(30864003)(356005)(7416002)(36860700001)(41300700001)(966005)(83380400001)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:40:34.6117 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9d17b1f-6709-47fd-8dc5-08db57add6cb 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4890 dt_device_get_address() can accept uint64_t only for address and size. However, the address/size denotes physical addresses. Thus, they should be represented by 'paddr_t'. Consequently, we introduce a wrapper for dt_device_get_address() ie dt_device_get_paddr() which accepts address/size as paddr_t and inturn invokes dt_device_get_address() after converting address/size to uint64_t. The reason for introducing this is that in future 'paddr_t' may not always be 64-bit. Thus, we need an explicit wrapper to do the type conversion and return an error in case of truncation. With this, callers can now invoke dt_device_get_paddr(). However, ns16550.c is left unchanged as it requires some prior cleanup. For details, see https://patchew.org/Xen/20230413173735.48387-1-ayan.kumar.halder@amd.com. This will be addressed in a subsequent series. Signed-off-by: Ayan Kumar Halder Reviewed-by: Michal Orzel Acked-by: Julien Grall --- Changes from - v1 - 1. New patch. v2 - 1. Extracted part of "[XEN v2 05/11] xen/arm: Use paddr_t instead of u64 for address/size" into this patch. 2. dt_device_get_address() callers now invoke dt_device_get_paddr() instead. 3. Logged error in case of truncation. v3 - 1. Modified the truncation checks as "dt_addr != (paddr_t)dt_addr". 2. Some sanity fixes. v4 - 1. Some sanity fixes. 2. Preserved the declaration of dt_device_get_address() in xen/include/xen/device_tree.h. The reason being it is currently used by ns16550.c. This driver requires some more changes as pointed by Jan in https://lore.kernel.org/xen-devel/6196e90f-752e-e61a-45ce-37e46c22b812@suse.com/ which is to be addressed as a separate series. v5 - 1. Removed initialization of variables. 2. In dt_device_get_paddr(), added the check if ( !addr ) return -EINVAL; v6 - 1. Added R-b and Ack. xen/arch/arm/domain_build.c | 10 +++--- xen/arch/arm/gic-v2.c | 10 +++--- xen/arch/arm/gic-v3-its.c | 4 +-- xen/arch/arm/gic-v3.c | 10 +++--- xen/arch/arm/pci/pci-host-common.c | 6 ++-- xen/arch/arm/platforms/brcm-raspberry-pi.c | 2 +- xen/arch/arm/platforms/brcm.c | 6 ++-- xen/arch/arm/platforms/exynos5.c | 32 +++++++++---------- xen/arch/arm/platforms/sunxi.c | 2 +- xen/arch/arm/platforms/xgene-storm.c | 2 +- xen/common/device_tree.c | 36 ++++++++++++++++++++++ xen/drivers/char/cadence-uart.c | 4 +-- xen/drivers/char/exynos4210-uart.c | 4 +-- xen/drivers/char/imx-lpuart.c | 4 +-- xen/drivers/char/meson-uart.c | 4 +-- xen/drivers/char/mvebu-uart.c | 4 +-- xen/drivers/char/omap-uart.c | 4 +-- xen/drivers/char/pl011.c | 6 ++-- xen/drivers/char/scif-uart.c | 4 +-- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 8 ++--- xen/drivers/passthrough/arm/smmu-v3.c | 2 +- xen/drivers/passthrough/arm/smmu.c | 8 ++--- xen/include/xen/device_tree.h | 13 ++++++++ 23 files changed, 117 insertions(+), 68 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 7bcd6a83f7..50b85ea783 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1698,13 +1698,13 @@ static int __init find_memory_holes(const struct kernel_info *kinfo, dt_for_each_device_node( dt_host, np ) { unsigned int naddr; - u64 addr, size; + paddr_t addr, size; naddr = dt_number_of_address(np); for ( i = 0; i < naddr; i++ ) { - res = dt_device_get_address(np, i, &addr, &size); + res = dt_device_get_paddr(np, i, &addr, &size); if ( res ) { printk(XENLOG_ERR "Unable to retrieve address %u for %s\n", @@ -2475,7 +2475,7 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev, unsigned int naddr; unsigned int i; int res; - u64 addr, size; + paddr_t addr, size; bool own_device = !dt_device_for_passthrough(dev); /* * We want to avoid mapping the MMIO in dom0 for the following cases: @@ -2530,7 +2530,7 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev, /* Give permission and map MMIOs */ for ( i = 0; i < naddr; i++ ) { - res = dt_device_get_address(dev, i, &addr, &size); + res = dt_device_get_paddr(dev, i, &addr, &size); if ( res ) { printk(XENLOG_ERR "Unable to retrieve address %u for %s\n", @@ -2961,7 +2961,7 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo, if ( res ) { printk(XENLOG_ERR "Unable to permit to dom%d access to" - " 0x%"PRIx64" - 0x%"PRIx64"\n", + " 0x%"PRIpaddr" - 0x%"PRIpaddr"\n", kinfo->d->domain_id, mstart & PAGE_MASK, PAGE_ALIGN(mstart + size) - 1); return res; diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 5d4d298b86..6476ff4230 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -993,7 +993,7 @@ static void gicv2_extension_dt_init(const struct dt_device_node *node) continue; /* Get register frame resource from DT. */ - if ( dt_device_get_address(v2m, 0, &addr, &size) ) + if ( dt_device_get_paddr(v2m, 0, &addr, &size) ) panic("GICv2: Cannot find a valid v2m frame address\n"); /* @@ -1018,19 +1018,19 @@ static void __init gicv2_dt_init(void) paddr_t vsize; const struct dt_device_node *node = gicv2_info.node; - res = dt_device_get_address(node, 0, &dbase, NULL); + res = dt_device_get_paddr(node, 0, &dbase, NULL); if ( res ) panic("GICv2: Cannot find a valid address for the distributor\n"); - res = dt_device_get_address(node, 1, &cbase, &csize); + res = dt_device_get_paddr(node, 1, &cbase, &csize); if ( res ) panic("GICv2: Cannot find a valid address for the CPU\n"); - res = dt_device_get_address(node, 2, &hbase, NULL); + res = dt_device_get_paddr(node, 2, &hbase, NULL); if ( res ) panic("GICv2: Cannot find a valid address for the hypervisor\n"); - res = dt_device_get_address(node, 3, &vbase, &vsize); + res = dt_device_get_paddr(node, 3, &vbase, &vsize); if ( res ) panic("GICv2: Cannot find a valid address for the virtual CPU\n"); diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index 1ec9934191..3aa4edda10 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -1004,12 +1004,12 @@ static void gicv3_its_dt_init(const struct dt_device_node *node) */ dt_for_each_child_node(node, its) { - uint64_t addr, size; + paddr_t addr, size; if ( !dt_device_is_compatible(its, "arm,gic-v3-its") ) continue; - if ( dt_device_get_address(its, 0, &addr, &size) ) + if ( dt_device_get_paddr(its, 0, &addr, &size) ) panic("GICv3: Cannot find a valid ITS frame address\n"); add_to_host_its_list(addr, size, its); diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index bb59ea94cd..4e6c98bada 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1377,7 +1377,7 @@ static void __init gicv3_dt_init(void) int res, i; const struct dt_device_node *node = gicv3_info.node; - res = dt_device_get_address(node, 0, &dbase, NULL); + res = dt_device_get_paddr(node, 0, &dbase, NULL); if ( res ) panic("GICv3: Cannot find a valid distributor address\n"); @@ -1393,9 +1393,9 @@ static void __init gicv3_dt_init(void) for ( i = 0; i < gicv3.rdist_count; i++ ) { - uint64_t rdist_base, rdist_size; + paddr_t rdist_base, rdist_size; - res = dt_device_get_address(node, 1 + i, &rdist_base, &rdist_size); + res = dt_device_get_paddr(node, 1 + i, &rdist_base, &rdist_size); if ( res ) panic("GICv3: No rdist base found for region %d\n", i); @@ -1417,10 +1417,10 @@ static void __init gicv3_dt_init(void) * For GICv3 supporting GICv2, GICC and GICV base address will be * provided. */ - res = dt_device_get_address(node, 1 + gicv3.rdist_count, + res = dt_device_get_paddr(node, 1 + gicv3.rdist_count, &cbase, &csize); if ( !res ) - dt_device_get_address(node, 1 + gicv3.rdist_count + 2, + dt_device_get_paddr(node, 1 + gicv3.rdist_count + 2, &vbase, &vsize); } diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c index 7474d877de..5dd62e8013 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -93,7 +93,7 @@ gen_pci_init(struct dt_device_node *dev, const struct pci_ecam_ops *ops) cfg_reg_idx = 0; /* Parse our PCI ecam register address */ - err = dt_device_get_address(dev, cfg_reg_idx, &addr, &size); + err = dt_device_get_paddr(dev, cfg_reg_idx, &addr, &size); if ( err ) goto err_exit; @@ -351,10 +351,10 @@ int __init pci_host_bridge_mappings(struct domain *d) for ( i = 0; i < dt_number_of_address(dev); i++ ) { - uint64_t addr, size; + paddr_t addr, size; int err; - err = dt_device_get_address(dev, i, &addr, &size); + err = dt_device_get_paddr(dev, i, &addr, &size); if ( err ) { printk(XENLOG_ERR diff --git a/xen/arch/arm/platforms/brcm-raspberry-pi.c b/xen/arch/arm/platforms/brcm-raspberry-pi.c index 811b40b1a6..407ec07f63 100644 --- a/xen/arch/arm/platforms/brcm-raspberry-pi.c +++ b/xen/arch/arm/platforms/brcm-raspberry-pi.c @@ -64,7 +64,7 @@ static void __iomem *rpi4_map_watchdog(void) if ( !node ) return NULL; - ret = dt_device_get_address(node, 0, &start, &len); + ret = dt_device_get_paddr(node, 0, &start, &len); if ( ret ) { printk("Cannot read watchdog register address\n"); diff --git a/xen/arch/arm/platforms/brcm.c b/xen/arch/arm/platforms/brcm.c index d481b2c60f..951e4d6cc3 100644 --- a/xen/arch/arm/platforms/brcm.c +++ b/xen/arch/arm/platforms/brcm.c @@ -40,7 +40,7 @@ static __init int brcm_get_dt_node(char *compat_str, u32 *reg_base) { const struct dt_device_node *node; - u64 reg_base_64; + paddr_t reg_base_paddr; int rc; node = dt_find_compatible_node(NULL, NULL, compat_str); @@ -50,7 +50,7 @@ static __init int brcm_get_dt_node(char *compat_str, return -ENOENT; } - rc = dt_device_get_address(node, 0, ®_base_64, NULL); + rc = dt_device_get_paddr(node, 0, ®_base_paddr, NULL); if ( rc ) { dprintk(XENLOG_ERR, "%s: missing \"reg\" prop\n", __func__); @@ -61,7 +61,7 @@ static __init int brcm_get_dt_node(char *compat_str, *dn = node; if ( reg_base ) - *reg_base = reg_base_64; + *reg_base = reg_base_paddr; return 0; } diff --git a/xen/arch/arm/platforms/exynos5.c b/xen/arch/arm/platforms/exynos5.c index 6560507092..c48093cd4f 100644 --- a/xen/arch/arm/platforms/exynos5.c +++ b/xen/arch/arm/platforms/exynos5.c @@ -42,8 +42,8 @@ static int exynos5_init_time(void) void __iomem *mct; int rc; struct dt_device_node *node; - u64 mct_base_addr; - u64 size; + paddr_t mct_base_addr; + paddr_t size; node = dt_find_compatible_node(NULL, NULL, "samsung,exynos4210-mct"); if ( !node ) @@ -52,14 +52,14 @@ static int exynos5_init_time(void) return -ENXIO; } - rc = dt_device_get_address(node, 0, &mct_base_addr, &size); + rc = dt_device_get_paddr(node, 0, &mct_base_addr, &size); if ( rc ) { dprintk(XENLOG_ERR, "Error in \"samsung,exynos4210-mct\"\n"); return -ENXIO; } - dprintk(XENLOG_INFO, "mct_base_addr: %016llx size: %016llx\n", + dprintk(XENLOG_INFO, "mct_base_addr: 0x%"PRIpaddr" size: 0x%"PRIpaddr"\n", mct_base_addr, size); mct = ioremap_nocache(mct_base_addr, size); @@ -97,9 +97,9 @@ static int __init exynos5_smp_init(void) struct dt_device_node *node; void __iomem *sysram; char *compatible; - u64 sysram_addr; - u64 size; - u64 sysram_offset; + paddr_t sysram_addr; + paddr_t size; + paddr_t sysram_offset; int rc; node = dt_find_compatible_node(NULL, NULL, "samsung,secure-firmware"); @@ -125,13 +125,13 @@ static int __init exynos5_smp_init(void) return -ENXIO; } - rc = dt_device_get_address(node, 0, &sysram_addr, &size); + rc = dt_device_get_paddr(node, 0, &sysram_addr, &size); if ( rc ) { dprintk(XENLOG_ERR, "Error in %s\n", compatible); return -ENXIO; } - dprintk(XENLOG_INFO, "sysram_addr: %016llx size: %016llx offset: %016llx\n", + dprintk(XENLOG_INFO,"sysram_addr: 0x%"PRIpaddr" size: 0x%"PRIpaddr"offset: 0x%"PRIpaddr"\n", sysram_addr, size, sysram_offset); sysram = ioremap_nocache(sysram_addr, size); @@ -189,7 +189,7 @@ static int exynos5_cpu_power_up(void __iomem *power, int cpu) return 0; } -static int exynos5_get_pmu_baseandsize(u64 *power_base_addr, u64 *size) +static int exynos5_get_pmu_baseandsize(paddr_t *power_base_addr, paddr_t *size) { struct dt_device_node *node; int rc; @@ -208,14 +208,14 @@ static int exynos5_get_pmu_baseandsize(u64 *power_base_addr, u64 *size) return -ENXIO; } - rc = dt_device_get_address(node, 0, power_base_addr, size); + rc = dt_device_get_paddr(node, 0, power_base_addr, size); if ( rc ) { dprintk(XENLOG_ERR, "Error in \"samsung,exynos5XXX-pmu\"\n"); return -ENXIO; } - dprintk(XENLOG_DEBUG, "power_base_addr: %016llx size: %016llx\n", + dprintk(XENLOG_DEBUG, "power_base_addr: 0x%"PRIpaddr" size: 0x%"PRIpaddr"\n", *power_base_addr, *size); return 0; @@ -223,8 +223,8 @@ static int exynos5_get_pmu_baseandsize(u64 *power_base_addr, u64 *size) static int exynos5_cpu_up(int cpu) { - u64 power_base_addr; - u64 size; + paddr_t power_base_addr; + paddr_t size; void __iomem *power; int rc; @@ -256,8 +256,8 @@ static int exynos5_cpu_up(int cpu) static void exynos5_reset(void) { - u64 power_base_addr; - u64 size; + paddr_t power_base_addr; + paddr_t size; void __iomem *pmu; int rc; diff --git a/xen/arch/arm/platforms/sunxi.c b/xen/arch/arm/platforms/sunxi.c index e8e4d88bef..2b2c215f20 100644 --- a/xen/arch/arm/platforms/sunxi.c +++ b/xen/arch/arm/platforms/sunxi.c @@ -50,7 +50,7 @@ static void __iomem *sunxi_map_watchdog(bool *new_wdt) return NULL; } - ret = dt_device_get_address(node, 0, &wdt_start, &wdt_len); + ret = dt_device_get_paddr(node, 0, &wdt_start, &wdt_len); if ( ret ) { dprintk(XENLOG_ERR, "Cannot read watchdog register address\n"); diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c index befd0c3c2d..6fc2f9679e 100644 --- a/xen/arch/arm/platforms/xgene-storm.c +++ b/xen/arch/arm/platforms/xgene-storm.c @@ -50,7 +50,7 @@ static void __init xgene_check_pirq_eoi(void) if ( !node ) panic("%s: Can not find interrupt controller node\n", __func__); - res = dt_device_get_address(node, 0, &dbase, NULL); + res = dt_device_get_paddr(node, 0, &dbase, NULL); if ( res ) panic("%s: Cannot find a valid address for the distributor\n", __func__); diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 6c9712ab7b..20bc369367 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -955,6 +955,42 @@ int dt_device_get_address(const struct dt_device_node *dev, unsigned int index, return 0; } +int dt_device_get_paddr(const struct dt_device_node *dev, unsigned int index, + paddr_t *addr, paddr_t *size) +{ + uint64_t dt_addr, dt_size; + int ret; + + ret = dt_device_get_address(dev, index, &dt_addr, &dt_size); + if ( ret ) + return ret; + + if ( !addr ) + return -EINVAL; + + if ( dt_addr != (paddr_t)dt_addr ) + { + printk("Error: Physical address 0x%"PRIx64" for node=%s is greater than max width (%zu bytes) supported\n", + dt_addr, dev->name, sizeof(paddr_t)); + return -ERANGE; + } + + *addr = dt_addr; + + if ( size ) + { + if ( dt_size != (paddr_t)dt_size ) + { + printk("Error: Physical size 0x%"PRIx64" for node=%s is greater than max width (%zu bytes) supported\n", + dt_size, dev->name, sizeof(paddr_t)); + return -ERANGE; + } + + *size = dt_size; + } + + return ret; +} int dt_for_each_range(const struct dt_device_node *dev, int (*cb)(const struct dt_device_node *, diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c index 22905ba66c..c38d7ed143 100644 --- a/xen/drivers/char/cadence-uart.c +++ b/xen/drivers/char/cadence-uart.c @@ -158,14 +158,14 @@ static int __init cuart_init(struct dt_device_node *dev, const void *data) const char *config = data; struct cuart *uart; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) printk("WARNING: UART configuration is not supported\n"); uart = &cuart_com; - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("cadence: Unable to retrieve the base" diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c index 43aaf02e18..2503392ccd 100644 --- a/xen/drivers/char/exynos4210-uart.c +++ b/xen/drivers/char/exynos4210-uart.c @@ -303,7 +303,7 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev, const char *config = data; struct exynos4210_uart *uart; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) printk("WARNING: UART configuration is not supported\n"); @@ -316,7 +316,7 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev, uart->parity = PARITY_NONE; uart->stop_bits = 1; - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("exynos4210: Unable to retrieve the base" diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c index 9c1f3b71a3..77f70c2719 100644 --- a/xen/drivers/char/imx-lpuart.c +++ b/xen/drivers/char/imx-lpuart.c @@ -204,7 +204,7 @@ static int __init imx_lpuart_init(struct dt_device_node *dev, const char *config = data; struct imx_lpuart *uart; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) printk("WARNING: UART configuration is not supported\n"); @@ -216,7 +216,7 @@ static int __init imx_lpuart_init(struct dt_device_node *dev, uart->parity = 0; uart->stop_bits = 1; - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("imx8-lpuart: Unable to retrieve the base" diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c index b1e25e0468..c627328122 100644 --- a/xen/drivers/char/meson-uart.c +++ b/xen/drivers/char/meson-uart.c @@ -209,14 +209,14 @@ static int __init meson_uart_init(struct dt_device_node *dev, const void *data) const char *config = data; struct meson_uart *uart; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) printk("WARNING: UART configuration is not supported\n"); uart = &meson_com; - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("meson: Unable to retrieve the base address of the UART\n"); diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c index a00618b96f..cc55173513 100644 --- a/xen/drivers/char/mvebu-uart.c +++ b/xen/drivers/char/mvebu-uart.c @@ -231,14 +231,14 @@ static int __init mvebu_uart_init(struct dt_device_node *dev, const void *data) const char *config = data; struct mvebu3700_uart *uart; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) printk("WARNING: UART configuration is not supported\n"); uart = &mvebu3700_com; - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("mvebu3700: Unable to retrieve the base address of the UART\n"); diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c index d6a5d59aa2..8e643cb039 100644 --- a/xen/drivers/char/omap-uart.c +++ b/xen/drivers/char/omap-uart.c @@ -324,7 +324,7 @@ static int __init omap_uart_init(struct dt_device_node *dev, struct omap_uart *uart; u32 clkspec; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) printk("WARNING: UART configuration is not supported\n"); @@ -344,7 +344,7 @@ static int __init omap_uart_init(struct dt_device_node *dev, uart->parity = UART_PARITY_NONE; uart->stop_bits = 1; - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("omap-uart: Unable to retrieve the base" diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c index be67242bc0..052a651251 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -222,7 +222,7 @@ static struct uart_driver __read_mostly pl011_driver = { .vuart_info = pl011_vuart, }; -static int __init pl011_uart_init(int irq, u64 addr, u64 size, bool sbsa) +static int __init pl011_uart_init(int irq, paddr_t addr, paddr_t size, bool sbsa) { struct pl011 *uart; @@ -258,14 +258,14 @@ static int __init pl011_dt_uart_init(struct dt_device_node *dev, { const char *config = data; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) { printk("WARNING: UART configuration is not supported\n"); } - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("pl011: Unable to retrieve the base" diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c index 2fccafe340..1b28ba90e9 100644 --- a/xen/drivers/char/scif-uart.c +++ b/xen/drivers/char/scif-uart.c @@ -311,14 +311,14 @@ static int __init scif_uart_init(struct dt_device_node *dev, const char *config = data; struct scif_uart *uart; int res; - u64 addr, size; + paddr_t addr, size; if ( strcmp(config, "") ) printk("WARNING: UART configuration is not supported\n"); uart = &scif_com; - res = dt_device_get_address(dev, 0, &addr, &size); + res = dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { printk("scif-uart: Unable to retrieve the base" diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthrough/arm/ipmmu-vmsa.c index 091f09b217..611d9eeba5 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -794,7 +794,7 @@ static void ipmmu_device_reset(struct ipmmu_vmsa_device *mmu) static __init bool ipmmu_stage2_supported(void) { struct dt_device_node *np; - uint64_t addr, size; + paddr_t addr, size; void __iomem *base; uint32_t product, cut; bool stage2_supported = false; @@ -806,7 +806,7 @@ static __init bool ipmmu_stage2_supported(void) return false; } - if ( dt_device_get_address(np, 0, &addr, &size) ) + if ( dt_device_get_paddr(np, 0, &addr, &size) ) { printk(XENLOG_ERR "ipmmu: Failed to get PRR MMIO\n"); return false; @@ -884,7 +884,7 @@ static int ipmmu_probe(struct dt_device_node *node) { const struct dt_device_match *match; struct ipmmu_vmsa_device *mmu; - uint64_t addr, size; + paddr_t addr, size; uint32_t reg; int irq, ret; @@ -905,7 +905,7 @@ static int ipmmu_probe(struct dt_device_node *node) bitmap_zero(mmu->ctx, IPMMU_CTX_MAX); /* Map I/O memory and request IRQ. */ - ret = dt_device_get_address(node, 0, &addr, &size); + ret = dt_device_get_paddr(node, 0, &addr, &size); if ( ret ) { dev_err(&node->dev, "Failed to get MMIO\n"); diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c index 4ca55d400a..720aa69ff2 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -2428,7 +2428,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) } /* Base address */ - ret = dt_device_get_address(np, 0, &ioaddr, &iosize); + ret = dt_device_get_paddr(np, 0, &ioaddr, &iosize); if (ret) goto out_free_smmu; diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 0a514821b3..79281075ba 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -73,8 +73,8 @@ /* Xen: Helpers to get device MMIO and IRQs */ struct resource { - u64 addr; - u64 size; + paddr_t addr; + paddr_t size; unsigned int type; }; @@ -101,7 +101,7 @@ static struct resource *platform_get_resource(struct platform_device *pdev, switch (type) { case IORESOURCE_MEM: - ret = dt_device_get_address(pdev, num, &res.addr, &res.size); + ret = dt_device_get_paddr(pdev, num, &res.addr, &res.size); return ((ret) ? NULL : &res); @@ -169,7 +169,7 @@ static void __iomem *devm_ioremap_resource(struct device *dev, ptr = ioremap_nocache(res->addr, res->size); if (!ptr) { dev_err(dev, - "ioremap failed (addr 0x%"PRIx64" size 0x%"PRIx64")\n", + "ioremap failed (addr 0x%"PRIpaddr" size 0x%"PRIpaddr")\n", res->addr, res->size); return ERR_PTR(-ENOMEM); } diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 5f8f61aec8..d514c486a8 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -585,6 +585,19 @@ int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, */ const struct dt_device_node *dt_get_parent(const struct dt_device_node *node); +/** + * dt_device_get_paddr - Resolve an address for a device + * @device: the device whose address is to be resolved + * @index: index of the address to resolve + * @addr: address filled by this function + * @size: size filled by this function + * + * This function resolves an address, walking the tree, for a given + * device-tree node. It returns 0 on success. + */ +int dt_device_get_paddr(const struct dt_device_node *dev, unsigned int index, + paddr_t *addr, paddr_t *size); + /** * dt_device_get_address - Resolve an address for a device * @device: the device whose address is to be resolved From patchwork Thu May 18 14:39:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246912 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 2E96EC7EE2A for ; Thu, 18 May 2023 14:41:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536401.834698 (Exim 4.92) (envelope-from ) id 1pzeoH-0001Bh-W9; Thu, 18 May 2023 14:40:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536401.834698; Thu, 18 May 2023 14:40:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeoH-0001Ba-SV; Thu, 18 May 2023 14:40:53 +0000 Received: by outflank-mailman (input) for mailman id 536401; Thu, 18 May 2023 14:40:52 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeoG-00074K-Ox for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:40:52 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20628.outbound.protection.outlook.com [2a01:111:f400:7eab::628]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fb41bd51-f589-11ed-8611-37d641c3527e; Thu, 18 May 2023 16:40:50 +0200 (CEST) Received: from MW4PR04CA0318.namprd04.prod.outlook.com (2603:10b6:303:82::23) by SJ2PR12MB9209.namprd12.prod.outlook.com (2603:10b6:a03:558::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 14:40:46 +0000 Received: from CO1NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::1) by MW4PR04CA0318.outlook.office365.com (2603:10b6:303:82::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:40:46 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT026.mail.protection.outlook.com (10.13.175.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:40:45 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:40:42 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:40:42 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:40:41 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fb41bd51-f589-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TlmwmNq3D7cLBLdPDzjc9NkISAWvS8oY2BzZMBbutii01/nT/hxFjIzRlo8WpBvobHoPTc2uudmxFK67rpxnansMHlzx7LcFLi42Qrc0SHSkoWWrN+dzHjg6tPQHSlO09lMJDHqjzzM9pDKvFfxIrU4Zi5BhKUhd56/M1Lk4PsxjWQBiqIOuRNFxaOas1dLHiaUOdFUsx5EAg8ZHYWRKNKZ4DUx3lPSRd+LHWWYaNiATLYACTs2t8WWTx6or7O+GcxMAnZo46Xh2Gi6FJNs5U+UCcxkVWlejkQ6PYK/1M6iEyGI+5sWVV/7PECB+SX11MLYtmEBnS78piLNxNZ/o/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=EAgb1ysrPbUg0InpEjefR449H1nWxGwdPTeZHCYsBak=; b=KKA6e+1ubKQyK1olEGEKD6P6BJTL2SoS0UztOxQFygdkvfZ2ZThlQe/tCgBVvRpeTNu5LeH+7peaqUnC93wCIbWtg4AgULpafuQBq2jw/GiHXpDu08v2/6I5/TI3RZFQ4sfZ66+eQZ2QKlvV/gn/DDkeGsv7PsaPsI90m7HC1AuWLqXHIDkQyUfZPDcVBEPk9u9JVi1jF9ktck5z+uOE77bvp4Ue5Os/qQzMSYpstKws4w0cPk2PmrSI1Ow4gIghiSABxmK84KUT/vPocO9UakMuzcZaEDA6DwMMRV2KheqivHvDZ7sYtpYyqJ/X/xpy5O+bjO2wnuQYxYd7LrGB7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=temperror action=none header.from=amd.com; dkim=none (message not signed); 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=EAgb1ysrPbUg0InpEjefR449H1nWxGwdPTeZHCYsBak=; b=2sHMdsD53eCq5+6Y8pcMcBY2s2rZG9VliEa7xNTLE7wKFVtB3mDau/nJZQ8J9QWI1HELxgeM345X1aggLSVS71NK/T3LPDwZGlTCtrhZ9HErWsXzFQkwK2iJaeyc9ky37Js8UcrxHYKxAXB9sSOY2+gXId9gEhADmFb71vse8XE= X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 04/11] xen/arm: smmu: Use writeq_relaxed_non_atomic() for writing to SMMU_CBn_TTBR0 Date: Thu, 18 May 2023 15:39:13 +0100 Message-ID: <20230518143920.43186-5-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT026:EE_|SJ2PR12MB9209:EE_ X-MS-Office365-Filtering-Correlation-Id: bd4570f7-76c0-488d-9dc1-08db57addd82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 327SBPcJ42XIc8xHyjXzwvanvvWZ22qoP2EY7wt80BgGAf/iOzdXrXtZDeRJbDB3zjgOCGvRwraaBVrWsWp8/lKc0noJsByNxQWsCmWiuguS9DenoTBQSvhfmGszbYlnZtfPRovaX8bOGkKl9SrwARixAdzznlNGdKKZ2HFR/HtNNRviRgFL5/IDZrwLi1B2KtA3h2z7gHC+IEgIY9yWouUmkOSbc8MH3XbtbEVSbpycrRrDYMVNueWl5bHrKG2HcCokb/loVEP1ANNHpklQhDJwVd5ovNd22lJdY2DPKPeAVhizaB8/to5FAKqwvP0kkT2Q5oFOM2PnuC4L4J7Ji6WYwdZ8/KWMKg/FLPFWgIzVfyjdEPRwUmV0jombx5rltIGEmY5MXcIaQMkcGAuw1b3T4wG+UBxBTDZKP0WkV4nFNW0vz8/3Ts2BRjtHa7mmeqvEb+rOyVsMKfnTpRwNpc/vNZPSmo9ZFP2QUDbSFuUpnFkPDKcsNAGBO87nVPLEjkDY/zmhmEBlxHXNZUiKI8nndUdx/ql2XlmcaerkW3BPfElpT6SNgkSoBZov3mth34pTI0r2WTVMPr1qWI0FqXwFEvuQsKinI5bLF9kMTLwizqJWksKxwVRa6mM37DY/OnsL8EWG3EUnd0yZ6pC76VX4QlBdRKYpGRpgOUylUVr9hUsCcvWx2/yVqs5Y+erjXyOmcVsT7WY4jYmZP0kcccd+AGVdzZTUr8+G6vcK0kLejEMU2KFJ4CYQT2/+es6YiDKjrx8ZeDkudz0OEXyJuA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(39860400002)(396003)(376002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(316002)(70206006)(70586007)(478600001)(4326008)(54906003)(6916009)(36756003)(103116003)(63350400001)(83380400001)(63370400001)(47076005)(1076003)(426003)(36860700001)(186003)(26005)(2616005)(86362001)(2906002)(5660300002)(8936002)(8676002)(82310400005)(336012)(6666004)(40480700001)(7416002)(356005)(81166007)(41300700001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:40:45.8778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd4570f7-76c0-488d-9dc1-08db57addd82 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9209 Refer ARM IHI 0062D.c ID070116 (SMMU 2.0 spec), 17-360, 17.3.9, SMMU_CBn_TTBR0 is a 64 bit register. Thus, one can use writeq_relaxed_non_atomic() to write to it instead of invoking writel_relaxed() twice for lower half and upper half of the register. This also helps us as p2maddr is 'paddr_t' (which may be u32 in future). Thus, one can assign p2maddr to a 64 bit register and do the bit manipulations on it, to generate the value for SMMU_CBn_TTBR0. Signed-off-by: Ayan Kumar Halder Reviewed-by: Stefano Stabellini Reviewed-by: Michal Orzel Reviewed-by: Rahul Singh --- Changes from - v1 - 1. Extracted the patch from "[XEN v1 8/9] xen/arm: Other adaptations required to support 32bit paddr". Use writeq_relaxed_non_atomic() to write u64 register in a non-atomic fashion. v2 - 1. Added R-b. v3 - 1. No changes. v4 - 1. Reordered the R-b. No further changes. (This patch can be committed independent of the series). v5 - Used 'uint64_t' instead of u64. As the change looked trivial to me, I retained the R-b. v6 - Added R-b. xen/drivers/passthrough/arm/smmu.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 79281075ba..c37fa9af13 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -499,8 +499,7 @@ enum arm_smmu_s2cr_privcfg { #define ARM_SMMU_CB_SCTLR 0x0 #define ARM_SMMU_CB_RESUME 0x8 #define ARM_SMMU_CB_TTBCR2 0x10 -#define ARM_SMMU_CB_TTBR0_LO 0x20 -#define ARM_SMMU_CB_TTBR0_HI 0x24 +#define ARM_SMMU_CB_TTBR0 0x20 #define ARM_SMMU_CB_TTBCR 0x30 #define ARM_SMMU_CB_S1_MAIR0 0x38 #define ARM_SMMU_CB_FSR 0x58 @@ -1083,6 +1082,7 @@ static void arm_smmu_flush_pgtable(struct arm_smmu_device *smmu, void *addr, static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain) { u32 reg; + uint64_t reg64; bool stage1; struct arm_smmu_cfg *cfg = &smmu_domain->cfg; struct arm_smmu_device *smmu = smmu_domain->smmu; @@ -1177,12 +1177,13 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain) dev_notice(smmu->dev, "d%u: p2maddr 0x%"PRIpaddr"\n", smmu_domain->cfg.domain->domain_id, p2maddr); - reg = (p2maddr & ((1ULL << 32) - 1)); - writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBR0_LO); - reg = (p2maddr >> 32); + reg64 = p2maddr; + if (stage1) - reg |= ARM_SMMU_CB_ASID(cfg) << TTBRn_HI_ASID_SHIFT; - writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBR0_HI); + reg64 |= (((uint64_t) (ARM_SMMU_CB_ASID(cfg) << TTBRn_HI_ASID_SHIFT)) + << 32); + + writeq_relaxed_non_atomic(reg64, cb_base + ARM_SMMU_CB_TTBR0); /* * TTBCR From patchwork Thu May 18 14:39:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246913 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 5F01DC7EE23 for ; Thu, 18 May 2023 14:41:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536403.834708 (Exim 4.92) (envelope-from ) id 1pzeoR-0001ka-A4; Thu, 18 May 2023 14:41:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536403.834708; Thu, 18 May 2023 14:41:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeoR-0001kT-64; Thu, 18 May 2023 14:41:03 +0000 Received: by outflank-mailman (input) for mailman id 536403; Thu, 18 May 2023 14:41:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeoQ-0000Pw-1B for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:41:02 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20622.outbound.protection.outlook.com [2a01:111:f400:7e83::622]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 01770aa1-f58a-11ed-b22c-6b7b168915f2; Thu, 18 May 2023 16:41:01 +0200 (CEST) Received: from BN9PR03CA0178.namprd03.prod.outlook.com (2603:10b6:408:f4::33) by CH0PR12MB5387.namprd12.prod.outlook.com (2603:10b6:610:d6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Thu, 18 May 2023 14:40:57 +0000 Received: from BN8NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::f6) by BN9PR03CA0178.outlook.office365.com (2603:10b6:408:f4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:40:57 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT092.mail.protection.outlook.com (10.13.176.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:40:57 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:40:56 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:40:56 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:40:54 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 01770aa1-f58a-11ed-b22c-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gJzO8xv45zn9w1Dkr6iS3sdn+uUGIm0t3eT8Y99//7eksGU4+5ND2qXPc0gRrb4OwJ6jS4JMp93Z1i8RkmMrt87qdrblGMBbP6LJm0pW0z+l6R7+JXmWyDGBJCUgEM3TRGszwdv0eKtgSYWrPcBDLQ8J/qxMNZTBEA70nOAKXQP3D2rkqNXCIXTYsnuLYzSslSlgnvq+W3jyQpc9ATrBqgSHYX43RfoALa0hXO+98MUdl7QWrG+M/62MXWDPq0jn3vi66NLz0Ptq7IKnm37iAVmLwrHEQNFgQmAukcJhJe9FKHvoxjwPCQX9oyur4iWc8TMFOnincM6CHqtEUrFtGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=dIbGtyu/gWerwDuQ2gvCU+RRCAtN1+d/wfgGFegCZv8=; b=b52H8s8t5TiuEfTjY1BYae43ctiUlp5SrDAghP7Ch5lU5qRAxXZvo315DTaQ/OmE96vBx9DO2+5Jm+R1GUS2IAm82ct9aJXb1TOenhUG/w518yyEbpulMzbyl5+lYNZcKzx38sFYrHYC+Xm2o5jbkRBJdnSI2/dLUt5PaaeMSWs2juLy6vxetn+srTreohqXk4oFgfTIuv/0KpkhFHinvwsEKlrpQJDpB3j3Bh5/UYVF05fJg8aVUVHqkfvnQLPKoh1DM+Q4OetQbUeGAlTkYsuTo9qCW4LKkpaShuvHsxxxi38VNwCYsJ5AGaY5W9S4AG+RTPAnO8Io15qUG0n0Cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=dIbGtyu/gWerwDuQ2gvCU+RRCAtN1+d/wfgGFegCZv8=; b=3PcfitGTM7m6Qvsh/k33vn7y/9jZIWX+YmiNxh+R4bztP2zKWlw9w66fA/sBoeaLq1gGMrVYIXzvmNv1jrFBITkRtcRDrMPT/nSMIptpeWwEUms7vhdpfvgTonh5SXlLjimCbLHB7hm0tGylvT5tCGYSi9qesfemifJgaUdtS+I= X-MS-Exchange-Authentication-Results: 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=SATLEXMB03.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 05/11] xen/arm: domain_build: Check if the address fits the range of physical address Date: Thu, 18 May 2023 15:39:14 +0100 Message-ID: <20230518143920.43186-6-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT092:EE_|CH0PR12MB5387:EE_ X-MS-Office365-Filtering-Correlation-Id: bbfb26b1-c771-4668-1066-08db57ade439 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a0K+eRmx4ZJrhgGkrSsAthQy62mld0TL3pwTK+ORsIN/pwZxnZp5B8e40sTSJ1dBEpKORAMPaeoDGJ4Pan5AYrd09u5h9oUDkVKSHzNhJsWyZ0NcMKa10krwL3tMdHtgZTD8RzKRK4Uxa+na8sRJBAvAEFhNbhnoKs/csyUuh/p8h8kA251l4D+IGmOmE3UuugPK6znsc2RgNDtUGJdBKmyCdrSzxCvqbPf7Fry/edZ+YP5Yib+8vUoC6HXheCc+8+GRk/PqjXI7P4Qi6niGH79suI9wVj+ahSzkJE5HQESIKHzWSQMWuhfVNTK6ZcKVck2nS0DM8OcxYH6fNRvwVI7Hb3eBFSC1IQ3DE001MISSulKJQq9sjw8+ZCltvZ8968UzqtS4kXyCHe6TSCgvjfN/dQ7N6XpKysHY21OnVVA0OLtstkaea/NCszfZHXJ8fTWpS49p5cFRuQltFW0O/JeUykEBfDcTja4ThSXFdlvw9pJy1YnFEifpEmjAr3Gfg/wlVI1hF60T4Sk/Y+X7ZaaHTMmvHnt7bnct/mdP+tXZXIsOeK4KhS/7lFoVv2S9wuf5kUaen8kN8WXqIywPWYq3cLYn9WVhTeQEmOVSa2qsOgekLDbtYFGDlVgg7Tzauk14SFe58o08NFd03SI93LP50QZVH+MeZjmP1ol/+BeEdArGltr/d1UPfJTilrrIznD66Jx9KKDCd4wUaJ1y6iVpENh7xY1EZgs1qAEF+m1zDQSwc+u3LE8MDDNCydfgby/++LMIwJ+cucXqhjwk1g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199021)(46966006)(36840700001)(40470700004)(26005)(40460700003)(1076003)(36860700001)(36756003)(83380400001)(47076005)(40480700001)(426003)(336012)(86362001)(82310400005)(2616005)(103116003)(356005)(81166007)(82740400003)(186003)(54906003)(7416002)(478600001)(2906002)(316002)(8936002)(6916009)(4326008)(8676002)(41300700001)(5660300002)(70586007)(70206006)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:40:57.2492 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbfb26b1-c771-4668-1066-08db57ade439 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5387 handle_pci_range() and map_range_to_domain() take addr and len as uint64_t parameters. Then frame numbers are obtained from addr and len by right shifting with PAGE_SHIFT. The frame numbers are expressed using unsigned long. Now if 64-bit >> PAGE_SHIFT, the result will have 52-bits as valid. On a 32-bit system, 'unsigned long' is 32-bits. Thus, there is a potential loss of value when the result is stored as 'unsigned long'. To mitigate this issue, we check if the starting and end address can be contained within the range of physical address supported on the system. If not, then an appropriate error is returned. Signed-off-by: Ayan Kumar Halder Reviewed-by: Julien Grall Reviewed-by: Michal Orzel --- Changes from :- v1...v4 - NA. New patch introduced in v5. v5 - 1. Updated the error message 2. Used "(((paddr_t)~0 - addr) < len)" to check the limit on len. 3. Changes in the prototype of "map_range_to_domain()" has been addressed by the patch 8. v6 - Trivial changes. Added R-b. xen/arch/arm/domain_build.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 50b85ea783..cb23f531a8 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1643,6 +1643,13 @@ static int __init handle_pci_range(const struct dt_device_node *dev, paddr_t start, end; int res; + if ( (addr != (paddr_t)addr) || (((paddr_t)~0 - addr) < len) ) + { + printk(XENLOG_ERR "%s: [0x%"PRIx64", 0x%"PRIx64"] exceeds the maximum allowed PA width (%u bits)", + dt_node_full_name(dev), addr, (addr + len), PADDR_BITS); + return -ERANGE; + } + start = addr & PAGE_MASK; end = PAGE_ALIGN(addr + len); res = rangeset_remove_range(mem_holes, PFN_DOWN(start), PFN_DOWN(end - 1)); @@ -2333,6 +2340,13 @@ int __init map_range_to_domain(const struct dt_device_node *dev, struct domain *d = mr_data->d; int res; + if ( (addr != (paddr_t)addr) || (((paddr_t)~0 - addr) < len) ) + { + printk(XENLOG_ERR "%s: [0x%"PRIx64", 0x%"PRIx64"] exceeds the maximum allowed PA width (%u bits)", + dt_node_full_name(dev), addr, (addr + len), PADDR_BITS); + return -ERANGE; + } + /* * reserved-memory regions are RAM carved out for a special purpose. * They are not MMIO and therefore a domain should not be able to From patchwork Thu May 18 14:39:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246914 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 EFA7AC77B7D for ; Thu, 18 May 2023 14:41:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536406.834717 (Exim 4.92) (envelope-from ) id 1pzeoW-00028V-I0; Thu, 18 May 2023 14:41:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536406.834717; Thu, 18 May 2023 14:41:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeoW-00028O-F1; Thu, 18 May 2023 14:41:08 +0000 Received: by outflank-mailman (input) for mailman id 536406; Thu, 18 May 2023 14:41:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeoU-00074K-K6 for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:41:06 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20625.outbound.protection.outlook.com [2a01:111:f400:7e83::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 03ad2234-f58a-11ed-8611-37d641c3527e; Thu, 18 May 2023 16:41:04 +0200 (CEST) Received: from MW4PR02CA0022.namprd02.prod.outlook.com (2603:10b6:303:16d::15) by SA1PR12MB7037.namprd12.prod.outlook.com (2603:10b6:806:24c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Thu, 18 May 2023 14:41:01 +0000 Received: from CO1NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::4a) by MW4PR02CA0022.outlook.office365.com (2603:10b6:303:16d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:41:01 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT004.mail.protection.outlook.com (10.13.175.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.20 via Frontend Transport; Thu, 18 May 2023 14:41:00 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:41:00 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:40:58 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 03ad2234-f58a-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aS+z61dIEOh9wHoYQV5HXZhDJBTlh4TPoLbW+9gdcSiLp3XAhVn/tBxddyrVUTKUk4yq1AT/ovHB07PoVgvS99vV47y8G2dE7XfGsIhT7sUrLEMOSx+AA/YhLt/XirD4t8e1qEKICwLqEP0nUj4+voZ3vjdR/jOxiR64NEJV89nmJlN4bV3Wd3XbBLUGRhKgLmhoB7X3vjQPvujpbkjElB68qQyQICCnqNtpCAAmZsHFSUZjT0XqfRA8p7VzAV/atuxZDMZbqK4D3jMXVE4Pl0nlAx0jht8jhsIucB9zqc9JrG+HiNbBmRo5T5llVni8iXn7rE0ZCztJ4/9BsQfEug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=fc/6ksSNIY14+cMIRv0fMrHzTXfYwm3DIOoQYaSFZAM=; b=mmIwTPUwjh0down3t8bHqjdQQblEEBW29Qv65oYd67eza7VGyDqQxU2Oy6ynaZSDbwrNUnpeKRlJBtnIryTiSA1Wv3RJ+mEtO5P4LevGyX/cAl5Q49AQN6CYgXnAQVQHvMTTA7OfJV0h7IosWdb+oDKtjDrXR9qLAVf9sxkeSV3u9KB8ufcZ4/tuo4TIrC4iRjiUgLXeSyXWLbHdOlXhXrsO35pripi3T6Tzjk6CHZv+r0xcufJy0O/DeBiHqaArAisCR8iu/eYW7sTPyJ6ujPdRk9k7UhKNXsRJQqKtNMOEPrVHPG/2B6gYIvZM8S/UMjSW5MaPLjsssVfsAN1BzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=fc/6ksSNIY14+cMIRv0fMrHzTXfYwm3DIOoQYaSFZAM=; b=HmA0QSxc/Gsqf83zKSAxc3OM9X71iHPC+SfCoVacqvu7aRu1yT9ptN4ocilEI31+bKTiCWlFexGXwZjpTD+q1lT79tscMYRIczWkpaTD+g7vTJXr++sanlK7ead8i6q7SJdCN7cX3BypzpB1MKmUFC6SuJxygs842R+RregMTms= X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 06/11] xen: dt: Replace u64 with uint64_t as the callback function parameters for dt_for_each_range() Date: Thu, 18 May 2023 15:39:15 +0100 Message-ID: <20230518143920.43186-7-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT004:EE_|SA1PR12MB7037:EE_ X-MS-Office365-Filtering-Correlation-Id: 92281347-216f-4037-489d-08db57ade65e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PSaiMIR0zR/aFHCVT2O4ZUfN99/cgRGDkD1kvTEAZTHQPU9uFnh/vZ+H9c9FlielH16tLEHYK67FgZ1zU3cSSlWDtNdC1wtsR1V2sqnRj+kERDJYtH4tiAh/PAbqElyoQybBpZ3Z61n5UO7YWqM1N0wGnlrkmEL7DZAElfN0L2SaD0k7xsN+QsR5VHEPgyviG7yJrS+YPuHRjdXVNYSaUTE4GqQIqfOzWjyHCNzNUShyagpWEjVVQAQsdsi4hhlYU6G4UrCfLoC/1j29P8G39qPplLY3SswB06ykBSkrq/GPVe+QOUgh0yg75kvOoeuOFBLhrAU8wbVt/z/60F7Dd0hnHJ4E6x3Bwlni9riHeAgUsya5NO7UO5NG0aKB43hA/W6ZXoCRZZWKZcvYx5obFn4ePsoK8jBBjeioFmDghyU1Vx7ueEapCCrpmZIc+QC+5T/JOr2wMA4jAAWG9J7TgiiACsO3KO23fix4FZlm/iSIPBKXEJrqg+VpHXwjzVb1ZUUmIl6vuMrnEh5CkcHdgmiFUKzmqvhSnHzxR+wojJSFkb1S80YaHw4AGX/rPMqmnnUPpzHbUjfBIuTH0KT+cITVEniCU8G58TFIX6495e5vhwxUACbWUJchyN2WHge4tjfK749Q+Bqh9LBbHHdgb+ape6fLZ4QkuD/D/uDQJz+HMy4fCSsp85uUEhNV42NTbQMJ9c5nPrJkFUjjnrrGVR0vW0GEaZyzGN6sjwHdopBEsU4/OtG7ReFTV88zanOlroEmFCGLFouqMo464H2lpw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(376002)(39860400002)(136003)(451199021)(36840700001)(40470700004)(46966006)(41300700001)(86362001)(316002)(54906003)(82310400005)(7416002)(103116003)(5660300002)(81166007)(82740400003)(356005)(478600001)(2906002)(4326008)(6916009)(8676002)(8936002)(70586007)(70206006)(36756003)(6666004)(26005)(36860700001)(47076005)(1076003)(2616005)(336012)(40460700003)(426003)(186003)(83380400001)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:41:00.7235 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92281347-216f-4037-489d-08db57ade65e 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7037 In the callback functions invoked by dt_for_each_range() ie handle_pci_range(), map_range_to_domain(), 'u64' should be replaced with 'uint64_t' as the data type for the parameters. The reason being Xen coding style mentions that u32/u64 should be avoided. Also dt_for_each_range() invokes the callback functions with 'uint64_t' arguments. Thus, is_bar_valid() needs to change the parameter types accordingly. Signed-off-by: Ayan Kumar Halder Reviewed-by: Michal Orzel Acked-by: Julien Grall --- Changes from :- v1-v5 - New patch introduced in v6. v6 - 1. Merged "[XEN v6 08/12] xen: dt: Replace u64 with uint64_t as the callback" and "[XEN v6 09/12] xen/arm: pci: Use 'uint64_t' as the datatype for the .." 2. Added R-b. xen/arch/arm/domain_build.c | 4 ++-- xen/arch/arm/include/asm/setup.h | 2 +- xen/arch/arm/pci/pci-host-common.c | 2 +- xen/common/device_tree.c | 4 ++-- xen/include/xen/device_tree.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index cb23f531a8..3f4558ade6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1637,7 +1637,7 @@ out: } static int __init handle_pci_range(const struct dt_device_node *dev, - u64 addr, u64 len, void *data) + uint64_t addr, uint64_t len, void *data) { struct rangeset *mem_holes = data; paddr_t start, end; @@ -2334,7 +2334,7 @@ static int __init map_dt_irq_to_domain(const struct dt_device_node *dev, } int __init map_range_to_domain(const struct dt_device_node *dev, - u64 addr, u64 len, void *data) + uint64_t addr, uint64_t len, void *data) { struct map_range_data *mr_data = data; struct domain *d = mr_data->d; diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h index 47ce565d87..fe17cb0a4a 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -166,7 +166,7 @@ u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); int map_range_to_domain(const struct dt_device_node *dev, - u64 addr, u64 len, void *data); + uint64_t addr, uint64_t len, void *data); extern DEFINE_BOOT_PAGE_TABLE(boot_pgtable); diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c index 5dd62e8013..7cdfc89e52 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -381,7 +381,7 @@ int __init pci_host_bridge_mappings(struct domain *d) * right place for alignment check. */ static int is_bar_valid(const struct dt_device_node *dev, - paddr_t addr, paddr_t len, void *data) + uint64_t addr, uint64_t len, void *data) { struct pdev_bar_check *bar_data = data; paddr_t s = bar_data->start; diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 20bc369367..8da1052911 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -994,7 +994,7 @@ int dt_device_get_paddr(const struct dt_device_node *dev, unsigned int index, int dt_for_each_range(const struct dt_device_node *dev, int (*cb)(const struct dt_device_node *, - u64 addr, u64 length, + uint64_t addr, uint64_t length, void *), void *data) { @@ -1057,7 +1057,7 @@ int dt_for_each_range(const struct dt_device_node *dev, for ( ; rlen >= rone; rlen -= rone, ranges += rone ) { - u64 a, s; + uint64_t a, s; int ret; memcpy(addr, ranges + na, 4 * pna); diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index d514c486a8..c2eada7489 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -681,7 +681,7 @@ int dt_for_each_irq_map(const struct dt_device_node *dev, */ int dt_for_each_range(const struct dt_device_node *dev, int (*cb)(const struct dt_device_node *, - u64 addr, u64 length, + uint64_t addr, uint64_t length, void *), void *data); From patchwork Thu May 18 14:39:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246921 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 D561AC77B7D for ; Thu, 18 May 2023 14:47:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536431.834763 (Exim 4.92) (envelope-from ) id 1pzeul-000532-J2; Thu, 18 May 2023 14:47:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536431.834763; Thu, 18 May 2023 14:47:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeul-00051s-Bu; Thu, 18 May 2023 14:47:35 +0000 Received: by outflank-mailman (input) for mailman id 536431; Thu, 18 May 2023 14:47:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeoZ-00074K-GH for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:41:11 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f400:7eae::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 06f2fec4-f58a-11ed-8611-37d641c3527e; Thu, 18 May 2023 16:41:09 +0200 (CEST) Received: from BN1PR14CA0029.namprd14.prod.outlook.com (2603:10b6:408:e3::34) by SA0PR12MB4576.namprd12.prod.outlook.com (2603:10b6:806:93::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Thu, 18 May 2023 14:41:05 +0000 Received: from BN8NAM11FT106.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e3:cafe::6a) by BN1PR14CA0029.outlook.office365.com (2603:10b6:408:e3::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:41:04 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT106.mail.protection.outlook.com (10.13.177.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:41:03 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:41:03 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 07:41:02 -0700 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:41:01 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 06f2fec4-f58a-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GPNXG2IM5Ehud4tR8pGKKxkxebCruwh99eJLIRN7YSosKkRwMpYDaLefAKSJNS5vqrv9+vgdy3LeW1Ab497ytE8Nk+HNzcxBbEhghekitWuLvf1e0K1ucstY8gl5qp+Py6Ey3nh49ROe0gRnIHQk0pThD9cPq0YkI77+zonfYEXdQmOe7ArjIp7i2y6p8jJtGqyNvvxSOwxp0XNolRx6QcUhTwln7xipvn+SxBaucLKO+7hzuktQykLpC0Pmspq1RJvh4iBH1OH+qbgktJFzodTX7mw/mbqMbiH+zGobvvVLYlTD/95Q8BBXw0uLVyGrnAIIful49LSn+HuNnA2PGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=b9lGGyp31QTztHVbOYMqPwY8XuOJ0Ip79morXeJYXlE=; b=GMidtoGFfHj6WV7uCedW5BvLrbHb+m2JB4InlSwfoJkDfiP63jLCpFl7tNvdropKx02hh5MzIiXb+sBl9o6oBOwkU5QdTgV+XxOSnbRWtPgpBbQCq+TfTg5d2q0/WJyfkOJsWPvdvGzUxCQIZJVXXojEwgVvya5VxdgryuDSdw17TXpegDjRMD+t/XxAxlFG4mMxal8tUD3B2HioS9AqfiqdMZLmrDLM6Il8AOcQkzqjkYSN9ibAYaASE1xym6DUhvcN1611DWhH1WWHGrMgcVD9cGexoSMiydxv6lr+eWSNSbcuTdGFH3BvDh4P19x9V/L60gcGC13YlBEco8zqXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=b9lGGyp31QTztHVbOYMqPwY8XuOJ0Ip79morXeJYXlE=; b=IT2LIcMcwekH1Ud2KAbMJOkR8BIIlplEaDM5TbXL5kI3vJt1A7r1i6ECUJrPoVUeuIr5afCedunYlt4X+Mp7Hlug62g1Yy2aY050nL+8DohCij06uInyZkuiTxyrkNITCV+AfF4maA9Msy64YN6mrIxlNCsPdeB3x2N2SUjjXrU= X-MS-Exchange-Authentication-Results: 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=SATLEXMB03.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 07/11] xen/arm: p2m: Use the pa_range_info table to support ARM_32 and ARM_64 Date: Thu, 18 May 2023 15:39:16 +0100 Message-ID: <20230518143920.43186-8-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT106:EE_|SA0PR12MB4576:EE_ X-MS-Office365-Filtering-Correlation-Id: 45b85d64-7e76-4884-f1e6-08db57ade836 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PxuliIDOJ40wAcLwYeedNUZOELXqQoDpOsDruCR20x86iC3IdBng0iwshjGch7LRBxVEyXgsbbNYP8mFrR1v1X2KjJZXMwi55nsfkeMUntTx0+U/IfjZvxxoRLvj1WJdRVFKyeaWO56HlR20nrk0AxNoKQQIyKo4XEkTL75VTk3ohlH4FzF+9NONIHCCEpjNIBf9EMrqWH5LuSxCUis14vUE1XiOUdGVnKVofSf95S/iS5apfc1gokykrMMD5Fx8CfAji6+DF8Nqih8YyM1NfEJR7Tff1Lk9I1Z+XYE0Ov0VsURBeOSLzdbU+UtVr1Qifl+nAOWsaGFmpDAGQhW+fgQPjzZFDJR9W7zsi+C2g4T3Xc7wT8K61BDZtDxiGyycRwaZZp2NF0kMy8p5KiqQ8hMKpA09w42sH/U415Zd9xtNqhQTZ4CPqziAeGwsa8sJ1vLTSOSX+GnmJs8mKEjyBd/s7rsRf0Zstc792r7BGLogKuJ/aEcyhcMZ/byDRz8qBfnVGGp6/j8Vbm//kEip55Jbh60hobXVqsjM2XGhk6dmdYX8ETb+1dEyJow2pTnODIJjiEwCg12XcWTP/mvJCHThv8S8fl9Bd7hH/ZLV45Qj+kRRnz+GlOigomCff+3ExpTCHfXQuvUHgKCU8IwtKV9o8E2bV6mRk0cx/DvuJSVbduXUt86PTXrT8eZxWJjlw+/VfWIRngT5kpwat7+lt2xqmYV/AJ7AojJ0EiCVw59MDrjMhCh6ekianD8mksifos3xeCqf6ZjWp/14tmD/HQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199021)(36840700001)(40470700004)(46966006)(6666004)(83380400001)(2906002)(82310400005)(47076005)(36756003)(426003)(336012)(2616005)(186003)(5660300002)(82740400003)(8676002)(26005)(1076003)(54906003)(7416002)(8936002)(81166007)(86362001)(41300700001)(40460700003)(36860700001)(70586007)(6916009)(103116003)(478600001)(70206006)(356005)(4326008)(316002)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:41:03.9462 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45b85d64-7e76-4884-f1e6-08db57ade836 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT106.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4576 Restructure the code so that one can use pa_range_info[] table for both ARM_32 as well as ARM_64. Also, removed the hardcoding for P2M_ROOT_ORDER and P2M_ROOT_LEVEL as p2m_root_order can be obtained from the pa_range_info[].root_order and p2m_root_level can be obtained from pa_range_info[].sl0. Refer ARM DDI 0406C.d ID040418, B3-1345, "Use of concatenated first-level translation tables ...However, a 40-bit input address range with a translation granularity of 4KB requires a total of 28 bits of address resolution. Therefore, a stage 2 translation that supports a 40-bit input address range requires two concatenated first-level translation tables,..." Thus, root-order is 1 for 40-bit IPA on ARM_32. Refer ARM DDI 0406C.d ID040418, B3-1348, "Determining the required first lookup level for stage 2 translations For a stage 2 translation, the output address range from the stage 1 translations determines the required input address range for the stage 2 translation. The permitted values of VTCR.SL0 are: 0b00 Stage 2 translation lookup must start at the second level. 0b01 Stage 2 translation lookup must start at the first level. VTCR.T0SZ must indicate the required input address range. The size of the input address region is 2^(32-T0SZ) bytes." Thus VTCR.SL0 = 1 (maximum value) and VTCR.T0SZ = -8 when the size of input address region is 2^40 bytes. Thus, pa_range_info[].t0sz = 1 (VTCR.S) | 8 (VTCR.T0SZ) ie 11000b which is 24. VTCR.T0SZ, is bits [5:0] for ARM_64. VTCR.T0SZ is bits [3:0] and S(sign extension), bit[4] for ARM_32. Thus, VTCR.T0SZ bits are interpreted accordingly for different architecture. For this, we have used union. pa_range_info[] is indexed by ID_AA64MMFR0_EL1.PARange which is present in Arm64 only. This is the reason we do not specify the indices for ARM_32. Also, we duplicated the entry "{ 40, 24/*24*/, 1, 1 }" between ARM_64 and ARM_32. This is done to avoid introducing extra #if-defs. Signed-off-by: Ayan Kumar Halder --- Changes from - v3 - 1. New patch introduced in v4. 2. Restructure the code such that pa_range_info[] is used both by ARM_32 as well as ARM_64. v4 - 1. Removed the hardcoded definitions of P2M_ROOT_ORDER and P2M_ROOT_LEVEL. The reason being root_order will not be always 1 (See the next patch). 2. Updated the commit message to explain t0sz, sl0 and root_order values for 32-bit IPA on Arm32. 3. Some sanity fixes. v5 - pa_range_info is indexed by system_cpuinfo.mm64.pa_range. ie when PARange is 0, the PA size is 32, 1 -> 36 and so on. So pa_range_info[] has been updated accordingly. For ARM_32 pa_range_info[0] = 0 and pa_range_info[1] = 0 as we do not support 32-bit, 36-bit physical address range yet. v6 - 1. Added pa_range_info[] entries for ARM_32 without indices. Some entry may be duplicated between ARM_64 and ARM_32. 2. Recalculate p2m_ipa_bits for ARM_32 from T0SZ (similar to ARM_64). 3. Introduced an union to reinterpret T0SZ bits between ARM_32 and ARM_64. xen/arch/arm/include/asm/p2m.h | 6 ------ xen/arch/arm/p2m.c | 37 +++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h index f67e9ddc72..940495d42b 100644 --- a/xen/arch/arm/include/asm/p2m.h +++ b/xen/arch/arm/include/asm/p2m.h @@ -14,16 +14,10 @@ /* Holds the bit size of IPAs in p2m tables. */ extern unsigned int p2m_ipa_bits; -#ifdef CONFIG_ARM_64 extern unsigned int p2m_root_order; extern unsigned int p2m_root_level; #define P2M_ROOT_ORDER p2m_root_order #define P2M_ROOT_LEVEL p2m_root_level -#else -/* First level P2M is always 2 consecutive pages */ -#define P2M_ROOT_ORDER 1 -#define P2M_ROOT_LEVEL 1 -#endif struct domain; diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 418997843d..755cb86c5b 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -19,9 +19,9 @@ #define INVALID_VMID 0 /* VMID 0 is reserved */ -#ifdef CONFIG_ARM_64 unsigned int __read_mostly p2m_root_order; unsigned int __read_mostly p2m_root_level; +#ifdef CONFIG_ARM_64 static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT; /* VMID is by default 8 bit width on AArch64 */ #define MAX_VMID max_vmid @@ -2247,16 +2247,6 @@ void __init setup_virt_paging(void) /* Setup Stage 2 address translation */ register_t val = VTCR_RES1|VTCR_SH0_IS|VTCR_ORGN0_WBWA|VTCR_IRGN0_WBWA; -#ifdef CONFIG_ARM_32 - if ( p2m_ipa_bits < 40 ) - panic("P2M: Not able to support %u-bit IPA at the moment\n", - p2m_ipa_bits); - - printk("P2M: 40-bit IPA\n"); - p2m_ipa_bits = 40; - val |= VTCR_T0SZ(0x18); /* 40 bit IPA */ - val |= VTCR_SL0(0x1); /* P2M starts at first level */ -#else /* CONFIG_ARM_64 */ static const struct { unsigned int pabits; /* Physical Address Size */ unsigned int t0sz; /* Desired T0SZ, minimum in comment */ @@ -2265,6 +2255,7 @@ void __init setup_virt_paging(void) } pa_range_info[] __initconst = { /* T0SZ minimum and SL0 maximum from ARM DDI 0487H.a Table D5-6 */ /* PA size, t0sz(min), root-order, sl0(max) */ +#ifdef CONFIG_ARM_64 [0] = { 32, 32/*32*/, 0, 1 }, [1] = { 36, 28/*28*/, 0, 1 }, [2] = { 40, 24/*24*/, 1, 1 }, @@ -2273,11 +2264,22 @@ void __init setup_virt_paging(void) [5] = { 48, 16/*16*/, 0, 2 }, [6] = { 52, 12/*12*/, 4, 2 }, [7] = { 0 } /* Invalid */ +#else + { 40, 24/*24*/, 1, 1 }, + { 0 }, /* Invalid */ +#endif }; unsigned int i; unsigned int pa_range = 0x10; /* Larger than any possible value */ + /* Typecast pa_range_info[].t0sz into ARM_32 and ARM_64 bit variants. */ + union { + signed int t0sz_32:5; + unsigned int t0sz_64:6; + } t0sz; + +#ifdef CONFIG_ARM_64 /* * Restrict "p2m_ipa_bits" if needed. As P2M table is always configured * with IPA bits == PA bits, compare against "pabits". @@ -2291,6 +2293,7 @@ void __init setup_virt_paging(void) */ if ( system_cpuinfo.mm64.vmid_bits == MM64_VMID_16_BITS_SUPPORT ) max_vmid = MAX_VMID_16_BIT; +#endif /* Choose suitable "pa_range" according to the resulted "p2m_ipa_bits". */ for ( i = 0; i < ARRAY_SIZE(pa_range_info); i++ ) @@ -2306,24 +2309,34 @@ void __init setup_virt_paging(void) if ( pa_range >= ARRAY_SIZE(pa_range_info) || !pa_range_info[pa_range].pabits ) panic("Unknown encoding of ID_AA64MMFR0_EL1.PARange %x\n", pa_range); +#ifdef CONFIG_ARM_64 val |= VTCR_PS(pa_range); val |= VTCR_TG0_4K; /* Set the VS bit only if 16 bit VMID is supported. */ if ( MAX_VMID == MAX_VMID_16_BIT ) val |= VTCR_VS; +#endif + val |= VTCR_SL0(pa_range_info[pa_range].sl0); val |= VTCR_T0SZ(pa_range_info[pa_range].t0sz); p2m_root_order = pa_range_info[pa_range].root_order; p2m_root_level = 2 - pa_range_info[pa_range].sl0; + +#ifdef CONFIG_ARM_64 + t0sz.t0sz_64 = pa_range_info[pa_range].t0sz; p2m_ipa_bits = 64 - pa_range_info[pa_range].t0sz; +#else + t0sz.t0sz_32 = pa_range_info[pa_range].t0sz; + p2m_ipa_bits = 32 - t0sz.t0sz_32; +#endif printk("P2M: %d-bit IPA with %d-bit PA and %d-bit VMID\n", p2m_ipa_bits, pa_range_info[pa_range].pabits, ( MAX_VMID == MAX_VMID_16_BIT ) ? 16 : 8); -#endif + printk("P2M: %d levels with order-%d root, VTCR 0x%"PRIregister"\n", 4 - P2M_ROOT_LEVEL, P2M_ROOT_ORDER, val); From patchwork Thu May 18 14:39:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246922 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 0F6C6C7EE23 for ; Thu, 18 May 2023 14:47:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536426.834748 (Exim 4.92) (envelope-from ) id 1pzeuj-0004lb-Sj; Thu, 18 May 2023 14:47:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536426.834748; Thu, 18 May 2023 14:47:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeuj-0004lO-O3; Thu, 18 May 2023 14:47:33 +0000 Received: by outflank-mailman (input) for mailman id 536426; Thu, 18 May 2023 14:47:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzepA-00074K-A9 for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:41:48 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20617.outbound.protection.outlook.com [2a01:111:f400:7eaa::617]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1c61c6a2-f58a-11ed-8611-37d641c3527e; Thu, 18 May 2023 16:41:46 +0200 (CEST) Received: from MW4PR04CA0086.namprd04.prod.outlook.com (2603:10b6:303:6b::31) by SJ1PR12MB6361.namprd12.prod.outlook.com (2603:10b6:a03:455::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Thu, 18 May 2023 14:41:42 +0000 Received: from CO1NAM11FT094.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::cc) by MW4PR04CA0086.outlook.office365.com (2603:10b6:303:6b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:41:42 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT094.mail.protection.outlook.com (10.13.174.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:41:42 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:41:39 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:41:39 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:41:37 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1c61c6a2-f58a-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mrjx0LnzcAsYrkxe9sr49t7CfQz8YRveGilrmREb3T55OTvXIfk5vftZcaklyT2Q2ClKmXRbDhLNLuMzmeTyjSN4q/uw5inXX/EahlDOP9nbF4NGBOBs0UERmmIdeVOrPub4wsYn680+hWnpT3hgGv1Nl2JBDNJCQgDFvc8Gj3Nk6sZYSjOR8UrJcjiibq2x3cGK6ff9pSqUpoLQcPlOGzwCHBvQLf5mygFqOYBlRsO9hjtCewBCLDk3sXUfGyNnvrZB7/9pTaW/weordR8uVXEsR7looC1B30BjfpiPiveSLf2LLD1eizJFGvE5ApTjO8JAVjr7O+LNzk9i3dKQcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=V/cEYIxV/h5yAer+sUbKU2ootiXZ/Hl1Xk3NfMqs0ok=; b=cekbC89ycqQaL2NJBYBi4LxcMT1Qy3csY7+umXBul7zEJK5x3IEjB2IZrlTvhhYntwOJy+DRXtQKQphEFViGzJ9jh477uHWncmG0Fd2hEDFlH0SJPjuA/7QCJF71eIuuazUbveGCjL/pchw5RU9GJg/DijeXdNe1hwMkwE3nK7Cq+Y3ivviBlkVpDdvkNUZqxtMO8GMes405fE+iMijOwPsuhltuKsLp9k1xbXZZjfi31iIS+s8A97rI5VFwfjRZg07gIdaZxZUOq5ho6+K1Nwmv8I9Y7sMO+7wVf50TBomJYUSdhuCSXCUDbRdw57ln9BKIVEbuW4/ouvo5vt5fXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=V/cEYIxV/h5yAer+sUbKU2ootiXZ/Hl1Xk3NfMqs0ok=; b=Day8QmvpJRuveSsSIqt6QF20wWiSSMrhNXhkAv9+bBZ7wwhcLUmhjbr6ur5pXpcy9vaIJwnVBvBRmLP1AlW2ynVmYi95KhbiswJpb0ysK8d9uxU4YLgaRQsJslqGcFOppURWCJX2ZklpDL/ZEN682h22+rGzkibNmEoxlJ4iKN4= X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 08/11] xen/arm: Introduce choice to enable 64/32 bit physical addressing Date: Thu, 18 May 2023 15:39:17 +0100 Message-ID: <20230518143920.43186-9-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT094:EE_|SJ1PR12MB6361:EE_ X-MS-Office365-Filtering-Correlation-Id: d53ad848-18ad-4aed-c475-08db57adff1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2tPYg221YJj44gHiKTuNUNfbzlpM6cHHXVOHpWr1ssKv+gTnx5khAUCA7NvbWU3z/uK9TNLYNWH+C5EQP5FjYmN6ZWNIq1V0LaMhiuy6ec3es13eML0LPJ4egBmJ1QSZHOuHW4rpJt4Eeg9L4RjKy40MRJ5tMjQMwdSxD6y0AR2DV6olYZUgl58Luvn5T3XyqdBEiOPsC8cz3exlzgLy2EfDm2CmftG5ol8lPyVq+a3fWv/w6PN0QUaofWYXZah5RJANqAbytfLXOzbdBCcrpccX9IEN9M0LrJ/5LJo4ThFKaYya8jDOaeUnn71mO6xSTvPi9rnXcR7Ec5GYpH6aN78Mc+Zjwd310kN5YjMImjUBQMNW/GlkiV5AlthNqgiJPbgeyySM5Nr1BJmIFh/xSogj2GsOmaKm+7cEqHSEmvRVocJDfFcNCGfqoh6Gk0b13aZaZuI1XQfZZOfm/kEOwLw40ZsRHtKn/v/zJFK6mRxkRC3tspcFCbpBEKcnywKdBIE1OPbBO5wA/4JVrCvyq0kga2dZ6kuIMc9pEndUhb79f8I45TNvvU7gpAJMrK1glKMdQ144hiLNFaStCwa4jOuEIVsG4bS2nn/a8xiP5nNeL+inPtrGorSdlmw1D82nPakTnGM92Etl2PAJTK0I7V/smKWWmdIwtUa5gx7sIDhoce09X0mHZPC7diqbsR4y9t/k5XhEgNuxVrkhL5Yo0m5wnFSgqwwQ7AvayWMMaZd2hqKtnQASlEB4ZT8C7J3k80LOusOvgDsFJwovjk3yaQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(396003)(39860400002)(136003)(376002)(451199021)(40470700004)(46966006)(36840700001)(5660300002)(70206006)(70586007)(2906002)(8936002)(478600001)(316002)(8676002)(54906003)(6916009)(7416002)(4326008)(41300700001)(6666004)(40460700003)(26005)(1076003)(82740400003)(356005)(186003)(40480700001)(426003)(336012)(83380400001)(36756003)(36860700001)(47076005)(86362001)(82310400005)(2616005)(81166007)(103116003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:41:42.1788 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d53ad848-18ad-4aed-c475-08db57adff1f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT094.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6361 Some Arm based hardware platforms which does not support LPAE (eg Cortex-R52), uses 32 bit physical addresses. Also, users may choose to use 32 bits to represent physical addresses for optimization. To support the above use cases, we have introduced arch independent config to choose if the physical address can be represented using 32 bits (PHYS_ADDR_T_32) or 64 bits (!PHYS_ADDR_T_32). For now only ARM_32 provides support to enable 32 bit physical addressing. When PHYS_ADDR_T_32 is defined, PADDR_BITS is set to 32. Note that we use "unsigned long" (not "uint32_t") to denote the datatype of physical address. This is done to avoid using a cast each time PAGE_* macros are used on paddr_t. On 32-bit architecture, "unsigned long" is 32-bit wide. Thus, it can be used to denote physical address. When PHYS_ADDR_T_32 is not defined for ARM_32, PADDR_BITS is set to 40. For ARM_64, PADDR_BITS is set to 48. The last two are same as the current configuration used today on Xen. Signed-off-by: Ayan Kumar Halder Reviewed-by: Michal Orzel --- Changes from - v1 - 1. Extracted from "[XEN v1 8/9] xen/arm: Other adaptations required to support 32bit paddr". v2 - 1. Introduced Kconfig choice. ARM_64 can select PHYS_ADDR_64 only whereas ARM_32 can select PHYS_ADDR_32 or PHYS_ADDR_64. 2. For CONFIG_ARM_PA_32, paddr_t is defined as 'unsigned long'. v3 - 1. Allow user to define PADDR_BITS by selecting different config options ARM_PA_BITS_32, ARM_PA_BITS_40 and ARM_PA_BITS_48. 2. Add the choice under "Architecture Features". v4 - 1. Removed PHYS_ADDR_T_64 as !PHYS_ADDR_T_32 means PHYS_ADDR_T_32. v5 - 1. Removed ARM_PA_BITS_48 as there is no choice for ARM_64. 2. In ARM_PA_BITS_32, "help" is moved to last, and "depends on" before "select". v6 - 1. Explained why we use "unsigned long" to represent physical address for ARM_32. xen/arch/Kconfig | 3 +++ xen/arch/arm/Kconfig | 32 ++++++++++++++++++++++++++++ xen/arch/arm/include/asm/page-bits.h | 6 +----- xen/arch/arm/include/asm/types.h | 13 +++++++++++ xen/arch/arm/mm.c | 5 +++++ 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/xen/arch/Kconfig b/xen/arch/Kconfig index 7028f7b74f..67ba38f32f 100644 --- a/xen/arch/Kconfig +++ b/xen/arch/Kconfig @@ -1,6 +1,9 @@ config 64BIT bool +config PHYS_ADDR_T_32 + bool + config NR_CPUS int "Maximum number of CPUs" range 1 4095 diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 239d3aed3c..63f4d35dab 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -26,6 +26,38 @@ config ARCH_DEFCONFIG menu "Architecture Features" +choice + prompt "Physical address space size" if ARM_32 + default ARM_PA_BITS_40 if ARM_32 + help + User can choose to represent the width of physical address. This can + sometimes help in optimizing the size of image when user chooses a + smaller size to represent physical address. + +config ARM_PA_BITS_32 + bool "32-bit" + depends on ARM_32 + select PHYS_ADDR_T_32 + help + On platforms where any physical address can be represented within 32 bits, + user should choose this option. This will help in reduced size of the + binary. + Xen uses "unsigned long" and not "uint32_t" to denote the datatype of + physical address. This is done to avoid using a cast each time PAGE_* + macros are used on paddr_t. On 32-bit architecture, "unsigned long" is + 32-bit wide. Thus, it can be used to denote physical address. + +config ARM_PA_BITS_40 + bool "40-bit" + depends on ARM_32 +endchoice + +config PADDR_BITS + int + default 32 if ARM_PA_BITS_32 + default 40 if ARM_PA_BITS_40 + default 48 if ARM_64 + source "arch/Kconfig" config ACPI diff --git a/xen/arch/arm/include/asm/page-bits.h b/xen/arch/arm/include/asm/page-bits.h index 5d6477e599..deb381ceeb 100644 --- a/xen/arch/arm/include/asm/page-bits.h +++ b/xen/arch/arm/include/asm/page-bits.h @@ -3,10 +3,6 @@ #define PAGE_SHIFT 12 -#ifdef CONFIG_ARM_64 -#define PADDR_BITS 48 -#else -#define PADDR_BITS 40 -#endif +#define PADDR_BITS CONFIG_PADDR_BITS #endif /* __ARM_PAGE_SHIFT_H__ */ diff --git a/xen/arch/arm/include/asm/types.h b/xen/arch/arm/include/asm/types.h index e218ed77bd..01d9d39e4b 100644 --- a/xen/arch/arm/include/asm/types.h +++ b/xen/arch/arm/include/asm/types.h @@ -34,9 +34,22 @@ typedef signed long long s64; typedef unsigned long long u64; typedef u32 vaddr_t; #define PRIvaddr PRIx32 +#if defined(CONFIG_PHYS_ADDR_T_32) + +/* + * We use "unsigned long" and not "uint32_t" to denote the type. This is done + * to avoid having a cast each time PAGE_* macros are used on paddr_t. + * On 32-bit architecture, "unsigned long" is 32-bit wide. Thus, we can use it + * to denote physical address. + */ +typedef unsigned long paddr_t; +#define INVALID_PADDR (~0UL) +#define PRIpaddr "08lx" +#else typedef u64 paddr_t; #define INVALID_PADDR (~0ULL) #define PRIpaddr "016llx" +#endif typedef u32 register_t; #define PRIregister "08x" #elif defined (CONFIG_ARM_64) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 74f6ff2c6f..5ef5fd8c49 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -703,6 +703,11 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) const unsigned long mapping_size = frametable_size < MB(32) ? MB(2) : MB(32); int rc; + /* + * The size of paddr_t should be sufficient for the complete range of + * physical address. + */ + BUILD_BUG_ON((sizeof(paddr_t) * BITS_PER_BYTE) < PADDR_BITS); BUILD_BUG_ON(sizeof(struct page_info) != PAGE_INFO_SIZE); if ( frametable_size > FRAMETABLE_SIZE ) From patchwork Thu May 18 14:39:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246923 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 A5487C7EE23 for ; Thu, 18 May 2023 14:47:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536430.834758 (Exim 4.92) (envelope-from ) id 1pzeul-00050w-9j; Thu, 18 May 2023 14:47:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536430.834758; Thu, 18 May 2023 14:47:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzeul-00050p-4j; Thu, 18 May 2023 14:47:35 +0000 Received: by outflank-mailman (input) for mailman id 536430; Thu, 18 May 2023 14:47:33 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzepP-0000Pw-5W for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:42:03 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20627.outbound.protection.outlook.com [2a01:111:f400:7eb2::627]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 26296225-f58a-11ed-b22c-6b7b168915f2; Thu, 18 May 2023 16:42:02 +0200 (CEST) Received: from MW2PR2101CA0029.namprd21.prod.outlook.com (2603:10b6:302:1::42) by SA1PR12MB6895.namprd12.prod.outlook.com (2603:10b6:806:24e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Thu, 18 May 2023 14:41:59 +0000 Received: from CO1NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:302:1:cafe::7d) by MW2PR2101CA0029.outlook.office365.com (2603:10b6:302:1::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Thu, 18 May 2023 14:41:59 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT053.mail.protection.outlook.com (10.13.175.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:41:58 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:41:57 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 07:41:57 -0700 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:41:56 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 26296225-f58a-11ed-b22c-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AxljZyJCoDuKiwjuzQwORT+0OarCdHjVU5cRm/0sqKn2D5JLiOwF3KZkPNLpMtA3uVx8Vw0W8KW8zCrdnHj69mle55n9q/NFNmdu5giN3K0VzVzR7FD8ZxxcxwLa0dWELcAS07SztYIUYAodG7Qt384rEJSY4JTXzR06zg4JZmk+ER31v+RcozkuqQDW7l5GgMl3jMOHK555wQK4WgwJRojhnYtrSb+DxFmbe+5o8647i8W+UP1FNv80Z0cyF4xBhmsTRPGAqD642NlI+CEGevYkLVfXTPO/W3rx116rPKT5kZjGltnM2Clg0RWgvEpGMGCyu6LvsrF63hG88mhNBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=IXMycSPCMoOkBk7CFnL74O37ftF1ESExFvr5Bqg0mxU=; b=UKEDB6pSB7tlAHpUpvDxLi9GylDEOGzTcV2pBrL3w6QTUO6ewvALKzyxe8afEVPDhUR9nVY1ysDKH5GuagYhE0SDRBnJIJ+qP9FVT239oRCjEHByOwk2cSo8V/Mr8L202tVSTppbW/hSKlTnLoYGY0jANgqUvROnaVqhlmHenFsGg+LgirLrptR4eSLoRtOpZyRGuyZ8rVQ9gLPQTEnuSp62Bdis7gcPdzfcKvp7ilvlyukuwYBiTJeMAxYTx+kAurhWfjicMraoEmRCfuR/rPEOfMsDJKxqy8tUmTpPzLUN6+Ee+ztywCP3LQ8rlDXaPoWAsYbAEf4p2TaAu9PTpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=IXMycSPCMoOkBk7CFnL74O37ftF1ESExFvr5Bqg0mxU=; b=s1v+xe6V4xa89bZ+XG7/a1/1i7GpxU0ONiQ5dk0Pwas4qtJwdSavRh7zErod5VxbCZpwNY6m5+rTRHHncZ3KeUwY/Qhs2f6Wxp3YNbFpVbsdYKeiQtM6ODsaEmRtDYwrJAp9xHi8GO8xC+CSuvbXPXDeYA6ZqzaMcQ4xG+NcGR8= X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 09/11] xen/arm: guest_walk: LPAE specific bits should be enclosed within "ifndef CONFIG_PHYS_ADDR_T_32" Date: Thu, 18 May 2023 15:39:18 +0100 Message-ID: <20230518143920.43186-10-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT053:EE_|SA1PR12MB6895:EE_ X-MS-Office365-Filtering-Correlation-Id: d91d4848-3879-4e23-c422-08db57ae08d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5ZSHmTx+EeRWpab+dReGyHtsuWWdQ5XcBVv9SyWuxsgmUAVUDTgD6OBmx4XUok+7htNOm0IiSYGueeTH0+enGRxsP3CiHYBnDxjy4LtSTqSO3wSHU1hF0gtR1xrt8Ifp2FRcIrMQ8L6TeeL38FeJeGAeI/eW11IC1nmwpFIN1rke6w/RsmK0hvaNIh+b8EoqZjqdRJTJoY8iu2Mcvw15G+Ta0k8W+0wU4pNw3FAlzf4GjDEurrf+NoZE0Bvl+GBhmfYG6iH7bx88ej4GhFOekRX7SI1YpvQ8kP9LgIJo5yP5uTZYBFvAufYEuKJFs5eXO7RJM/UqlPUKw5WZnMm5MTvX7yprEHr2CVg7i0ArhIU2P3aQFZ3+4MgJBo+K8i8YjYPlQko1+1waJEWAr2xUOa7Kr7DuY/PemyEmyeGL/WPk6a6LUWVoCrc4lZqjC9ByoOW9+o6vA1K/+h6CcEuMQ11ycDVSFChAlQdf4sKfhu6fm5TZTTmV7CpwtCv1TpIiazNa3gVa5RORwT+6LWuRuggagSM5ZConGr1fjrie+V4G++ODircD38WUmQr6HYQNOQJXL+hG9MmYs8BoyhOlnB1NgO4W3joiHG/FG8yFhCZuPBXbISQwd/7rS7Nd+6ngWLs77DoKw83VGGMaK3BwvArIbV141ZSKD/c0lFuh8dlkbhvm8UzlWR1bJthw+R3SzXagMWV3j3oA21ZBvksWauFRTXnR4MU12pofuCDpU6omN/6qhWvHthuwOnGZeocBLcbfNCGoRd3XutoTmXsqsw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(136003)(39860400002)(346002)(451199021)(46966006)(40470700004)(36840700001)(6916009)(36756003)(4326008)(2906002)(7416002)(8676002)(426003)(336012)(5660300002)(86362001)(8936002)(40460700003)(41300700001)(70206006)(54906003)(6666004)(103116003)(70586007)(316002)(40480700001)(478600001)(356005)(2616005)(82740400003)(83380400001)(47076005)(1076003)(36860700001)(82310400005)(26005)(81166007)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:41:58.5778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d91d4848-3879-4e23-c422-08db57ae08d7 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6895 As the previous patch introduces CONFIG_PHYS_ADDR_T_32 to support 32 bit physical addresses, the code specific to "Large Physical Address Extension" (ie LPAE) should be enclosed within "ifndef CONFIG_PHYS_ADDR_T_32". Refer xen/arch/arm/include/asm/short-desc.h, "short_desc_l1_supersec_t" unsigned int extbase1:4; /* Extended base address, PA[35:32] */ unsigned int extbase2:4; /* Extended base address, PA[39:36] */ Thus, extbase1 and extbase2 are not valid when 32 bit physical addresses are supported. Signed-off-by: Ayan Kumar Halder Acked-by: Stefano Stabellini --- Changes from - v1 - 1. Extracted from "[XEN v1 8/9] xen/arm: Other adaptations required to support 32bit paddr". v2 - 1. Reordered this patch so that it appears after CONFIG_ARM_PA_32 is introduced (in 6/9). v3 - 1. Updated the commit message. 2. Added Ack. v4 - 1. No changes. v5 - 1. No changes. v6 - 1. No changes. xen/arch/arm/guest_walk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c index 43d3215304..c80a0ce55b 100644 --- a/xen/arch/arm/guest_walk.c +++ b/xen/arch/arm/guest_walk.c @@ -154,8 +154,10 @@ static bool guest_walk_sd(const struct vcpu *v, mask = (1ULL << L1DESC_SUPERSECTION_SHIFT) - 1; *ipa = gva & mask; *ipa |= (paddr_t)(pte.supersec.base) << L1DESC_SUPERSECTION_SHIFT; +#ifndef CONFIG_PHYS_ADDR_T_32 *ipa |= (paddr_t)(pte.supersec.extbase1) << L1DESC_SUPERSECTION_EXT_BASE1_SHIFT; *ipa |= (paddr_t)(pte.supersec.extbase2) << L1DESC_SUPERSECTION_EXT_BASE2_SHIFT; +#endif /* CONFIG_PHYS_ADDR_T_32 */ } /* Set permissions so that the caller can check the flags by herself. */ From patchwork Thu May 18 14:39:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246915 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 A0B69C7EE23 for ; Thu, 18 May 2023 14:42:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536419.834728 (Exim 4.92) (envelope-from ) id 1pzepm-0003Rz-2o; Thu, 18 May 2023 14:42:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536419.834728; Thu, 18 May 2023 14:42:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzepl-0003Rs-Ul; Thu, 18 May 2023 14:42:25 +0000 Received: by outflank-mailman (input) for mailman id 536419; Thu, 18 May 2023 14:42:25 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzepl-0003Qv-9x for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:42:25 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2062f.outbound.protection.outlook.com [2a01:111:f400:7e83::62f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 32eca288-f58a-11ed-8611-37d641c3527e; Thu, 18 May 2023 16:42:23 +0200 (CEST) Received: from SJ0PR03CA0245.namprd03.prod.outlook.com (2603:10b6:a03:3a0::10) by DM4PR12MB5326.namprd12.prod.outlook.com (2603:10b6:5:39a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 14:42:21 +0000 Received: from CO1NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:3a0:cafe::f2) by SJ0PR03CA0245.outlook.office365.com (2603:10b6:a03:3a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:42:20 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT093.mail.protection.outlook.com (10.13.175.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:42:18 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:42:17 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:42:16 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 32eca288-f58a-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N1ytZ9+1/jjUtOKV2xnBBUtBFccy7gY3JEPHzcduwLOydo886bmdhUZzcYn17U0Epcb2sSnwMT9YnrUttBjYyeTKBeCcvGztaIcC4jVPrgS9vAS4VzWXgxs2dlcN9ZXak3sR0cJMLF3FFTOfCJCGRIjz6jh8jUmFp73+losru7GNZB63YkF6gdE8BjOCpRKhgYttCVPJJS9yhUUVwFFkEjY76o91onxVMKADe5zb3gGnLLbH/kBZYrbSpsROS3vpLQd8G50kA2grOMGbMV7Qip/EBjM6Ka8+NV6b3Qyc51vnDpaU08ETaBy1QIJgbl4Lugvc6C8acO4a27UpC878Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=S39xs8zKJNXxpJ6L+8N1p//laX3Tu7QlivwVG5FaGX0=; b=G1U+XtoGmrB/hRrojmjGvTg1/XQC872Hu6H9acixnQqP8kgI6m3Zq1N5x1XHXmxY55Ica42V5Fwa0c+YMFuwQEAzmTX7kcFRNacvwnkivmwSfKQkiiDd6goSplw/aN9Ne0yczb28hWKdb9vFASmX7aRkcoiyYj4sC8Pt7eEtbPovBvYlcJn74uPmwjkKp5pH+r9AXR6QUFq+TwDZ2hPQv3YMh83+36Nvn1ch32XIUilNAUhr9rhtz5p/pVlZ1Ih9z4UCYk0yr3PiD2JvIav344Xi9QAJ3QKRUgDqGf9C2qCkFM9UVee6waH+1KrseX15YOd11AK3HMzwrYTZbnsgJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=temperror action=none header.from=amd.com; dkim=none (message not signed); 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=S39xs8zKJNXxpJ6L+8N1p//laX3Tu7QlivwVG5FaGX0=; b=TAsE1B73aaMxisiJ0wMMX7VZTmaIGJCQ8gJwwUtuleD8Wq4wkIUsGhYb97mpFUQ+IFfwBCloOSlnNM0KUCvkIidLeFWfWCCE4A+WY31W1tuxz3i2w8p+fSwj4hzRzNJst9hY9cTkHssZGNerniCi8AexXT949rRfzoUXFNCpcus= X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 10/11] xen/arm: Restrict zeroeth_table_offset for ARM_64 Date: Thu, 18 May 2023 15:39:19 +0100 Message-ID: <20230518143920.43186-11-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT093:EE_|DM4PR12MB5326:EE_ X-MS-Office365-Filtering-Correlation-Id: bb8a2e8d-598c-4549-0786-08db57ae14ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GfcY/a1Ux/k4PtXxNmQNowT1RJhJeykLBnEv8rBjAiqQ8GoNDuQxssfxgeJjK/E9CYSeXhHZdmZeaP+MZKRYpf09lL315a+UpsB3miICqGreIZ/I8qFVjd3/xE49tnxS8TZffHcD3wf0o7EYdVNx926KufAG0p/cXjmvfWGp+XpsKxlJwPVIqnRN9aIsULGa6GnIEtWkST04SU3r5TmBdKfOEtUdw5Z6JfXAFq+03qtTqXZ5HepLmrbWNAf0b6Tgh2L6ZhlgQxWsTAZcoF9HZYtk7R3AJnOVmSdKh2hZVrMkSbKYnhL3YCVd/d7Bv2xIkKzKqdPkv8seWIZfXYFQ4yfqZhmg0xnwHkxwU+mdpEneS0o0xnhs5EWaoc4hNeMacDFUo2Je1ezowB9IZWCKJFWpEkCvymd4MtHUntIptX0hiK8X4WvJzGUnKC+afGzcw4M0BgolX5fvAJwHaMUVaUghQUi4SbFe5H7Gw5yk4ATc4uTV/vDJFwM4Ft17YOF2KH4G/SIR6Q+vB668MHXNMqg12OnnFSAKJjrZk9RCZLvueqmJUCjs+PaugujXzWRISriiWUhXNT/hyRyw9CDX/upbl4kEK/HfQ85gwW4hz1scb/Nm60Wqr0WKeJ8RSJ6+M58I3/E/QmRAZ9PAGN+eNuSIps2lmUSRmMTfXrr+rSbtDeW/UG9zlANX+OQieNeVWQvnNahYn2KKz/jjnpYejTIEa0cBc0XtGqEL/1UlSE82JJAaDv3aQs2DmOtv9fUn7Mis9PFn+YUR+PDhDSRwhg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(396003)(376002)(346002)(451199021)(46966006)(36840700001)(40470700004)(36860700001)(63350400001)(426003)(47076005)(336012)(186003)(1076003)(2616005)(54906003)(478600001)(63370400001)(26005)(83380400001)(2906002)(8676002)(36756003)(5660300002)(8936002)(6916009)(81166007)(82740400003)(103116003)(40460700003)(7416002)(41300700001)(356005)(70206006)(70586007)(82310400005)(40480700001)(86362001)(4326008)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:42:18.4173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb8a2e8d-598c-4549-0786-08db57ae14ab 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5326 When 32 bit physical addresses are used (ie PHYS_ADDR_T_32=y), "va >> ZEROETH_SHIFT" causes an overflow. Also, there is no zeroeth level page table on Arm32. Also took the opportunity to clean up dump_pt_walk(). One could use DECLARE_OFFSETS() macro instead of declaring an array of page table offsets. Signed-off-by: Ayan Kumar Halder Reviewed-by: Michal Orzel Acked-by: Julien Grall --- Changes from - v1 - Removed the duplicate declaration for DECLARE_OFFSETS. v2 - 1. Reworded the commit message. 2. Use CONFIG_ARM_PA_32 to restrict zeroeth_table_offset. v3 - 1. Added R-b and Ack. v4 - 1. Removed R-b and Ack as we use CONFIG_PHYS_ADDR_T_32 instead of CONFIG_ARM_PA_BITS_32. This is to be in parity with our earlier patches where we use CONFIG_PHYS_ADDR_T_32 to denote 32-bit physical addr support. v5 - 1. Added R-b and Ack. v6 - 1. No changes. xen/arch/arm/include/asm/lpae.h | 4 ++++ xen/arch/arm/mm.c | 7 +------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/include/asm/lpae.h b/xen/arch/arm/include/asm/lpae.h index 3fdd5d0de2..7d2f6fd1bd 100644 --- a/xen/arch/arm/include/asm/lpae.h +++ b/xen/arch/arm/include/asm/lpae.h @@ -259,7 +259,11 @@ lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned int attr); #define first_table_offset(va) TABLE_OFFSET(first_linear_offset(va)) #define second_table_offset(va) TABLE_OFFSET(second_linear_offset(va)) #define third_table_offset(va) TABLE_OFFSET(third_linear_offset(va)) +#ifdef CONFIG_PHYS_ADDR_T_32 +#define zeroeth_table_offset(va) 0 +#else #define zeroeth_table_offset(va) TABLE_OFFSET(zeroeth_linear_offset(va)) +#endif /* * Macros to define page-tables: diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 5ef5fd8c49..e460249736 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -233,12 +233,7 @@ void dump_pt_walk(paddr_t ttbr, paddr_t addr, { static const char *level_strs[4] = { "0TH", "1ST", "2ND", "3RD" }; const mfn_t root_mfn = maddr_to_mfn(ttbr); - const unsigned int offsets[4] = { - zeroeth_table_offset(addr), - first_table_offset(addr), - second_table_offset(addr), - third_table_offset(addr) - }; + DECLARE_OFFSETS(offsets, addr); lpae_t pte, *mapping; unsigned int level, root_table; From patchwork Thu May 18 14:39:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Kumar Halder X-Patchwork-Id: 13246916 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 51444C77B7D for ; Thu, 18 May 2023 14:43:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.536420.834738 (Exim 4.92) (envelope-from ) id 1pzepx-0003lI-9T; Thu, 18 May 2023 14:42:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 536420.834738; Thu, 18 May 2023 14:42:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzepx-0003lB-68; Thu, 18 May 2023 14:42:37 +0000 Received: by outflank-mailman (input) for mailman id 536420; Thu, 18 May 2023 14:42:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pzepv-0003kU-MI for xen-devel@lists.xenproject.org; Thu, 18 May 2023 14:42:35 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20602.outbound.protection.outlook.com [2a01:111:f400:fe59::602]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 39761814-f58a-11ed-b22c-6b7b168915f2; Thu, 18 May 2023 16:42:34 +0200 (CEST) Received: from BN9PR03CA0320.namprd03.prod.outlook.com (2603:10b6:408:112::25) by PH8PR12MB6961.namprd12.prod.outlook.com (2603:10b6:510:1bc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24; Thu, 18 May 2023 14:42:30 +0000 Received: from BN8NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::a8) by BN9PR03CA0320.outlook.office365.com (2603:10b6:408:112::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 14:42:30 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT065.mail.protection.outlook.com (10.13.177.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Thu, 18 May 2023 14:42:29 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 18 May 2023 09:42:29 -0500 Received: from xcbayankuma41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 18 May 2023 09:42:27 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 39761814-f58a-11ed-b22c-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kEXfwzU6VoApqgyxVB3k7eR/qeEpzyqikzzA+lp3LwD+CSpMml3MzBfPuun6t4H9k7B9oNYx1AxvJFIlt6bBrGwa3PA/4JHHjIVtSL1su7mb88SetivxZ3VLaVp7XZpdXbbVfDGKwJ7WNKLWRSK8/qMQNuwpPdaN4lcewwuddHIB4F+iLebbN7Aos0A64VBpPBCeykKDEK8F+SbL4iTnneqyTRX28xAZLDKdNaCDE01ycp803GBVxE7KK+RZV8MgPwMYqL0/stzJyD+tKYxDVwDMO80kEWrMpexNtm1qa6puB4RMTSg1pnLKfOSwVRNmU7KrX0DORwWOH57PeF91Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=M9J/5ThoetEUno6+i8DrRu1jgcNPeeZ3w3OXUkCp52Y=; b=I+QM4nORvC6tA/vLOZTiia1jZ5y081VwqSyMKSl5w71GS/53GKuICTnBuTv1x9/CPxkc0SmQ+I16nkbOogXhZJJ/NyO3fSred/1Dnd939vJp5XsyqqyqWff+flnMHFb5PE3Ieh9F88qASi5aG112ZpdNYki9bRIENGXHNTRwUuYTbpl+ImOfZwnX8u48FSq9KQVOV/M5raQEoKHN5KRlZi9XicE1+ONfWJ9ZuEgyWyVZrU3loG/sfpfokaa3ZfDgZ6R+Odhf6ldLM/fHfL1wIrICO3Nwb/CrAF/Diyx/9APpSvtGo9xTr2lA/+N6+PPTDgJ96tN6MemmngeC/mz9gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.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 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=M9J/5ThoetEUno6+i8DrRu1jgcNPeeZ3w3OXUkCp52Y=; b=b+iGFAU602aOhWComooD9HzBGj81gEbGY6fJRSQvuZ54Hwdxh1lkQy2uLZGda43UOoiNiNpmKOuFQaxAOYqOaI/DwPxrNGOkm0PQ8OXuod0H+SWQtUlVOtXQQlo1tvb9qZxKcisExyJ9s7BkpH4fGu7Ucw5qcS6IlVDRfYfELsY= X-MS-Exchange-Authentication-Results: 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=SATLEXMB03.amd.com; pr=C From: Ayan Kumar Halder To: CC: , , , , , , , , , , , "Ayan Kumar Halder" Subject: [XEN v7 11/11] xen/arm: p2m: Enable support for 32bit IPA for ARM_32 Date: Thu, 18 May 2023 15:39:20 +0100 Message-ID: <20230518143920.43186-12-ayan.kumar.halder@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230518143920.43186-1-ayan.kumar.halder@amd.com> References: <20230518143920.43186-1-ayan.kumar.halder@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT065:EE_|PH8PR12MB6961:EE_ X-MS-Office365-Filtering-Correlation-Id: 7efc5c60-cf6f-4e54-b064-08db57ae1b6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pTgoIEc+qksOtZzpFWX/aRxYRbHyE3smwQR+oM4eLzI0kmyuuqrkLg5+QtgGN/tkJdIPwXajxygGUC5V3hA2eOH9XHv6F/0eDI/+28DI1K6kXbsIxFoklzCcV14SP4BHTx1v3mK2rZ56Ubfys78mqIHl40rryW4FKsnfEBG0w55znkScPiTKDWdvf2oMDrJ0wJiSICXjpHprmM+bQbWDxJrv/MJ3w47TlIjYBjmkI7LXuCPcV0s6m5xBvqzRTB8vBoMA24QQtZcI847djFwHW50nS2vFhMEI0cM7UOyKledWbZCpTiBu6wPk5or1U3d0hevmCbY6c20xvhtmGaWeSsIh/y7RAWM6R4iAxqOLb46W28unFRIf7InclsE5hsEobEK7vUb5Dek0V6xOItMKbQNmYcVduXEPh+m3F/vjME/qVnh6Mt75NiAcAfhTuhv0kn08Yjab1kX+gX4ZfN91Q0eKk0DN+VJWliaPjIij2qJOuZAa1CljC1QmrtCILkD9NcUSANiYVOBYbRljwQfMXyHYXCb1MVS9tXyqvAVQLBcPNU0ACSLp7ub0ztwUodWugS/XV7GN9L76lPxPX18U/tr4UgQ48S02zr/cOTIjWUCUZG2B7+JnPU1ez5Y1zWpTP4viVhh3wtqOfYlw/CumWr602jT+8iApxXxjgxgYRvlmoZPtsrSFXj3xMnMnt0ZbnsbKu4UwSmcifTjtY5RQKqnq9geuXGi2YiZDooVKlMIqmTEHPY2Xk2fHjgkkILBNeUXWjcJXj4BWp67HxpMR6w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(7416002)(8676002)(8936002)(186003)(1076003)(26005)(336012)(426003)(83380400001)(47076005)(36860700001)(5660300002)(2616005)(6666004)(41300700001)(82310400005)(356005)(103116003)(70206006)(81166007)(40460700003)(54906003)(2906002)(316002)(4326008)(478600001)(82740400003)(40480700001)(6916009)(86362001)(36756003)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 14:42:29.8556 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7efc5c60-cf6f-4e54-b064-08db57ae1b6b 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6961 Refer ARM DDI 0406C.d ID040418, B3-1345, "A stage 2 translation with an input address range of 31-34 bits can start the translation either: - With a first-level lookup, accessing a first-level translation table with 2-16 entries. - With a second-level lookup, accessing a set of concatenated second-level translation tables" Thus, for 32 bit IPA, there will be no concatenated root level tables. So, the root-order is 0. Also, Refer ARM DDI 0406C.d ID040418, B3-1348 "Determining the required first lookup level for stage 2 translations For a stage 2 translation, the output address range from the stage 1 translations determines the required input address range for the stage 2 translation. The permitted values of VTCR.SL0 are: 0b00 Stage 2 translation lookup must start at the second level. 0b01 Stage 2 translation lookup must start at the first level. VTCR.T0SZ must indicate the required input address range. The size of the input address region is 2^(32-T0SZ) bytes." Thus VTCR.SL0 = 1 (maximum value) and VTCR.T0SZ = 0 when the size of input address region is 2^32 bytes. Signed-off-by: Ayan Kumar Halder --- Changes from - v1 - New patch. v2 - 1. Added Ack. v3 - 1. Dropped Ack. 2. Rebased the patch based on the previous change. v4 - 1. t0sz is 0 for 32-bit IPA on Arm32. 2. Updated the commit message to explain t0sz, sl0 and root_order. v5 - 1. Rebased on top of the changes in the previous patch. v6 - 1. Removed the index for ARM_32. xen/arch/arm/p2m.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 755cb86c5b..08b209e7c9 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -2265,6 +2265,7 @@ void __init setup_virt_paging(void) [6] = { 52, 12/*12*/, 4, 2 }, [7] = { 0 } /* Invalid */ #else + { 32, 0/*0*/, 0, 1 }, { 40, 24/*24*/, 1, 1 }, { 0 }, /* Invalid */ #endif