From nobody Mon Feb 9 19:30:00 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+62145+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594126122120517.653536122938; Tue, 7 Jul 2020 05:48:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vzqNYY1788612xL7Y60J5ZEE; Tue, 07 Jul 2020 05:48:41 -0700 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.85]) by mx.groups.io with SMTP id smtpd.web11.15382.1594126120807950686 for ; Tue, 07 Jul 2020 05:48:41 -0700 X-Received: from FR2P281CA0009.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::19) by VI1PR0801MB2077.eurprd08.prod.outlook.com (2603:10a6:800:8b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.29; Tue, 7 Jul 2020 12:48:36 +0000 X-Received: from VE1EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a:cafe::34) by FR2P281CA0009.outlook.office365.com (2603:10a6:d10:a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.8 via Frontend Transport; Tue, 7 Jul 2020 12:48:36 +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=bestguesspass 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+62145+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 VE1EUR03FT007.mail.protection.outlook.com (10.152.18.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Tue, 7 Jul 2020 12:48:36 +0000 X-Received: ("Tessian outbound 2dd9eeca983c:v62"); Tue, 07 Jul 2020 12:48:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 13fa135319de1c00 X-CR-MTA-TID: 64aa7808 X-Received: from 5d1836d1b25c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AC1AD02E-0C6E-436D-82FB-E2C603F20E7C.1; Tue, 07 Jul 2020 12:48:30 +0000 X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5d1836d1b25c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 07 Jul 2020 12:48:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JWLE0XMu2K+DwSEfcn/3aPz2QXKVkcNapdlNk1m4sBVUjLT28HdpZI4mAQlCZW84bsEplAvZYKmA8znXVFFs9XqcAYKm2YJ8Uns6o06kVGWb2RUS9IzlW/HGsHF9UtJ72+sIfL/ns+rTmGaXRmzVTg9c9tKMGP8dKUctaNXSL4Bn7xF9A++LUlCa9HNpP8kvCp7gl37HfedBzWUQfu5ytlDejApeu0oDWHdmz/SaiR9k2IFtbaVoRQjmzkLxEklHyHmqBG9ccHv0MtSvf50MsfxHkEgCVHTiymm1miKvKp+3NBf1dUNvN7TwqQtC3E2QVgk521BsD1b+61WMJm1xiQ== 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=ISuUmMsefX5IsgSOtlJ4XTZT/QuX/hhcTvmCvZEEtgQ=; b=diErLUFMmSZcgHMtEQVFicu/9lU/Y0TeRwzaTKmoRgykJQ2oN2CFaluD8xPkUfPKvDEi7dE5IHZ7AgUAEO933VFDo5QyK95NBVGkh5BHOFap4FsqAc3U2h6ex1vgHLChPliroSx74qMas0Ar81xJhFJGg126at6YBB4HyfcG26DnOj0UMpr10Qis4IEfD5vXniBJeXsz3VQZJLBRF5Qf1Ri1PNB+6DeMpANwW6nVvNN1igZu0wf/gZeVmzgGWnjSucJv4Nc3Eky78OKIWhpm5Ber3qaiWDEIiW4abEuqWF2giArsG7+3GGiiWlCEOns0n+KbZtVRDPYTBgf0FIIR8A== 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=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AM6P194CA0096.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::37) by AM0PR08MB3377.eurprd08.prod.outlook.com (2603:10a6:208:d4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23; Tue, 7 Jul 2020 12:48:29 +0000 X-Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::9f) by AM6P194CA0096.outlook.office365.com (2603:10a6:209:8f::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Tue, 7 Jul 2020 12:48:29 +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=bestguesspass 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 VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3153.24 via Frontend Transport; Tue, 7 Jul 2020 12:48:29 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.1415.2; Tue, 7 Jul 2020 12:48:17 +0000 X-Received: from E107187.Arm.com (10.57.21.15) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Tue, 7 Jul 2020 12:48:16 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [edk2-devel] [PATCH v4 05/15] ArmVirtPkg: kvmtool platform memory map Date: Tue, 7 Jul 2020 13:47:59 +0100 Message-ID: <20200707124810.50668-6-sami.mujawar@arm.com> In-Reply-To: <20200707124810.50668-1-sami.mujawar@arm.com> References: <20200707124810.50668-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant 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;SFTY:;SFS:(4636009)(396003)(39860400002)(376002)(346002)(136003)(46966005)(6916009)(336012)(7696005)(82740400003)(47076004)(186003)(6666004)(316002)(356005)(86362001)(26005)(4326008)(8936002)(54906003)(81166007)(82310400002)(8676002)(966005)(478600001)(70206006)(70586007)(44832011)(426003)(1076003)(2616005)(2906002)(5660300002)(36756003)(83380400001);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 397902f2-75c2-4fc0-84e6-08d82274108c X-MS-TrafficTypeDiagnostic: AM0PR08MB3377:|VI1PR0801MB2077: 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: bu/nhoW3dWvskjrybU9lh7OFosl8dr/abb/X3mecC+KgEWYsP3IS62CtUOHbq+q6lLwoVMf1JFnwoQdGELBu6w3YbBqRXyzIJ1s3kyRPBHjJ3c3KpmZqezTZcXT341wFCllnHvCiDwMRr5mgZIvP9134s/WyYkDrw2xhmDm4h9IjRbFK7q0vHlOvjOd3DK/V8se19k3ijFFrAjMvMGVbaWPRupfjlireGQKNgyebDk0PF14cKP9q2u1nIgYrVZ34Vtm7l2sx7VqUlNnkpuzARNJdo0FudLwaaAIk9LZ+h5gFkh8bEYcngy3eBzjEFycF5FrBSPt1T8XbHUxE+IDZkw0bVTnSJBgihhHPS+WVrY7BuqxEo+5QJzDcS+wjRB6mS5xl1lzqaPFmbfdQPT3WuCLOiutVoMuq9ZM+SrnuqLjES/V0LBrA9WVw7tV03ZxAA0hMwpRlSyzBz6F3qpHEsSOKDD1BBneoeQdS5DFUUek= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3377 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bd3326b1-fce4-4138-b5b6-08d822740c59 X-Microsoft-Antispam-Message-Info: p9k3X6XmnqWViirLyBQxl2d6WEu76B+d7AdkT0XomBA209JZdFjfy2XRtPb4bL1LJLPCwcZQbzfy9y3QPqwQjZshUPFY0Q2iiXLSxtSSQChf34g5LQqxcOCCIkFHhJZX58tj8XFg9bVBOGY+w/v9lckS+DVnWAURo0ImLtY/mnxVMhWEyU+7iL7QPvU69bnWFfTFqb0qTrw9LvIGZYRMia28S3umjP9WIv50ZZbVEsgOnS3mw8FNE2qkI8McTNFLZWXkcIEN2jO4BzajorixqsDnNtnDdCZmHNzg2YGB/EAuTiuJuZZTTZNr1yfRmKQJGXpMtKR7p9tGaujlMIP5Y4MQcfOw9SXgmt/ZUazvIaPGIlxb/hdapPLb7+bDKefK5jKXfTbVPDLXVnm/vrcsFCxUpB/TTGxdgyitHh0Hf9+KWppQ9eeKUKt20mTJiCmRMj8JogZszipgvwCag5JjXkZGRWCN07EEwMU1WF8e/qg= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 12:48:36.0980 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 397902f2-75c2-4fc0-84e6-08d82274108c 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: VE1EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2077 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: PluTgY9b0SLMZ6XJVJWuNQFfx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594126121; bh=QnyCjSzBzDV2rd8UtLWHAKieoFWveDtr8+zJpXq27Z8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=eJR8ab1VjoHJTmTulfxu6JrbJ/pVCuBH41Fd0rL8uEYjkBeVwG8bI8Dd3dSRiE2YU/y f8OarRJ0OJdxcUjC8Cpoj76FYlpSnNyVoLxymCZejJro6dgMYvgXZImP86YVqaaYl88I2 vHqrlYGmYrljEcyCOIKOR/SJFu42pkAY9ts= 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: 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 | 96 ++= ++++++++++++++++++ ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf | 42 ++= +++++++ 2 files changed, 138 insertions(+) diff --git a/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib= .c b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c new file mode 100644 index 0000000000000000000000000000000000000000..50e805b252d7564ac4770162eb6= 8eddfc1153d4b --- /dev/null +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.c @@ -0,0 +1,96 @@ +/** @file + + 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 =3D 0; + 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; + } + + // 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..dbf4ceabe3ae0db5e743e1d9a57= 5542dca32ed0a --- /dev/null +++ b/ArmVirtPkg/Library/KvmtoolVirtMemInfoLib/KvmtoolVirtMemInfoLib.inf @@ -0,0 +1,42 @@ +#/* @file +# +# 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 (#62145): https://edk2.groups.io/g/devel/message/62145 Mute This Topic: https://groups.io/mt/75354092/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-