From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.82]) by mx.groups.io with SMTP id smtpd.web12.13750.1593005729377638573 for ; Wed, 24 Jun 2020 06:35:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=ZSIcuj5T; spf=pass (domain: arm.com, ip: 40.107.7.82, 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=LOcZL0hrG1r4/eWhiYF9d2o2SATvN6junhmKLejLRLA=; b=ZSIcuj5TsPy4kiUm+Bgbo26lzAy8APqxfYIWrfSxPkQmOzJbfAc3q+EWkVkPWkbQlcHKTTcUvEUTxt00u+0DSEF8QGYXSNnXDbne9vmCI7/1IuqwshHGelNUL8wfJcKC/XJX3FQ7HQiQ7yBPz/ufoeSYwWOcdf46fF9uBOU0V4M= Received: from DB6PR07CA0095.eurprd07.prod.outlook.com (2603:10a6:6:2b::33) by DB6PR0802MB2326.eurprd08.prod.outlook.com (2603:10a6:4:86::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Wed, 24 Jun 2020 13:35:26 +0000 Received: from DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2b:cafe::1e) by DB6PR07CA0095.outlook.office365.com (2603:10a6:6:2b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.12 via Frontend Transport; Wed, 24 Jun 2020 13:35: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=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 DB5EUR03FT012.mail.protection.outlook.com (10.152.20.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Wed, 24 Jun 2020 13:35:26 +0000 Received: ("Tessian outbound 8fb20e43acb7:v59"); Wed, 24 Jun 2020 13:35:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4c334366ce55299d X-CR-MTA-TID: 64aa7808 Received: from 4287c613ae22.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 298422FC-83FC-4AF9-A666-2F9E37489C43.1; Wed, 24 Jun 2020 13:35:20 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4287c613ae22.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 24 Jun 2020 13:35:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HzuNcYTV/GWCT7nl84P7Gwix41TKJVNQ64C5T1OQxuVNXoV5oVPgoVeKzm5pAgaSBC0/X/dIKVeCdbcKhjLZRnuXVk8fJgC0bfYecLfUuL8CDgbjT2rJ2I2J3M0Pyss6KWfDWHrKHzPBv9a+QtXGUqbMeUdpmpKCd/mhtc30OhXKMTabGQ7E30YKFvZrjSVurESJJKzN5Pvm1/l1dqwmPiMOi8VxcUGXw6F+YMwacgLXhgl74oid2hEmmYjifcIjcQG+qqS2ymOVEo27YiYpYwgh7qDsDZv9ppFGUWnNx1ANfFamuVCOf29AkO9EOdBy+N/sSl4PqztWH3vQmcXB0A== 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=LOcZL0hrG1r4/eWhiYF9d2o2SATvN6junhmKLejLRLA=; b=oOMdtCSHnGaxXpi8MKSVTGQeCd+KTp7h9wGvCs8QE6pj84ZV7Vk8o7KSluo2D2ISoqfwnXU76uNErWTLaG33QOjMQBzZMQSQJqY3l9d3CNcK0oJ7BAsNYgfMlpyEpeqYBGbMVQB3LgeqZSKnv1t+1q0VZJTSbS3pbWmgbVORoob93gOiLrFkn3XqUZ7W4V73zgzWtVViWh1AmlNP8VdrlqwCXvwcgIcCIN/c4Gf8xRghhL72atNEvaMzFEbWtoe6aU4aedYjnNLTXLn7JSaZoMTmdFrSd5HQWcdCl60/GmvWgii6F/K1uXxuyowJLef88/dkpzK9i1aBATBy4ZOpnQ== 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=LOcZL0hrG1r4/eWhiYF9d2o2SATvN6junhmKLejLRLA=; b=ZSIcuj5TsPy4kiUm+Bgbo26lzAy8APqxfYIWrfSxPkQmOzJbfAc3q+EWkVkPWkbQlcHKTTcUvEUTxt00u+0DSEF8QGYXSNnXDbne9vmCI7/1IuqwshHGelNUL8wfJcKC/XJX3FQ7HQiQ7yBPz/ufoeSYwWOcdf46fF9uBOU0V4M= Received: from AM6P194CA0050.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::27) by AM0PR08MB4370.eurprd08.prod.outlook.com (2603:10a6:208:148::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Wed, 24 Jun 2020 13:35:18 +0000 Received: from AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::47) by AM6P194CA0050.outlook.office365.com (2603:10a6:209:84::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Wed, 24 Jun 2020 13:35:18 +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; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT060.mail.protection.outlook.com (10.152.16.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3131.20 via Frontend Transport; Wed, 24 Jun 2020 13:35:18 +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; Wed, 24 Jun 2020 13:35:03 +0000 Received: from E107187.Arm.com (10.57.22.181) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Wed, 24 Jun 2020 13:35:02 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [PATCH v3 04/15] ArmVirtPkg: Add kvmtool platform driver Date: Wed, 24 Jun 2020 14:34:47 +0100 Message-ID: <20200624133458.61920-5-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20200624133458.61920-1-sami.mujawar@arm.com> References: <20200624133458.61920-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)(136003)(39860400002)(376002)(346002)(46966005)(44832011)(6666004)(26005)(478600001)(6916009)(186003)(2906002)(316002)(54906003)(8936002)(5660300002)(426003)(336012)(1076003)(8676002)(70586007)(4326008)(7696005)(2616005)(70206006)(47076004)(36756003)(82740400003)(81166007)(82310400002)(356005)(966005)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1bccaf91-6209-4f7f-b7b4-08d8184373fa X-MS-TrafficTypeDiagnostic: AM0PR08MB4370:|DB6PR0802MB2326: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-Forefront-PRVS: 0444EB1997 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: VLrLqfZyVeaQxvxNMc8kHFHBYHloihSPttehhQZrsqynqNJSHL11ghWYOtKwXMssMkgLcY/9Ywmj6sVu4OIISACI6fKiVO3mpC9Dt5A1MpJBnIDKWPT6Im2Avc/KblXuLVu8mqHEUhm/T0fbnFGjNa2GAXhX1S5opwpugf/Kd1W3A+Y5w7t0b5n5PAnFmSeJDgPKPq3eF5czLl9/LPseSXWFKygHHHldTGmS7KuRbj+Qzwnn/CXOvAT+DVieJoC3BrPkdjCf86LqmlgD8Uwi/XLYXtVDD8dDzESYP6yoPm5v1uULJf0/pvJf8dDY25gGUx4aVDhvpGLtQXk8TiyWevN/4aA10OZgp+Wdp1/SwQLRrA7ZnAziZtF8Usboo3N++Gy38SRp0CAPxyX+Gl2avngbgqbiF4ZI1qQahoduBE06t5aXKca7Qzy9kyUmO/UGU1AJDlqOaIZLEFfgWFBBKejP/zkbLhXjisJCUpbtkG8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4370 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT012.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)(86362001)(26005)(8936002)(5660300002)(54906003)(44832011)(82310400002)(36756003)(6666004)(6916009)(82740400003)(4326008)(7696005)(70206006)(81166007)(83380400001)(47076004)(70586007)(1076003)(478600001)(966005)(316002)(2616005)(2906002)(426003)(8676002)(336012);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: feb90ee5-0b6c-40a8-e4d4-08d818436f67 X-Forefront-PRVS: 0444EB1997 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xxc+hCSV+B3kAJM4tvirPv0a+RZhwHv6IfApPu2IvxattTRn2hhS+dHOhkFEPoT2K+rWmeV9SDXxCIqLrgsOnSh1pvHlpw1kIYXclpsJ9hn+AB6bDdrNGW9VJS89VA3XpI7ns37Bb4JUy6X7eXSs4NJ86xUC5ErMB52oQ4zzsQHThzo/tu/YuXC/GhtkMukDRQKKfRB0Jb5NTXcyGYqLu0/Se23wPgezpchZBL2PuWLC4we9kf9Nqwp1P6rRz0PEwhaGlZSB0tZ9Lq55F+hWYD3GSMVoZW3pc/1SatzBR8lcYc3Zcf1s2N+hnOZGK8QYC3EAICIPJe/Elnxk2IqJyalX1vN5oRsnFMtxu1/vJvVeeLOEZqsh+uXF5DiIeio33F8q3OfFKcBXVvX20pb+DfKjof0+sg9Zw1+ldAif0kLYAz7y9fA9GA44gXFVub2znhNKPXDip2rW2GNZHHqhSzN3mBVgUfzw7LCTb7jZqvA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2020 13:35:26.0541 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1bccaf91-6209-4f7f-b7b4-08d8184373fa 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: DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2326 Content-Type: text/plain Kvmtool is a virtual machine manager that enables hosting KVM guests. It essentially provides a virtual hardware 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 Acked-by: Laszlo Ersek --- Notes: v3: - Don't use CpuDeadLoop()s in your drivers. [Ard] - Returned error code instead of dead loop. [Sami] - Installing a protocol on an image handle should not [Ard] ever fail. So just use ASSERT_EFI_ERROR(). - Added assert and returned status code. [Sami] Ref: https://edk2.groups.io/g/devel/topic/74200911#59650 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 | 85 ++++++++++++++++++++ ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf | 47 +++++++++++ 2 files changed, 132 insertions(+) diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..17a65bdff0c1a5851e45c2a9ede97f76236502e3 --- /dev/null +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c @@ -0,0 +1,85 @@ +/** @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); + ASSERT_EFI_ERROR (Status); + + 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)'