From nobody Mon Feb 9 12:15:19 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+61668+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 1593005731973676.5190578051898; Wed, 24 Jun 2020 06:35:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lcXiYY1788612xrge6pQZzLp; Wed, 24 Jun 2020 06:35:30 -0700 X-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 X-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 X-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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61668+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 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 X-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 X-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 X-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 X-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 X-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; X-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 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; Wed, 24 Jun 2020 13:35:03 +0000 X-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: [edk2-devel] [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> 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-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 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: feb90ee5-0b6c-40a8-e4d4-08d818436f67 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 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: zKHdHP7gbMJgzN2dl5vPBKTex1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1593005730; bh=N0b8tvtyuhpjSGG0FXrvXZIdvL3uAbtjtkE3wNenbbk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Dp12dwlF/Q14hDJA1/1L3fnpMiBC7AMM7/LfWxI6b59hdAppMsBlJq7XaiZ069dfb4N Bo7+RbCZB6Q2xB0yLpwIINLXm7+R58RHmbdZK3KPCY5dDEn6rVBNR5+wpyGxTjcoBaCkE HVeU8lpiWqTw1I6o3N6dyzdTTou+LDeP3L8= 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. 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 =20 v2: - Updated according to review comments. [Sami] =20 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/ArmVirtPk= g/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..17a65bdff0c1a5851e45c2a9ede= 97f76236502e3 --- /dev/null +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c @@ -0,0 +1,85 @@ +/** @file + + The KvmtoolPlatformDxe performs the platform specific initialization lik= e: + - 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 t= he + 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 t= he + 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 =3D PlatformHasAcpiDt (ImageHandle); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf b/ArmVirt= Pkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf new file mode 100644 index 0000000000000000000000000000000000000000..08a0fe5ce14469133479046385b= dd48c22698639 --- /dev/null +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf @@ -0,0 +1,47 @@ +#/** @file +# +# The KvmtoolPlatformDxe performs the platform specific initialization li= ke: +# - 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 =3D 0x0001001B + BASE_NAME =3D KvmtoolPlatformDxe + FILE_GUID =3D 7479CCCD-D721-442A-8C73-A72DBB886669 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D 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 --=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 (#61668): https://edk2.groups.io/g/devel/message/61668 Mute This Topic: https://groups.io/mt/75081480/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-