From nobody Sun Feb 8 18:24:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+65858+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1601673276031692.5209840645924; Fri, 2 Oct 2020 14:14:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5G37YY1788612xkf8SMmjcah; Fri, 02 Oct 2020 14:14:35 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.80]) by mx.groups.io with SMTP id smtpd.web12.5583.1601673274255340087 for ; Fri, 02 Oct 2020 14:14:34 -0700 X-Received: from AM7PR04CA0027.eurprd04.prod.outlook.com (2603:10a6:20b:110::37) by VI1PR08MB2848.eurprd08.prod.outlook.com (2603:10a6:802:23::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 2 Oct 2020 21:14:26 +0000 X-Received: from VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:110:cafe::8f) by AM7PR04CA0027.outlook.office365.com (2603:10a6:20b:110::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.36 via Frontend Transport; Fri, 2 Oct 2020 21:14:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+65858+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT031.mail.protection.outlook.com (10.152.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34 via Frontend Transport; Fri, 2 Oct 2020 21:14:25 +0000 X-Received: ("Tessian outbound bac899b43a54:v64"); Fri, 02 Oct 2020 21:14:24 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 28d30adc3747670e X-CR-MTA-TID: 64aa7808 X-Received: from e93ae44121dc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4D3916D4-CFAB-47B0-8D4D-A2B453E6CDB0.1; Fri, 02 Oct 2020 21:14:18 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e93ae44121dc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 02 Oct 2020 21:14:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UR1sc9yIbjUs/9do943UK5zoCFB+5lfH85N1Kxj7jpU23PkBMj6Aixyy3tj9CBUaDcLvSXPMcFfISmE6Ly3PA5u5/tNZ7R8XXErSZN5mQukoQXcRb8k3EsRvIY859VhzM5SI3K4WJwjm0kMyoU5drzhZf9ePKCZlcdi/dbLdQdWrequA3l2nZQ9ykYvC5M1r1OGnYNbyQwrGUrvpHQqOnav3dgCJfCftUEA+WL+lWwOlLk6tI8lzkslgOezwks4PxFcQoNZtPtgCgRinGSf2ue8CednpbpKcJj3IrLav2bfmYrvc/T7eYVlqHF58EO2n+wXQ62TSBZ2DD6G7E98/xw== 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-SenderADCheck; bh=EfcV1P3dWHIJUTVppSkzpGIIxiobeB1jvJvI6xxfnSo=; b=ka839vEHTyjNxEZkVb0z0cdGsuFvKkVvixDAfl+C+5o783VH15wy6sd9ItX1Q86vyzQIFEsBffZ4YoCqDIwI50hhMOICXzu05IYpnU6ojH9Z/sUEI5zZuOZzlLUa9cKWRTS1CaX8cI4TX9de/iaHOrSH9BLLM+DB9CiAR9o7tPOyCcB65iCXmq/RAlrMHBTI5KTyOAyu30FyPNi0s/6ogdbIZvoPrvPVHLleHvTeOTFfBlqT04SNh58C37bEHCyxb12E4bkXyOIkLeU+9Z3F3BjL2rFUt43rcOT4RF1iIvOgqcm7oDB5ghTbW552Z8MrBvpNnkTaheAHxkL7Ik6/TQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AM6P194CA0038.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::15) by AM6PR08MB4738.eurprd08.prod.outlook.com (2603:10a6:20b:cf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.37; Fri, 2 Oct 2020 21:14:17 +0000 X-Received: from AM5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::14) by AM6P194CA0038.outlook.office365.com (2603:10a6:209:84::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.32 via Frontend Transport; Fri, 2 Oct 2020 21:14:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT037.mail.protection.outlook.com (10.152.17.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3433.34 via Frontend Transport; Fri, 2 Oct 2020 21:14:17 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Fri, 2 Oct 2020 21:14:15 +0000 X-Received: from E107187.Arm.com (10.57.53.44) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Fri, 2 Oct 2020 21:14:14 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [edk2-devel] [PATCH v5 05/15] ArmVirtPkg: kvmtool platform memory map Date: Fri, 2 Oct 2020 22:13:59 +0100 Message-ID: <20201002211409.43888-6-sami.mujawar@arm.com> In-Reply-To: <20201002211409.43888-1-sami.mujawar@arm.com> References: <20201002211409.43888-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22323522-fecd-424a-b98c-08d867182436 X-MS-TrafficTypeDiagnostic: AM6PR08MB4738:|VI1PR08MB2848: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1hJDoc9NlkRHRunJ/JDZP7z82vO9Sx40QkR6L6m8SVqOeL6Mj8+d6PpqIglOMtULcmqtQ1C2rET06nBx0pJR9k7q90fndMb9nKbfwwb6nHnlEVJUY819nYI3KrXjeuswz/YyD/HXETJ9lTfQt0bt9leQE4DFQnr6VG7GW8eXUiWF8OdivwwxLCzJbYfBqLaMs+hc4THWNe64DVgOlAgSFmR4GY7X25Q/TKic2BHbZ/OQPPJ54bJB7svTnqpRjcBeLlLQBa2XM3SwXCjvzT+rhZ5N9tNBx/WWKLvznI/j6BnZCtjOXG+ngJQDEOlzU3p69X11VD4F5qouCXUmUkxpZ6xOm9964bifUv9gHT2674wqkzq6cDfepjoKCQuMEHV9CtrNy51NtIhXt877xNrVF8/wkAVGLvExRndWQVEMKZqQRPnYjJCwhQPKAK3k4/nWcptzZKVziTgd96FTlTfK1UVUkh5749YQNgSOVm7oTQs= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(39850400004)(396003)(136003)(346002)(376002)(46966005)(47076004)(7696005)(44832011)(8676002)(5660300002)(356005)(82740400003)(966005)(8936002)(36756003)(81166007)(83080400001)(478600001)(186003)(336012)(4326008)(6916009)(426003)(6666004)(70206006)(26005)(86362001)(2906002)(83380400001)(82310400003)(1076003)(54906003)(2616005)(316002)(70586007);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4738 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ce1ceada-4d01-4001-d1d3-08d867181f2d X-Microsoft-Antispam-Message-Info: fL0sV9CFMN7xSkwbmE03R10Eagd0YrGFDj9Qo6TK1Z4nDHX2kH3dYDzdV/UBkJ2D+NW4bnxqaO7AgmRInIDfC0zyzuXuJmM1nJljKyCQ8WMX89kdNK8PJgubAIHnggnILgI3gL8Z0La/vslhNqUp4NdjdaSfrx/2fY56qSMdfgKnIi2Nbwn8x7OPBcU+VnRL9QMHzxBkGpdwAeCrhDebWhL01hGXoc+Os1x5dpkVPT5VQD8Egv+0pQG7cJjCcA/bplMq/DfsLMRtYnzima4UYyMNzgwY0d345Y5N47A9rSCQ/5M51glf0VhEgKB2Fmzw+TZwDDuoNeEIBIWDd5SO/danvKKXmkBilnmEzIrT/t60Vzq2STd2TfeJWM9LbNqfo14AbGCtnFug/VE+NT3YTCztWOlGbJYrC11JwPTul22PHtU4Xj7HsJs45I3RqQfoDjL/tXwYhyf5Efd/pFHOWMdDBPRyK1NqYX0ob/YunvjqPWw0VLXcgJcD19eX8xXOkqOop9La3e/0EcG3mqQnSQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2020 21:14:25.6169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22323522-fecd-424a-b98c-08d867182436 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2848 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com X-Gm-Message-State: 51QVlozlGJZMh0OovUbr6nHZx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1601673275; bh=W5Uf9FZHT8ByCO57y6+YWfrfQQzRaxgTND20jWS+XV8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=jGJwLgUzynYC/O8VpL4+0nu0gKAk3az/nIti3MDpgfj8cimbpt6AJwZr1cnzq9LijOw 9JSBB6r2rakIQ6xQDIT0HUmh+AcG942jpw/yvLr8XS2yAgRzwGmdKXNq17DRECtAnbyA6 SkOaFKRhNg9kP1nHDA0NoT5xIhMjemP5F60= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Kvmtool is a virtual machine manager that enables hosting KVM guests. Kvmtool allows to vary the hardware configuration of the virtual platform it provides to the guest partition. It provides the current hardware configuration to the firmware by handing off a device tree containing the hardware information. This library parses the kvmtool provided device tree and populates the system memory map for the kvmtool virtual platform. Signed-off-by: Sami Mujawar Reviewed-by: Ard Biesheuvel Acked-by: Laszlo Ersek --- Notes: v5: - Fixed minor ECC reported issues in file header and [Sami] also a minor fix for ECC error "5007: There should be no initialization of a variable as part of its declaration". Ref: https://edk2.groups.io/g/devel/message/62145 =20 v4: - Remove logging code as this requires support for Early [Sami] serial port initialisation which is dropped in this series as it would not work with Xen. Ref: https://edk2.groups.io/g/devel/message/61669 https://edk2.groups.io/g/devel/topic/75081479 =20 v3: - Fix coding style, use "Txt" in LOG_VM_MAP(txt). [Laszlo] - Fixed coding style and also formatted log output. [Sami] Ref: https://edk2.groups.io/g/devel/topic/74200913#59548 v2: - Library to populate Kvmtool system memory map. [Sami] ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c | 98 ++= ++++++++++++++++++ ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf | 43 ++= +++++++ 2 files changed, 141 insertions(+) diff --git a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib= .c b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c new file mode 100644 index 0000000000000000000000000000000000000000..63bb81ef91ce0d16b604f5606a6= a340647b706ad --- /dev/null +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c @@ -0,0 +1,98 @@ +/** @file + Kvmtool virtual memory map library. + + Copyright (c) 2018 - 2020, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +// Number of Virtual Memory Map Descriptors +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5 + +/** + Return the Virtual Memory Map of your platform + + This Virtual Memory Map is used by MemoryInitPei Module to initialize th= e MMU + on your platform. + + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR + describing a Physical-to-Virtual Memory + mapping. This array must be ended by a + zero-filled entry. The allocated memory + will not be freed. + +**/ +VOID +ArmVirtGetMemoryMap ( + OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap + ) +{ + ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable; + UINTN Idx; + EFI_PHYSICAL_ADDRESS TopOfAddressSpace; + + ASSERT (VirtualMemoryMap !=3D NULL); + + TopOfAddressSpace =3D LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()); + + VirtualMemoryTable =3D (ARM_MEMORY_REGION_DESCRIPTOR*) + AllocatePages ( + EFI_SIZE_TO_PAGES ( + sizeof (ARM_MEMORY_REGION_DESCRIPTOR) * + MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS + ) + ); + if (VirtualMemoryTable =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Error: Failed to Allocate Pages\n", + __FUNCTION__ + )); + return; + } + + Idx =3D 0; + // System DRAM + VirtualMemoryTable[Idx].PhysicalBase =3D PcdGet64 (PcdSystemMemoryBase); + VirtualMemoryTable[Idx].VirtualBase =3D VirtualMemoryTable[Idx].Physica= lBase; + VirtualMemoryTable[Idx].Length =3D PcdGet64 (PcdSystemMemorySize); + VirtualMemoryTable[Idx].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_WRI= TE_BACK; + + // Peripheral space before DRAM + VirtualMemoryTable[++Idx].PhysicalBase =3D 0x0; + VirtualMemoryTable[Idx].VirtualBase =3D 0x0; + VirtualMemoryTable[Idx].Length =3D PcdGet64 (PcdSystemMemoryBase= ); + VirtualMemoryTable[Idx].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_D= EVICE; + + // Peripheral space after DRAM + VirtualMemoryTable[++Idx].PhysicalBase =3D PcdGet64 (PcdSystemMemoryBase= ) + + PcdGet64 (PcdSystemMemorySize); + VirtualMemoryTable[Idx].VirtualBase =3D VirtualMemoryTable[Idx].Physi= calBase; + VirtualMemoryTable[Idx].Length =3D TopOfAddressSpace - + VirtualMemoryTable[Idx].Physica= lBase; + VirtualMemoryTable[Idx].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_D= EVICE; + + // Map the FV region as normal executable memory + VirtualMemoryTable[++Idx].PhysicalBase =3D PcdGet64 (PcdFvBaseAddress); + VirtualMemoryTable[Idx].VirtualBase =3D VirtualMemoryTable[Idx].Physica= lBase; + VirtualMemoryTable[Idx].Length =3D FixedPcdGet32 (PcdFvSize); + VirtualMemoryTable[Idx].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_WRI= TE_BACK; + + // End of Table + VirtualMemoryTable[++Idx].PhysicalBase =3D 0; + VirtualMemoryTable[Idx].VirtualBase =3D 0; + VirtualMemoryTable[Idx].Length =3D 0; + VirtualMemoryTable[Idx].Attributes =3D (ARM_MEMORY_REGION_ATTRIBUTE= S)0; + + ASSERT((Idx + 1) <=3D MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS); + + *VirtualMemoryMap =3D VirtualMemoryTable; +} diff --git a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib= .inf b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..4b0cf06e1e6950d57c397502a77= abd8aa738254d --- /dev/null +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf @@ -0,0 +1,43 @@ +## @file +# Kvmtool virtual memory map library. +# +# Copyright (c) 2018, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D KvmtoolVirtMemInfoLib + FILE_GUID =3D B752E953-394F-462C-811C-F8BE35C8C071 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmVirtMemInfoLib + +[Sources] + KvmtoolVirtMemInfoLib.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmLib + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + PcdLib + +[Pcd] + gArmTokenSpaceGuid.PcdFvBaseAddress + gArmTokenSpaceGuid.PcdSystemMemoryBase + gArmTokenSpaceGuid.PcdSystemMemorySize + +[FixedPcd] + gArmTokenSpaceGuid.PcdFvSize + --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#65858): https://edk2.groups.io/g/devel/message/65858 Mute This Topic: https://groups.io/mt/77270946/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-