From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.80]) by mx.groups.io with SMTP id smtpd.web12.5577.1601673266627963602 for ; Fri, 02 Oct 2020 14:14:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=KonCkJZO; spf=pass (domain: arm.com, ip: 40.107.21.80, 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=10PnDy+pFiQWbub5SuJ17M8AOU7lYBs1dAoH5UIkr3o=; b=KonCkJZOPx7i/7vXPqfJdqzuxkW8ryodA8jjF+ieieaSzGot0wQ1QCtMShihcMoRSJCMjn2/ZyFIvjl3hGqI3mihsQXE/ChIrOC0WJ9jq1HzwBSFGFKI4/8EXO/qJ3mQ6oYgtG5gkXmS6HGabXAj+pb9LTw0uKOQIGsW6to7tzw= Received: from DB6P193CA0001.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::11) by DB8PR08MB3931.eurprd08.prod.outlook.com (2603:10a6:10:ab::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.32; Fri, 2 Oct 2020 21:14:23 +0000 Received: from DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:29:cafe::f2) by DB6P193CA0001.outlook.office365.com (2603:10a6:6:29::11) 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:23 +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 (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 DB5EUR03FT044.mail.protection.outlook.com (10.152.21.167) 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:23 +0000 Received: ("Tessian outbound 34b830c8a0ef:v64"); Fri, 02 Oct 2020 21:14:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7223e876afb7ab6b X-CR-MTA-TID: 64aa7808 Received: from 6f80e1e24439.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A3CF31A0-7F28-4031-B56D-E2F57E023ED3.1; Fri, 02 Oct 2020 21:14:18 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6f80e1e24439.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=WVccU4nFmJromY4vb8qjEszCFswgBsqO8n9ECQE+U9bbCewgQYp1LLZIewsREIhncXqSY7jE/2jvH9P7Xk/POpRB5nklrQqY5x5aZzstXfM+da8TYQ3Mw4JZzKOPum5LQ8U0XvCa+202QKG+8CmdHHP55GCgqQvuAhyUyufQ7l1GCRN95CafyROSoraq9XNUJOuBuI1LTiQTJnqk1tdkuTrCPWj3nBYEwjZE3Q3+mwmcUnGaLdd2yzsmc+DiW/iybY7Q0MarnCEMlnwV7Dl/KIGyMDz2J0AO6GILpcYDUkSQ6eS1cTPoA9g2DZz7SexGuXWGS5zj93omuRZdWq62AA== 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=10PnDy+pFiQWbub5SuJ17M8AOU7lYBs1dAoH5UIkr3o=; b=SW5sl29s86h49j41TltlrTbg7xCub2BF6bucUjfQ35I3TkpwM43Pt6RQn6ZVYSqGPRfNUrH/JphDeTYRapUKAYCy+/eWL50KJ20EbuzGCn0Hgcwlzd62hkkiJarJo7QLjaEc3I5H6NELjbXjg5xpZGvV9h4WeKvb5z4ERZHtiFtD0z/cYcZt7c8W1w7KlYfkrMwz1fRiLv0gt8x20Pwbe1dyfj1fBvveS2dCl+Gg71k+7qy7AzdlyTKQCBdvnLgV2po3415wj0aVaudWTJWpjTb7LEhYYHKE/m67A7HIiDs7+dPIBImHp/EGYVlPsAOpkcmR6dgYHuO6eSrxZOZNYw== 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 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=10PnDy+pFiQWbub5SuJ17M8AOU7lYBs1dAoH5UIkr3o=; b=KonCkJZOPx7i/7vXPqfJdqzuxkW8ryodA8jjF+ieieaSzGot0wQ1QCtMShihcMoRSJCMjn2/ZyFIvjl3hGqI3mihsQXE/ChIrOC0WJ9jq1HzwBSFGFKI4/8EXO/qJ3mQ6oYgtG5gkXmS6HGabXAj+pb9LTw0uKOQIGsW6to7tzw= Received: from AM6P194CA0057.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::34) by AM6PR08MB4421.eurprd08.prod.outlook.com (2603:10a6:20b:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.36; Fri, 2 Oct 2020 21:14:16 +0000 Received: from AM5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::38) by AM6P194CA0057.outlook.office365.com (2603:10a6:209:84::34) 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:16 +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; 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:16 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2044.4; Fri, 2 Oct 2020 21:14:15 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Fri, 2 Oct 2020 21:14:14 +0000 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:13 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [PATCH v5 04/15] ArmVirtPkg: Add kvmtool platform driver Date: Fri, 2 Oct 2020 22:13:58 +0100 Message-ID: <20201002211409.43888-5-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 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: 5a092741-306b-41b5-4061-08d867182308 X-MS-TrafficTypeDiagnostic: AM6PR08MB4421:|DB8PR08MB3931: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: U+sGdW5SBwhwq3z8VyBi8xjsshuJGAG/gkAcYVGknOF35NNaCD91yqHwfF+kvR89MjpjX0RAmtn9mysKeV3eeP/SrG4kA7LDmunwOFvHQW+mP+uNjA9BtiBCHuTu1J2GYpmp54Rpqpd8/zT8yswtyFQIC2p+pOoQ1KZ3kwyRqI6gqE0fKkSBSJi7ewR2exzbUziaqNvOO/iYbq2qHywHZX9VjCoD8YxAG6TY//LRm64eWi+2lnhBa+nvaOX5dccs+29ENMFvWwF6eWhCAABXea5iLBC/aCir4qVPJQHJV+U8xKJpZD2gzYZSM1qL304sQuSUBxNQDY9WY14e+g2+mNBLha2vIJFEa5Gv2Wp7RvOH77iqdctVKCFkLaJEKsd/1JcPO3jyYd7nBg5vhWyu+2bwj5FaehscBgbh3dkFvSCV+9FV56UNWYb0dyOREQ3KnLep556qTZrUKfxtNC4aC0Ykamm6g0/t89Nc42tdsvI= 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)(396003)(376002)(136003)(346002)(39860400002)(46966005)(186003)(1076003)(6916009)(2906002)(82740400003)(86362001)(966005)(316002)(36756003)(426003)(2616005)(478600001)(54906003)(44832011)(6666004)(336012)(356005)(81166007)(82310400003)(47076004)(83080400001)(70206006)(83380400001)(7696005)(8676002)(8936002)(26005)(4326008)(70586007)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4421 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 130c1c55-367a-439c-63a1-08d867181ea6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ceFnBFjySMf/Ir0gxvfqpZ9cJvSMhBjIJL/OFqvvox9V9a1UpAC8CN43wCHlRoQKBVHgH0NMP06kuLFeImwNXAgmRCmD/U1oa9nxANGfZIX3wS2dUW8+vEARBR0uZBPsFiiOEElwDXjY7d1wcHusMtE7sWisJ+rvTVaRVEKvKVPPfN4Tvv4YonyTo2IYGE3dXEDATqvlnBPEsxGh4BDyj0HCs4ja++RXM+CkM3InXBX8qn+EiPx2VwCe8W+/dxwXY3NqQ7X0HSzbjPvYMbP7kTYs2Iw6+17YWjWs08A0iA3R8TWUnmMQO4LKY4Xk70qdj+CewW0FEwtJVKhARnYZBm63cBCh7Z+5Kg7++wX5T6PlMtmyElQbClI44Bv7Rnf4byYTjNJr8d1hDE6ZqfpD9ubP9nGthkCTiKgBZhvhVWXZupX1n7gViuDyyK64cOSV8ExAIgL4jjSSrJIahzfTKd862xohh5Xf0vFa6k02DwQ= 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;SFS:(4636009)(39860400002)(396003)(136003)(376002)(346002)(46966005)(83080400001)(81166007)(4326008)(26005)(1076003)(82310400003)(5660300002)(83380400001)(8676002)(336012)(966005)(6666004)(36756003)(2616005)(44832011)(8936002)(70206006)(6916009)(82740400003)(186003)(70586007)(426003)(54906003)(316002)(86362001)(7696005)(2906002)(478600001)(47076004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2020 21:14:23.7474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a092741-306b-41b5-4061-08d867182308 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: DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3931 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 Reviewed-by: Ard Biesheuvel --- Notes: v5: - Fixed minor ECC reported issues in file header. [Sami] Ref: https://edk2.groups.io/g/devel/message/62159 v4: - Cleaned up include file and LibraryClasses list. [Sami] - Missing MemoryAllocationLib here - either add it [Ard] here, or remove it from LibraryClasses. Ref: https://edk2.groups.io/g/devel/message/61714 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 | 82 ++++++++++++++++++++ ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf | 43 ++++++++++ 2 files changed, 125 insertions(+) diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..a42b64d1061dcdf8163775f66b6d2f550e481315 --- /dev/null +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c @@ -0,0 +1,82 @@ +/** @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 + +/** 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..1cf25780f8300edab607d0c1dfbf7255404226df --- /dev/null +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf @@ -0,0 +1,43 @@ +## @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 + DebugLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Guids] + gEdkiiPlatformHasAcpiGuid ## SOMETIMES_PRODUCES ## PROTOCOL + gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL + +[Pcd] + gArmVirtTokenSpaceGuid.PcdForceNoAcpi + +[Depex] + TRUE -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'