From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.59]) by mx.groups.io with SMTP id smtpd.web09.1151.1632355268756578203 for ; Wed, 22 Sep 2021 17:01:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=fe8ZTE0q; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.93.59, mailfrom: bobm@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ILhQj+rWh/sSJq8+calIJ42b1nwxSZ0HI9Qrr1ipaS57W/hHMLAAFjNxV5ijQv9lBulVO5+/QodT8YxbqHfKr4zHrBlXnCoSYAjPokGlzTWOSaqWsWoknjzqZBE3qISsd1b73TmCQLxmCNPL9oRcSb9tVFBZ+KQOpFaEn7xQjNhv6nOiFsHDnHeSVKTN5oKFVQL2JSYzPXt6fXfO1chIJMrKf653n8v+gSTk2V9QitCgcjLxYiPbFRHo/7OS2VwmeN0anHESFZoqWfsUy6bObHOxeQkpNxDsxB0GnF/OJCrfD5cmZbywwkujFLuexXKB5xuTK2xbJAF7lmmPnjcQMw== 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; bh=Z7l7D7uQodRasIpegRsZ7Wa2PHZmVIhbfXb0kUAL5BM=; b=aNYS7hbGwwPJkO2uP3CrCr5/gNlNjejHwuYB27AQvdX7oeM01zpU93DWp673EaeAuArFmvdIvgsR/ijFRKl5C2fmVc9zjayOXmxf5xx7H5RqEkrAGw59+XuUHaz56ImwNcz2/Qn9D31KwaURIF4W4X7xlBwjVrIBormbHBSOE6pny1SdrkO9DuZMDLoCP6S+/DzElyaB++irfbkPo7FEao5fsF+Bu6zsgYwoMHM2M22PQGBTj7cx+io/ZRE8sjEVAjYds8tgb0bhUgEbKZaMDPs5lB4RSA43xE+MlsdpdvMUHPasDyKSpHQo4BKahDdns7HW1fz1KI0279d8fA85Lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z7l7D7uQodRasIpegRsZ7Wa2PHZmVIhbfXb0kUAL5BM=; b=fe8ZTE0qR/oj4FsMp1bd67F/iKH7b3h88nmIiJkAojDaJvpsipjM5U5s4jkAymqIFPytzZuEcTPIb1OyiIFUz8zr2JN0oAcWVy0wQx7Z4u2td+zqG45WwJnLCMEnI0uTCiZAR6YpQ4d/gjNk7fCV/EAHOVQRyMpnn2qvwKXeC3x+zKIqZqOyc6CA6u9nnhNXR9nL78DyDPt5Fw/3S10nrxhbpxLLc2GWNnDkDqQ9nQg4OxqKRsPLieTgD0a6IMX6fhuYxihRkK4c7EPDrsOtoybCOlse/L2lZqw11GUHB/vEPcMzbtCif/AwjTcwfQq+dm5e1feOlosWqhFpDqkbJw== Received: from MW4PR03CA0158.namprd03.prod.outlook.com (2603:10b6:303:8d::13) by CY4PR1201MB0072.namprd12.prod.outlook.com (2603:10b6:910:1b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 00:01:06 +0000 Received: from CO1NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::de) by MW4PR03CA0158.outlook.office365.com (2603:10b6:303:8d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Thu, 23 Sep 2021 00:01:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT014.mail.protection.outlook.com (10.13.175.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 00:01:06 +0000 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 23 Sep 2021 00:00:58 +0000 Received: from localhost.localdomain (172.20.187.6) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 23 Sep 2021 00:00:58 +0000 From: "Bob Morgan" To: CC: , , , , Bob Morgan Subject: [PATCH 5/5] FmpDevicePkg/FmpDxe: Add runtime FmpDxe driver Date: Wed, 22 Sep 2021 17:59:54 -0600 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-NVConfidentiality: public Return-Path: bobm@nvidia.com MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dadae4f5-f85e-4e7a-3822-08d97e253dbd X-MS-TrafficTypeDiagnostic: CY4PR1201MB0072: X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rmUeevfO2LxsmM/AxvBlqirf0Moclq3zse7FPa7orZKaRewAXl0Vht3x1JBI6GWvOQMEq3VUKpCK0LJoUQ93Ijdt5E5cv+DebO2YLlulQGpP2eRfjwyyISvryDwfFjtVK+qhQ8GrLpXMFA6KmpmWpPxTv4TXNKC4Xsz3mq3xzEqVdQvKZJMs7SITeSLKASpls6wVwlS8YZSA5XL3GOzEgfazg3vw8z46pZwz+EQFMGCmfQ8NR8NdLMG2HZFkXC+gTbP6Cyrfvf9JdFCSQU1Q+6ifiUdl8PHRkihZBrvZVZuIC59r1tx54hsvI7vKbGfpZZN44eCR6SpNEcyog1Wmlr/CrCvg49PpeXTqd0XWV5MUYM7vyTrcGdKQyWzaCDH6IkwrUhEkaO2bEJVHuBPy8ylXUV/1I5OwU9Sa6XmavXa9SrPL3Gpxd5wuXcOnqgZIufMTsNJjYv8CxOOxDUb9Vh39oJmcdtHftoov/CeiSmmOgVJCI8V3vgEGwHFLK9av6Iv5lPBl7RvcrQsAPR9G6x2e8c1L68SIBSiod4P8Vjkfl+0cY9RwgcG3aQq4PmXbe9VQqjGJJm2DJ9o4iyoWj1opzOybgIhr405RgAdOGzNk/mdJjfTPa5Lp+aAMepHGOu69Kid+39uzZVL1HZSy8OCTNpbiwvYUo3wj7g7kp3anrK6KONcZC+FeqwDQCFfj8ubBmGVnMCqmwLyU0x7sAhJWVA3nX/22ig/e2u/RR6Vmxq3CCBuvDF36c9CwHzkd X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(5660300002)(8936002)(36906005)(2906002)(54906003)(336012)(316002)(186003)(426003)(36860700001)(6666004)(26005)(36756003)(47076005)(4326008)(82310400003)(107886003)(30864003)(70206006)(45080400002)(508600001)(7636003)(6916009)(356005)(83380400001)(86362001)(2616005)(70586007)(8676002)(290074003)(44824005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 00:01:06.3236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dadae4f5-f85e-4e7a-3822-08d97e253dbd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0072 Content-Type: text/plain Adds a runtime version of FmpDxe driver to allow firmware updates after ExitBootServices() is called. Cc: Liming Gao Cc: Michael D Kinney Cc: Guomin Jiang Cc: Wei6 Xu Signed-off-by: Bob Morgan --- FmpDevicePkg/FmpDevicePkg.dsc | 29 ++++ FmpDevicePkg/FmpDxe/FmpDxe.c | 34 +++-- FmpDevicePkg/FmpDxe/FmpRuntimeDxe.c | 185 ++++++++++++++++++++++++++ FmpDevicePkg/FmpDxe/FmpRuntimeDxe.inf | 87 ++++++++++++ FmpDevicePkg/FmpDxe/VariableSupport.c | 7 + 5 files changed, 332 insertions(+), 10 deletions(-) create mode 100644 FmpDevicePkg/FmpDxe/FmpRuntimeDxe.c create mode 100644 FmpDevicePkg/FmpDxe/FmpRuntimeDxe.inf diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc index b420f52a08..0f38e47ae4 100644 --- a/FmpDevicePkg/FmpDevicePkg.dsc +++ b/FmpDevicePkg/FmpDevicePkg.dsc @@ -29,6 +29,7 @@ # DEFINE SYSTEM_FMP_ESRT_GUID = B461B3BD-E62A-4A71-841C-50BA4E500267 DEFINE DEVICE_FMP_ESRT_GUID = 226034C4-8B67-4536-8653-D6EE7CE5A316 + DEFINE RUNTIME_FMP_ESRT_GUID = DECC975F-135A-426F-B667-ACA49E8CEF2A # # TRUE - Build FmpDxe module for with storage access enabled @@ -173,6 +174,34 @@ CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf } + FmpDevicePkg/FmpDxe/FmpRuntimeDxe.inf { + + # + # FILE_GUID is used as ESRT GUID + # + FILE_GUID = $(RUNTIME_FMP_ESRT_GUID) + + # + # Unicode name string that is used to populate FMP Image Descriptor for this capsule update module + # + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L"Sample Firmware Device" + # + # Certificates used to authenticate capsule update image + # + !include BaseTools/Source/Python/Pkcs7Sign/TestRoot.cer.gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr.inc + + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{GUID("$(RUNTIME_FMP_ESRT_GUID)")} + + UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf + + # + # Directly use a platform specific CapsuleUpdatePolicyLib instance. + # Only works for FmpDxe modules that are build from sources and included + # in a system firmware image. + # + CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf + } + # # Add UEFI Target Based Unit Tests # diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index 6b0675ea38..2ebf99d68b 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.c +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c @@ -84,6 +84,8 @@ const FIRMWARE_MANAGEMENT_PRIVATE_DATA mFirmwareManagementPrivateDataTemplate = TRUE // DependenciesSatisfied }; +FIRMWARE_MANAGEMENT_PRIVATE_DATA *mPrivate = NULL; + /// /// GUID that is used to create event used to lock the firmware storage device. /// @@ -99,6 +101,11 @@ EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS mProgressFunc = NULL; /// CHAR16 *mImageIdName = NULL; +/// +/// Optional function to determine if we're executing after ExitBootServices(). +/// +BOOLEAN (EFIAPI *mFmpAtRuntimeFunction) (VOID) = NULL; + /** Callback function to report the process of the firmware updating. @@ -1451,8 +1458,10 @@ cleanup: // // Need repopulate after SetImage is called to // update LastAttemptVersion and LastAttemptStatus. + // But don't force repopulate if executing at runtime. // - if (Private != NULL) { + if ((Private != NULL) && + ((mFmpAtRuntimeFunction == NULL) || !mFmpAtRuntimeFunction ())) { Private->DescriptorPopulated = FALSE; } @@ -1628,16 +1637,21 @@ InstallFmpInstance ( } // - // Allocate FMP Protocol instance + // Allocate FMP Protocol instance if FmpRuntimeDxe didn't already do it // - Private = AllocateCopyPool ( - sizeof (mFirmwareManagementPrivateDataTemplate), - &mFirmwareManagementPrivateDataTemplate - ); - if (Private == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to allocate memory for private structure.\n", mImageIdName)); - Status = EFI_OUT_OF_RESOURCES; - goto cleanup; + if (mPrivate == NULL) { + Private = AllocateCopyPool ( + sizeof (mFirmwareManagementPrivateDataTemplate), + &mFirmwareManagementPrivateDataTemplate + ); + if (Private == NULL) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to allocate memory for private structure.\n", mImageIdName)); + Status = EFI_OUT_OF_RESOURCES; + goto cleanup; + } + mPrivate = Private; + } else { + Private = mPrivate; } // diff --git a/FmpDevicePkg/FmpDxe/FmpRuntimeDxe.c b/FmpDevicePkg/FmpDxe/FmpRuntimeDxe.c new file mode 100644 index 0000000000..d7e0a988d6 --- /dev/null +++ b/FmpDevicePkg/FmpDxe/FmpRuntimeDxe.c @@ -0,0 +1,185 @@ +/** @file + Support for runtime Firmware Management Protocol + + Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
+ Copyright (c) Microsoft Corporation.
+ Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include "FmpDxe.h" + +EFI_EVENT mAddressChangeEvent = NULL; + +/// +/// FILE_GUID from FmpRuntimeDxe.inf. When FmpRuntimeDxe.inf is used in a platform, +/// the FILE_GUID must always be overridden in the section to provide +/// the ESRT GUID value associated with the updatable firmware image. A +/// check is made in this module's driver entry point to verify that a +/// new FILE_GUID value has been defined. +/// +const EFI_GUID mDefaultRuntimeModuleFileGuid = { + 0xd12aece5, 0x7399, 0x4d05, { 0x88, 0xe4, 0x1c, 0x42, 0x84, 0xd8, 0xa0, 0x23 } +}; + +// FmpDxe module variables +extern FIRMWARE_MANAGEMENT_PRIVATE_DATA *mPrivate; +extern CHAR16 *mImageIdName; +extern const FIRMWARE_MANAGEMENT_PRIVATE_DATA mFirmwareManagementPrivateDataTemplate; +extern BOOLEAN (EFIAPI *mFmpAtRuntimeFunction) (VOID); + +// FmpDxe ENTRY_POINT function prototype +EFI_STATUS +EFIAPI +FmpDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +// FmpDxe UNLOAD_IMAGE function prototype +EFI_STATUS +EFIAPI +UninstallFmpInstance ( + IN EFI_HANDLE Handle + ); + +/** + Event notification function that is invoked when the event GUID specified by + gEfiEventVirtualAddressChangeGuid is signaled. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context The pointer to the notification function's context, + which is implementation-dependent. +**/ +VOID +EFIAPI +FmpRuntimeDxeAddressChangeEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private; + + if (Context == NULL) { + ASSERT (Context != NULL); + return; + } + + Private = (FIRMWARE_MANAGEMENT_PRIVATE_DATA *) Context; + + EfiConvertPointer (0x0, (VOID **) &Private->Descriptor.VersionName); + EfiConvertPointer (0x0, (VOID **) &Private->Descriptor.Dependencies); + EfiConvertPointer (0x0, (VOID **) &Private->FmpDeviceContext); + EfiConvertPointer (0x0, (VOID **) &Private->VersionVariableName); + EfiConvertPointer (0x0, (VOID **) &Private->LsvVariableName); + EfiConvertPointer (0x0, (VOID **) &Private->LastAttemptStatusVariableName); + EfiConvertPointer (0x0, (VOID **) &Private->LastAttemptVersionVariableName); + EfiConvertPointer (0x0, (VOID **) &Private->FmpStateVariableName); + + EfiConvertPointer (0x0, (VOID **) &Private->Fmp.GetImageInfo); + EfiConvertPointer (0x0, (VOID **) &Private->Fmp.GetImage); + EfiConvertPointer (0x0, (VOID **) &Private->Fmp.SetImage); + EfiConvertPointer (0x0, (VOID **) &Private->Fmp.CheckImage); + EfiConvertPointer (0x0, (VOID **) &Private->Fmp.GetPackageInfo); + EfiConvertPointer (0x0, (VOID **) &Private->Fmp.SetPackageInfo); + + EfiConvertPointer (0x0, (VOID **) &mPrivate); + EfiConvertPointer (0x0, (VOID **) &mImageIdName); + EfiConvertPointer (0x0, (VOID **) &mFmpAtRuntimeFunction); +} + +/** + Function to uninstall FMP instance. + + @param[in] Handle The device handle to uninstall. + + @retval EFI_SUCCESS FMP Uninstalled + @retval other Error from UninstallFmpInstance(). + +**/ +EFI_STATUS +EFIAPI +UninstallRuntimeFmpInstance ( + IN EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + + if (mAddressChangeEvent != NULL) { + gBS->CloseEvent (mAddressChangeEvent); + } + + Status = UninstallFmpInstance (Handle); + + return Status; +} + +/** + Entry point for runtime FmpDxe. Performs runtime-only initialization and + then calls regular FmpDxe initialization. + + @param[in] ImageHandle Image handle this driver. + @param[in] SystemTable Pointer to SystemTable. + +**/ +EFI_STATUS +EFIAPI +FmpRuntimeDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Verify that a new FILE_GUID value has been provided in the + // section of this module. The FILE_GUID is the ESRT GUID that must be + // unique for each updatable firmware image. + // + if (CompareGuid (&mDefaultRuntimeModuleFileGuid, &gEfiCallerIdGuid)) { + DEBUG ((DEBUG_ERROR, "FmpRuntimeDxe: Use of default FILE_GUID detected. FILE_GUID must be set to a unique value.\n")); + ASSERT (FALSE); + return EFI_UNSUPPORTED; + } + + // + // Allocate and initialize private data structure from runtime pool + // + mPrivate = AllocateRuntimeCopyPool (sizeof (mFirmwareManagementPrivateDataTemplate), + &mFirmwareManagementPrivateDataTemplate); + if (mPrivate == NULL) { + DEBUG ((DEBUG_ERROR, "FmpRuntimeDxe: Failed to allocate memory for private structure.\n")); + return EFI_OUT_OF_RESOURCES; + } + + // + // Create and register notify function for virtual address change event + // + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + FmpRuntimeDxeAddressChangeEventNotify, + mPrivate, + &gEfiEventVirtualAddressChangeGuid, + &mAddressChangeEvent); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "FmpRuntimeDxe: Failed to register address change notification. Status = %r\n", + Status)); + return Status; + } + + // + // Initialize FmpDxe + // + Status = FmpDxeEntryPoint (ImageHandle, SystemTable); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "FmpRuntimeDxe: Failed to initialize FmpDxe: %r\n", Status)); + } + + // Set AtRuntime function pointer + mFmpAtRuntimeFunction = EfiAtRuntime; + + return Status; +} diff --git a/FmpDevicePkg/FmpDxe/FmpRuntimeDxe.inf b/FmpDevicePkg/FmpDxe/FmpRuntimeDxe.inf new file mode 100644 index 0000000000..fff779bc4d --- /dev/null +++ b/FmpDevicePkg/FmpDxe/FmpRuntimeDxe.inf @@ -0,0 +1,87 @@ +## @file +# Produces a runtime Firmware Management Protocol that supports updates +# to a firmware image stored in a firmware device with platform and +# firmware device specific information provided through PCDs and libraries. +# +# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 1.27 + BASE_NAME = FmpDxe + MODULE_UNI_FILE = FmpDxe.uni + FILE_GUID = D12AECE5-7399-4D05-88E4-1C4284D8A023 + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = FmpRuntimeDxeEntryPoint + UNLOAD_IMAGE = UninstallRuntimeFmpInstance + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 +# + +[Sources] + FmpRuntimeDxe.c + FmpDxe.c + FmpDxe.h + DetectTestKey.c + VariableSupport.h + VariableSupport.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + CryptoPkg/CryptoPkg.dec + FmpDevicePkg/FmpDevicePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + DebugLib + BaseLib + BaseMemoryLib + UefiBootServicesTableLib + MemoryAllocationLib + PrintLib + UefiLib + BaseCryptLib + FmpAuthenticationLib + FmpDeviceLib + FmpPayloadHeaderLib + CapsuleUpdatePolicyLib + FmpDependencyLib + FmpDependencyCheckLib + FmpDependencyDeviceLib + UefiRuntimeLib + +[Guids] + gEfiEndOfDxeEventGroupGuid + gEfiEventVirtualAddressChangeGuid + +[Protocols] + gEdkiiVariableLockProtocolGuid ## CONSUMES + gEfiFirmwareManagementProtocolGuid ## PRODUCES + gEdkiiFirmwareManagementProgressProtocolGuid ## PRODUCES + +[Pcd] + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceStorageAccessEnable ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersion ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceLockEventGuid ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceTestKeySha256Digest ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## SOMETIMES_PRODUCES + +[Depex] + gEfiVariableWriteArchProtocolGuid AND gEdkiiVariableLockProtocolGuid + +[UserExtensions.TianoCore."ExtraFiles"] + FmpDxeExtra.uni diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/VariableSupport.c index 86dd5b203b..13fc638618 100644 --- a/FmpDevicePkg/FmpDxe/VariableSupport.c +++ b/FmpDevicePkg/FmpDxe/VariableSupport.c @@ -12,6 +12,8 @@ #include "FmpDxe.h" #include "VariableSupport.h" +extern BOOLEAN (EFIAPI *mFmpAtRuntimeFunction) (VOID); + /** Retrieve the value of a 32-bit UEFI Variable specified by VariableName and a GUID of gEfiCallerIdGuid. @@ -103,6 +105,11 @@ GetFmpControllerState ( FMP_CONTROLLER_STATE *FmpControllerState; UINTN Size; + // FmpState variable not accessible at runtime + if ((mFmpAtRuntimeFunction != NULL) && mFmpAtRuntimeFunction ()) { + return NULL; + } + FmpControllerState = NULL; Size = 0; Status = GetVariable2 ( -- 2.17.1