From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.73]) by mx.groups.io with SMTP id smtpd.web10.8564.1589445882663404541 for ; Thu, 14 May 2020 01:44:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=QpPK401e; spf=pass (domain: arm.com, ip: 40.107.0.73, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H6IuH6Kk5txaU/bYEpoU/D9lk0xk+zeIYJ9fJUZX+AA=; b=QpPK401ecmgCjm3+DaS07I+jelaHIxtBKxiI1Jz7GySsqc3akBdZbvIH7ZTyC8rWsgZFH1DdeobqOHT3xKecyf5GKF8ibHYSwqeAMPp0zNPBsQhtyEeJC918H5FFHh80+Cc+UnuquK5nhr2jeppWIDMYEWGSO8k0FMfG38BYPLk= Received: from DB6PR0202CA0015.eurprd02.prod.outlook.com (2603:10a6:4:29::25) by DB6PR0802MB2613.eurprd08.prod.outlook.com (2603:10a6:4:a0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.35; Thu, 14 May 2020 08:44:39 +0000 Received: from DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:29:cafe::32) by DB6PR0202CA0015.outlook.office365.com (2603:10a6:4:29::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Thu, 14 May 2020 08:44:39 +0000 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 (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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT038.mail.protection.outlook.com (10.152.21.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19 via Frontend Transport; Thu, 14 May 2020 08:44:39 +0000 Received: ("Tessian outbound fb9de21a7e90:v54"); Thu, 14 May 2020 08:44:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ec51dd582cdf8960 X-CR-MTA-TID: 64aa7808 Received: from 63d4200101c6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B3F236DD-4A3E-47D2-ACD4-1E651DF4357B.1; Thu, 14 May 2020 08:44:39 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 63d4200101c6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 14 May 2020 08:44:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aatnBmAnLi6vDkF0m1Kui2Lh4TO7becXomqM9+cAQq/co11X7Uo73erb0bHgzFvw41uQS9KG+QwbMY9i6Wkm+V50ODD9ZIABysU5dsMw5O57dNziLaM1o618ZANjkQFH47nPPYCPNPioaXZ+CgWS0VS9M6d11Qyj4mVLng8GmOd9t4lJh5UbkKeGCPzOB+6tTsWrbZ3PxA9YomfRfQEfEbx6wCipbd55x6UeAT5utWppWZJLDtuVGOKSTeIR5NAr0H5YbzsjHYPnQwUdswfKjOT1FsDIfURKBlgW1GerBe6CNtfhWlYEPSuRnkA88H5XJVYAvkFVSbej51iwTx6uVQ== 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=H6IuH6Kk5txaU/bYEpoU/D9lk0xk+zeIYJ9fJUZX+AA=; b=d20mi1D1feO/CK6tMBDq0cvK8B1jfdflwW3sYwNHn1MSIrndNjfGIWNU7Egx7tOmZqPS/b3dpgCCEP8Ers3yvaTOeeEYnqx7zxHguZVJo/LcFUyvwTTBpmYzbABI88aEb+5Z//vYVkPri/HRM1Msej3rcuHZwPGZ59J79154sL9I8s/0wxp8a+15iSQ0VmE3UlYr8DbRSimZOMb048jwIiiwPeA0IELSX4Bu3CcZzPkjRAKxwXkxpeTwoCSxH+DJzbfJeaxxPL0V88OnxFQpQdzuofDs2ysuK450IK5b8TA0ZAWdBDM1K6AH8k5uWeg59e9TBdiDrxN20zvvKxWWNA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H6IuH6Kk5txaU/bYEpoU/D9lk0xk+zeIYJ9fJUZX+AA=; b=QpPK401ecmgCjm3+DaS07I+jelaHIxtBKxiI1Jz7GySsqc3akBdZbvIH7ZTyC8rWsgZFH1DdeobqOHT3xKecyf5GKF8ibHYSwqeAMPp0zNPBsQhtyEeJC918H5FFHh80+Cc+UnuquK5nhr2jeppWIDMYEWGSO8k0FMfG38BYPLk= Received: from DB6PR0301CA0049.eurprd03.prod.outlook.com (2603:10a6:4:54::17) by VI1PR0801MB2063.eurprd08.prod.outlook.com (2603:10a6:800:8c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28; Thu, 14 May 2020 08:44:37 +0000 Received: from DB5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::58) by DB6PR0301CA0049.outlook.office365.com (2603:10a6:4:54::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Thu, 14 May 2020 08:44:37 +0000 Authentication-Results-Original: 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; Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT021.mail.protection.outlook.com (10.152.20.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3000.19 via Frontend Transport; Thu, 14 May 2020 08:44:37 +0000 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; Thu, 14 May 2020 08:40:28 +0000 Received: from E107187.Arm.com (10.57.42.179) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 14 May 2020 08:40:27 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [PATCH v2 06/11] ArmVirtPkg: Add kvmtool platform driver Date: Thu, 14 May 2020 09:40:14 +0100 Message-ID: <20200514084019.71368-7-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20200514084019.71368-1-sami.mujawar@arm.com> References: <20200514084019.71368-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)(376002)(136003)(396003)(39860400002)(346002)(46966005)(54906003)(70206006)(186003)(26005)(6666004)(316002)(1076003)(2616005)(7696005)(8676002)(5660300002)(36756003)(336012)(8936002)(70586007)(6916009)(86362001)(44832011)(426003)(356005)(966005)(2906002)(47076004)(82310400002)(82740400003)(478600001)(81166007)(4326008);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca76942a-f07f-44f4-fdad-08d7f7e309da X-MS-TrafficTypeDiagnostic: VI1PR0801MB2063:|DB6PR0802MB2613: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-Forefront-PRVS: 040359335D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: a6+azvujQoJYZdds+7AKsNK3kp5L4cZtdlWI7zkP4sn0X6QaZ9WuT4ACe3+ORP6odpgKGYNVeH7vGt8xmhGX0KgAipWWVjMTcy9Lw9izdxAwJtj0/RiYYVCf1n06QlLYKSdiWAl/b9KCQM7AOWHhpFI9wsdr6RX0yUxSy8+c1cn8VIMUn8+JmR7VkBw0HT9iLYSM6RtZfdV8TJszpB5dRnTVoSFysAWuM9jeQxik7N/KIIcjmC5nPpEApGVg6hpN2Gm2/pVHybU7Pwproi3YDfCaXJ2wd9h/a3laSjXctlxOxnjmpbdznNDDbdWKckSieYUzH9TzkRSdN+Vk09lu55fOVA8NYf066EvfHtRTwYsDSVNEJ3mThwUXzKO8NEmeogwBqhJ1m5q5aL0TaFEXKH9Jr7t/NmhunuEcu/SFjEC/Q7L2yz1bWMCa+/pJWYsXLygmxUQfgUryQ0+n5ceQA6lU/DzVc3clu0YKwODKemIrgJ7Bmoy80tdfGm8XQxq6IEurV7Ew+6FYJuo+IGX5g0T7L8Bl4z3Y2fXILdhE6IDZ4+EGKA+SmQEYWvDUerLdhDUJeX9L4xawfz/prQ3cg5o7kv9f3VzgbJiADH+54W0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2063 Original-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; Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFTY:;SFS:(4636009)(136003)(396003)(39860400002)(376002)(346002)(46966005)(186003)(8676002)(47076004)(5660300002)(26005)(316002)(70586007)(82740400003)(6916009)(6666004)(54906003)(82310400002)(70206006)(8936002)(81166007)(2906002)(426003)(7696005)(1076003)(36756003)(2616005)(478600001)(4326008)(44832011)(86362001)(966005)(336012);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 55d68cb7-5e30-4c1c-5cd9-08d7f7e308c1 X-Forefront-PRVS: 040359335D X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kwq8WYONyn8EuBIbKTEBenNBc9/cuLEBbwKiguK3+UvK5Qn+1JGRnNdoP7/pJV//eHj/v7eUHUpdY4TVSKAQMT8rMAlomkvKGV8rM/ci/CDkA74L716E9nv2DsQXQo5tYcUpEMoD+YaOHy/dN49vHHL0iILxMWnmBrCMOApvSPZQkRmaj1ELJJGZwU/r+eOgKtV4HtNNBJvzvhQH/Pj3RQtCthdzmzTNitmXAPG+Hy1iNu4+shCipwRBGFxKiuzpatZt1A4jVZ4UcEEGNeRC2dD2XIOiB7mBJddppN3v+2ji2n5dlKaeOLbV1tY+byN5jZK6Kcd0b+jIuErmqkzWYCzNlA/upfjHMEEc0VOkGNENW/fHVTQ78sGPwfgc2A+KB+XeaudvXfTpH+zAgtSRGj1lmcLZsot9Jo8yt4kIoKrmVGaLcvEF4CZER23w65j9gJOqQWjBDxBZ3lY+5FRWxx1Kj0qUd3soLmErY6pjiH2qKWT+6FCWUaw5f7zVn1L/vXJ900BB1LRVAe6bMTIcfbCWbe8a+mBCNu5r1Yl+6A7blRlCXLKhGohG/Kpbne19Jy4YDNKGDbh2mE63oy5cWDGvWRytOA/yfFJJe1srs7o= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2020 08:44:39.1128 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca76942a-f07f-44f4-fdad-08d7f7e309da 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2613 Content-Type: text/plain Kvmtool is a virtual machine manager that enables hosting KVM guests. It essentially provides an emulated platform for guest operating systems. Kvmtool hands of a device tree containing the current hardware configuration to the firmware. A standards-based operating system would use ACPI to consume the platform hardware information, while some operating systems may prefer to use Device Tree. The KvmtoolPlatformDxe performs the platform actions like determining if the firmware should expose ACPI or the Device Tree based hardware description to the operating system. Signed-off-by: Sami Mujawar --- Notes: v2: - Updated according to review comments. [Sami] v1: - Add kvmtool platform driver to support loading platform [Sami] specific information. - Keep code to initialise the variable storage PCDs in the [Laszlo] platform-specific FVB driver. - Document code derived from [Laszlo] "ArmVirtPkg/PlatformHasAcpiDtDxe" Ref: https://edk2.groups.io/g/devel/topic/30915278#30757 ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c | 93 ++++++++++++++++++++ ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf | 47 ++++++++++ 2 files changed, 140 insertions(+) diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..e7568f66f5ebeb0423fc1c10345cd8dad0800d94 --- /dev/null +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c @@ -0,0 +1,93 @@ +/** @file + + The KvmtoolPlatformDxe performs the platform specific initialization like: + - It decides if the firmware should expose ACPI or Device Tree-based + hardware description to the operating system. + + Copyright (c) 2018 - 2020, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/** Decide if the firmware should expose ACPI tables or Device Tree and + install the appropriate protocol interface. + + Note: This function is derived from "ArmVirtPkg/PlatformHasAcpiDtDxe", + by dropping the word size check, and the fw_cfg check. + + @param [in] ImageHandle Handle for this image. + + @retval EFI_SUCCESS Success. + @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the + protocols. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + +**/ +STATIC +EFI_STATUS +PlatformHasAcpiDt ( + IN EFI_HANDLE ImageHandle + ) +{ + if (!PcdGetBool (PcdForceNoAcpi)) { + // Expose ACPI tables + return gBS->InstallProtocolInterface ( + &ImageHandle, + &gEdkiiPlatformHasAcpiGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + } + + // Expose the Device Tree. + return gBS->InstallProtocolInterface ( + &ImageHandle, + &gEdkiiPlatformHasDeviceTreeGuid, + EFI_NATIVE_INTERFACE, + NULL + ); +} + +/** Entry point for Kvmtool Platform Dxe + + @param [in] ImageHandle Handle for this image. + @param [in] SystemTable Pointer to the EFI system table. + + @retval EFI_SUCCESS Success. + @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the + protocols. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + +**/ +EFI_STATUS +EFIAPI +KvmtoolPlatformDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status = PlatformHasAcpiDt (ImageHandle); + if (EFI_ERROR (Status)) { + goto Failed; + } + + return Status; + +Failed: + ASSERT_EFI_ERROR (Status); + CpuDeadLoop (); + + return Status; +} diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf new file mode 100644 index 0000000000000000000000000000000000000000..08a0fe5ce14469133479046385bdd48c22698639 --- /dev/null +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf @@ -0,0 +1,47 @@ +#/** @file +# +# The KvmtoolPlatformDxe performs the platform specific initialization like: +# - It decides if the firmware should expose ACPI or Device Tree-based +# hardware description to the operating system. +# +# Copyright (c) 2018 - 2020, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = KvmtoolPlatformDxe + FILE_GUID = 7479CCCD-D721-442A-8C73-A72DBB886669 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = KvmtoolPlatformDxeEntryPoint + +[Sources] + KvmtoolPlatformDxe.c + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + DxeServicesTableLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Guids] + gEdkiiPlatformHasAcpiGuid ## SOMETIMES_PRODUCES ## PROTOCOL + gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL + +[Pcd] + gArmVirtTokenSpaceGuid.PcdForceNoAcpi + +[Depex] + TRUE -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'