From nobody Wed Feb 11 01:26:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94683+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94683+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1664823247; cv=none; d=zohomail.com; s=zohoarc; b=ZJ3RmmAYuog2k2IxkG0fEUpbErgiv/vPxugzm/Al+hk+tWXGQLmefwHUt6SUw+D6O5cgaauQ4S6iloNZkGl0KIZ8J0quzJX/orYsdVoFTA3CozLJpp06wmwR0SvCEFw3qmAJLsDrAiKapjXVYj2cFWO0ESTUy5YXb3G8dX0E7XI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664823247; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=vnz9PYjv5vUpEKKq+l43qqx2zfNzRlrE+QZCmJXESqk=; b=PuhdIcRGyFqbHBIUyXKSPfA7WA2f4Lgmg8JS2ibfVbftpMLLxZqo/0EYe85S1krSKtjJLakA46w3CPs3bY3tWmWaTCNnAUnnKLOTAtji7f8NFmH2quMwJJHQYKSuzzhBFIWUQXXHdplHrUirYq3qFPc6gRaqKR5lHbA30oypsg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94683+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 166482324744025.281612381005175; Mon, 3 Oct 2022 11:54:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Wi3OYY1788612xR2A24uuzSv; Mon, 03 Oct 2022 11:54:06 -0700 X-Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by mx.groups.io with SMTP id smtpd.web08.1482.1664823245330759376 for ; Mon, 03 Oct 2022 11:54:05 -0700 X-Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-3562f0fb5a7so93895027b3.1 for ; Mon, 03 Oct 2022 11:54:05 -0700 (PDT) X-Gm-Message-State: 30IZafTPAgmblO96ZgbCeVSpx1787277AA= X-Google-Smtp-Source: AMsMyM6VDlt1Fk1VDTbz3lpBc2wNMXVJSmq24I8W0FlWCAvFa4nDVjwMfkkzUZV3FvuaqMjrmndO+EZwaMV+xvKPYQ== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a25:3bcd:0:b0:6b3:bb2d:8497 with SMTP id i196-20020a253bcd000000b006b3bb2d8497mr21460102yba.598.1664823244418; Mon, 03 Oct 2022 11:54:04 -0700 (PDT) Date: Mon, 3 Oct 2022 18:53:48 +0000 In-Reply-To: <20221003185352.3969999-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221003185352.3969999-1-dionnaglaze@google.com> Message-ID: <20221003185352.3969999-4-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH v6 3/7] MdeModulePkg: Invoke all ExitBootServicesCallback instances at ExitBootServices From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Ard Biesheuvel , "Min M. Xu" , Andrew Fish , "Michael D. Kinney" , Ray Ni Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664823246; bh=G2GkZiHJvjlkU/3jA/YXoJXPMvcaYJXJ9uHwYsik4Uk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=EINxR5Zotm28lBTb8qnEVmn2jhjcvc8u3EgPCiQnePYHxtkI8ln9G8GvCnW+Zb4B1Dw zz8LxlNDufIwBQNypaTQl8J39nYcGMJz/m4Jj7umi4O5dXOD+9VaXDrFL07T+9fUSY6Zp YTb3YQQ3PPrkn487Qj7VTbYPpFzmWM0cW8w= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664823248809100013 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The protocol's intent is to allow drivers to install callbacks that can modify the memory map at ExitBootServices time, so that any changes will lead to the EFI_INVALID_PARAMETER error. This error is specified to require the EBS caller to call GetMemoryMap again if it already had. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Ard Biesheuvel Cc: "Min M. Xu" Cc: Andrew Fish Cc: "Michael D. Kinney" Cc: Ray Ni Signed-off-by: Dionna Glaze --- MdeModulePkg/Core/Dxe/DxeMain.h | 1 + MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 41 ++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMai= n.h index 815a6b4bd8..185b9dc3d6 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -45,6 +45,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index e4bca89577..bdd9cf8222 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -153,6 +153,7 @@ gEfiHiiPackageListProtocolGuid ## SOMETIMES_PRODUCES gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiExitBootServicesCallbackProtocolGuid ## CONSUMES =20 # Arch Protocols gEfiBdsArchProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 5733f0c8ec..3270f9858d 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -744,6 +744,34 @@ CalculateEfiHdrCrc ( Hdr->CRC32 =3D Crc; } =20 +/** + Invokes TerminateMemoryMapPrehook from the first located instance of + EdkiiExitBootServicesProtocol. +**/ +STATIC +EFI_STATUS +InvokeTerminateMemoryMapPrehooks ( + VOID + ) +{ + EFI_STATUS Status; + EDKII_EXIT_BOOT_SERVICES_CALLBACK_PROTOCOL *Callback; + + Status =3D gBS->LocateHandle ( + &gEdkiiExitBootServicesCallbackProtocolGuid, + NULL, + (VOID**)Callback + ); + if (Status =3D=3D EFI_NOT_FOUND) { + return EFI_SUCCESS; + } + if (EFI_ERROR (Status)) { + return Status; + } + + return Callback->TerminateMemoryMapPrehook(Callback); +} + /** Terminates all boot services. =20 @@ -768,6 +796,19 @@ CoreExitBootServices ( // gTimer->SetTimerPeriod (gTimer, 0); =20 + // + // Invoke all protocols installed for ExitBootServices prior to + // CoreTerminateMemoryMap. + // + Status =3D InvokeTerminateMemoryMapPrehooks(); + if (EFI_ERROR (Status)) { + // + // Notify other drivers that ExitBootServices failed + // + CoreNotifySignalList (&gEventExitBootServicesFailedGuid); + return Status; + } + // // Terminate memory services if the MapKey matches // --=20 2.38.0.rc1.362.ged0d419d3c-goog -=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 (#94683): https://edk2.groups.io/g/devel/message/94683 Mute This Topic: https://groups.io/mt/94098170/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-