From nobody Sat Apr 20 12:16:28 2024 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+94141+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+94141+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1663879890; cv=none; d=zohomail.com; s=zohoarc; b=G6V0yc9h7UZq84IRFyTq/U6kXQboHNsxd/f3T44qWRLj3kvOgpFt5vjcE4v0E6lni1qjtecDKrtQ9I7nN7Ux6rG6wIzHOxVJ8/QcYQA9UeZO6A5+8xdV9LJllpTTclCyvidsB1rfNTZgncaw4hJW/gG7cZl6eN8Tz6TopV18iKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663879890; 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=EhcO9ihfjNjggodLgMKYKMbimSkHrCDr2Wm1gRVJe1Q=; b=MrXn/9u8tdBf3d+C/bBh65BPSmwf80UhaHRKSJTeCJEUvC030HvPG+r0eolTspO0xNO8A2nZ55/5CrkcGIrEbz8Nk+IK7cMrHu76wXXsQlEedar9uiV6tP4uru6x2LnDh7c/C1kT+PoP4S4nHg8PPiTZjjJKAUspWxSOzn9fAKU= 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+94141+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663879890463785.0478234581999; Thu, 22 Sep 2022 13:51:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vxS8YY1788612xpv0d7i4H3b; Thu, 22 Sep 2022 13:51:30 -0700 X-Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by mx.groups.io with SMTP id smtpd.web11.420.1663879889241583864 for ; Thu, 22 Sep 2022 13:51:29 -0700 X-Received: by mail-pg1-f202.google.com with SMTP id l72-20020a63914b000000b00434ac6f8214so5905774pge.13 for ; Thu, 22 Sep 2022 13:51:29 -0700 (PDT) X-Gm-Message-State: vmuwGqYEYyQhz8dJXKY8nBnEx1787277AA= X-Google-Smtp-Source: AMsMyM4Ox3voKgC/UzztzBS4wYKeJ41hb74fYHk15QID5Mxf/KntSd5OfXrd8TshrL7j5EoPkZl4CyX1o1uvaCsACg== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a05:6a00:2192:b0:54e:6aed:c6fb with SMTP id h18-20020a056a00219200b0054e6aedc6fbmr5528026pfi.10.1663879888616; Thu, 22 Sep 2022 13:51:28 -0700 (PDT) Date: Thu, 22 Sep 2022 20:50:52 +0000 In-Reply-To: <20220922205052.1198237-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20220922205052.1198237-1-dionnaglaze@google.com> Message-ID: <20220922205052.1198237-4-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH 3/3] MdeModulePkg: add EnableUnacceptedMemoryProtocol From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Ard Biesheuvel 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=1663879890; bh=/QH7XiGS9MWLXP9uBbqUUs620gs1jvmmKA0bFERLmpw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=P8CmbHD7POYibvwDK+4OkZuUPs9uwnf7WmRA3G3XyVT6v9owfqCvPYb1UUR0WZytnyO e0BS1P1zXqOHUiY1N0bbRh8V56KMii8oKKN1OJzUhZV72zkKSWczfwv4EXudXq8P0FSH5 h8OsNB4sdeWSJeNdjzdnqbNS+jm91X/W160= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663879891729100021 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a simple protocol that enables the use of the unaccepted memory type. Must be called before ExitBootServices to be effective. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Ard Biesheuvel Signed-off-by: Dionna Glaze --- MdeModulePkg/Core/Dxe/DxeMain.h | 22 ++++++++++++++++ MdeModulePkg/Core/Dxe/DxeMain.inf | 3 ++- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 5 ++++ MdeModulePkg/Core/Dxe/Mem/Page.c | 35 +++++++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 3 +++ 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMai= n.h index ac943c87a3..5f0114b04f 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2708,6 +2708,28 @@ CoreResolveUnacceptedMemory ( VOID ); =20 + +typedef struct _ENABLE_UNACCEPTED_MEMORY_PROTOCOL + ENABLE_UNACCEPTED_MEMORY_PROTOCOL; + +typedef EFI_STATUS (EFIAPI *ENABLE_UNACCEPTED_MEMORY)( + IN ENABLE_UNACCEPTED_MEMORY_PROTOCOL * + ); + +struct _ENABLE_UNACCEPTED_MEMORY_PROTOCOL { + ENABLE_UNACCEPTED_MEMORY Enable; +}; + +extern EFI_GUID gEnableUnacceptedMemoryProtocolGuid; + +/** + Implement the protocol for enabling unaccepted memory. + **/ +VOID +InstallEnableUnacceptedMemoryProtocol ( + VOID + ); + /** Install MemoryAttributesTable on memory allocation. =20 diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index deb8bb2ba8..39dcac98bb 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -122,6 +122,7 @@ gEfiMemoryAttributesTableGuid ## SOMETIMES_PRODUCES ##= SystemTable gEfiEndOfDxeEventGroupGuid ## SOMETIMES_CONSUMES ##= Event gEfiHobMemoryAllocStackGuid ## SOMETIMES_CONSUMES ##= SystemTable + gEnableUnacceptedMemoryProtocolGuid ## PRODUCES ##= GUID # Install protocol =20 [Ppis] gEfiVectorHandoffInfoPpiGuid ## UNDEFINED # HOB @@ -187,7 +188,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth = ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory = ## CONSUMES ## SOMETIMES_PRODUCES =20 # [Hob] # RESOURCE_DESCRIPTOR ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 8d1de32fe7..bc1a8ab6b2 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -354,6 +354,11 @@ DxeMain ( Status =3D CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid= , &gMemoryTypeInformation); ASSERT_EFI_ERROR (Status); =20 + // + // Install unaccepted memory configuration protocol + // + InstallEnableUnacceptedMemoryProtocol(); + // // If Loading modules At fixed address feature is enabled, install Load = moduels at fixed address // Configuration Table so that user could easily to retrieve the top add= ress to load Dxe and PEI diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index cbebe62a28..10e152d80d 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -96,6 +96,14 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiM= axMemoryType + 1] =3D { // GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN gLoadFixedAddressCodeMemoryReady = =3D FALSE; =20 +EFI_STATUS EFIAPI CoreEnableUnacceptedMemory(IN ENABLE_UNACCEPTED_MEMORY_P= ROTOCOL *); + +struct { + ENABLE_UNACCEPTED_MEMORY enable; +} mEnableUnacceptedMemoryProtocol =3D { + CoreEnableUnacceptedMemory, +}; + /** Enter critical section by gaining lock on gMemoryLock. =20 @@ -2205,6 +2213,33 @@ CoreResolveUnacceptedMemory ( return AcceptAllUnacceptedMemory(AcceptMemory); } =20 +EFI_STATUS +EFIAPI +CoreEnableUnacceptedMemory ( + IN ENABLE_UNACCEPTED_MEMORY_PROTOCOL *This + ) +{ + return PcdSetBoolS(PcdEnableUnacceptedMemory, TRUE); +} + +VOID +InstallEnableUnacceptedMemoryProtocol ( + VOID + ) +{ + EFI_HANDLE Handle; + EFI_STATUS Status; + + Handle =3D NULL; + Status =3D CoreInstallMultipleProtocolInterfaces ( + &Handle, + &gEnableUnacceptedMemoryProtocolGuid, + &mEnableUnacceptedMemoryProtocol, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + /** Make sure the memory map is following all the construction rules, it is the last time to check memory map error before exit boot services. diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index dd07b3725a..ce72c06a93 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -244,6 +244,9 @@ gEdkiiPerformanceMeasurementProtocolGuid =3D { 0xc85d06be, 0x5f75, = 0x48ce, { 0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 0xb1 } } gEdkiiSmmPerformanceMeasurementProtocolGuid =3D { 0xd56b6d73, 0x1a7b, = 0x4015, { 0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 0x24 } } =20 + ## Bootloader protocol Guid for enabling unaccepted memory support. + gEnableUnacceptedMemoryProtocolGuid =3D { 0xc5a010fe, 0x38a7, 0x4531, { = 0x8a, 0x4a, 0x05, 0x00, 0xd2, 0xfd, 0x16, 0x49 } } + ## Guid is defined for CRC32 encapsulation scheme. # Include/Guid/Crc32GuidedSectionExtraction.h gEfiCrc32GuidedSectionExtractionGuid =3D { 0xFC1BCDB0, 0x7D31, 0x49aa, {= 0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } } --=20 2.37.3.998.g577e59143f-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 (#94141): https://edk2.groups.io/g/devel/message/94141 Mute This Topic: https://groups.io/mt/93857649/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-