From: Jiewen Yao Date: Wed, 15 Mar 2017 05:12:33 +0000 (+0800) Subject: MdeModulePkg/CapsuleLib: Fix runtime issue X-Git-Tag: edk2-stable201903~4388 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=056563f1bbda839bab2ba32bd9bef962b862a9bd;hp=08bed3fbac47e32a6c715de35ae9e80f21d4508c MdeModulePkg/CapsuleLib: Fix runtime issue The previous patch has problem on handling capsule request at runtime. This patch fixed the issue. Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Reviewed-by: Chao Zhang --- diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 6344214ea0..9ed0be3b65 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -1453,33 +1453,44 @@ IsNestedFmpCapsule ( EFI_SYSTEM_RESOURCE_ENTRY Entry; EsrtGuidFound = FALSE; - - // - // Check ESRT protocol - // - Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol); - if (!EFI_ERROR(Status)) { - Status = EsrtProtocol->GetEsrtEntry(&CapsuleHeader->CapsuleGuid, &Entry); - if (!EFI_ERROR(Status)) { - EsrtGuidFound = TRUE; - } - } - - // - // Check ESRT configuration table - // - if (!EsrtGuidFound) { - Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt); - if (!EFI_ERROR(Status)) { - ASSERT (Esrt != NULL); - EsrtEntry = (VOID *)(Esrt + 1); - for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) { + if (mIsVirtualAddrConverted) { + if(mEsrtTable != NULL) { + EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1); + for (Index = 0; Index < mEsrtTable->FwResourceCount ; Index++, EsrtEntry++) { if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) { EsrtGuidFound = TRUE; break; } } } + } else { + // + // Check ESRT protocol + // + Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol); + if (!EFI_ERROR(Status)) { + Status = EsrtProtocol->GetEsrtEntry(&CapsuleHeader->CapsuleGuid, &Entry); + if (!EFI_ERROR(Status)) { + EsrtGuidFound = TRUE; + } + } + + // + // Check ESRT configuration table + // + if (!EsrtGuidFound) { + Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt); + if (!EFI_ERROR(Status)) { + ASSERT (Esrt != NULL); + EsrtEntry = (VOID *)(Esrt + 1); + for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) { + if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) { + EsrtGuidFound = TRUE; + break; + } + } + } + } } if (!EsrtGuidFound) { return FALSE;