public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH v3] MdeModulePkg: AllocatePages for TranslateBmpToGopBlt
@ 2023-08-03  9:29 chitralekha ck
  2023-08-04 19:12 ` Mike Maslenkin
  2023-09-01  5:29 ` Ni, Ray
  0 siblings, 2 replies; 3+ messages in thread
From: chitralekha ck @ 2023-08-03  9:29 UTC (permalink / raw)
  To: devel; +Cc: chitralekha ck, Ray Ni, Zhichao Gao, Ashraf Ali S,
	Chinni B Duggapu

https://bugzilla.tianocore.org/show_bug.cgi?id=4507
AllocatePool limits to allocate memory of 64 KB at most in PEI Phase.
AllocatePool() is being avoided due to its 64k allocation size limit
when the library is incorporated into a PEI component.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Signed-off-by: chitralekha ck <chitralekha.ck@intel.com>
---
 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
index c5e885d7a6..a7ebcd1d65 100644
--- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
+++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
@@ -52,7 +52,7 @@ const BMP_IMAGE_HEADER  mBmpImageHeaderTemplate = {
 /**
   Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
   is passed in a GopBlt buffer will be allocated by this routine using
-  EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it will be
+  EFI_BOOT_SERVICES.AllocatePages(). If a GopBlt buffer is passed in it will be
   used if it is big enough.
 
   @param[in]       BmpImage      Pointer to BMP file.
@@ -312,7 +312,7 @@ TranslateBmpToGopBlt (
     //
     DEBUG ((DEBUG_INFO, "Bmp Support: Allocating 0x%X bytes of memory\n", BltBufferSize));
     *GopBltSize = (UINTN)BltBufferSize;
-    *GopBlt     = AllocatePool (*GopBltSize);
+    *GopBlt     = AllocatePages (*GopBltSize);
     IsAllocated = TRUE;
     if (*GopBlt == NULL) {
       return RETURN_OUT_OF_RESOURCES;
-- 
2.38.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107576): https://edk2.groups.io/g/devel/message/107576
Mute This Topic: https://groups.io/mt/100551576/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH v3] MdeModulePkg: AllocatePages for TranslateBmpToGopBlt
  2023-08-03  9:29 [edk2-devel] [PATCH v3] MdeModulePkg: AllocatePages for TranslateBmpToGopBlt chitralekha ck
@ 2023-08-04 19:12 ` Mike Maslenkin
  2023-09-01  5:29 ` Ni, Ray
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Maslenkin @ 2023-08-04 19:12 UTC (permalink / raw)
  To: devel, chitralekha.ck; +Cc: Ray Ni, Zhichao Gao, Ashraf Ali S, Chinni B Duggapu

Very nice, that functional changes were separated.
But, as far as I remember, Pedro noticed that AllocatePages() takes
number of pages, not a bytes.
So, the change could be as:
  *GopBlt     = AllocatePages (EFI_SIZE_TO_PAGES(*GopBltSize));

But I I would like you to pay special attention that this change
breaks a previous contract.
AllocatePages() requires FreePages() to free memory, and currently all
consumers of TranslateBmpToGopBlt()
expect memory was allocated in pool and call FreePool() to release this buffer:

https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c#L439
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c#L96
https://github.com/tianocore/edk2-platforms/blob/master/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspSaPolicyInitLib.c#L176

So why don't you want to allocate enough memory and pass this pointer
to TranslateBmpToGopBlt().
As I can see there are some places where it has been done in that way
(thus I was not able to find where buffer is released) :

https://github.com/tianocore/edk2-platforms/blob/master/Platform/Intel/WhiskeylakeOpenBoardPkg/Policy/Library/PeiPolicyUpdateLib/PeiSaPolicyUpdate.c#L133
https://github.com/tianocore/edk2-platforms/blob/master/Platform/Intel/CometlakeOpenBoardPkg/Policy/Library/PeiPolicyUpdateLib/PeiSaPolicyUpdate.c#L133

On Fri, Aug 4, 2023 at 9:08 PM chitralekha ck <chitralekha.ck@intel.com> wrote:
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=4507
> AllocatePool limits to allocate memory of 64 KB at most in PEI Phase.
> AllocatePool() is being avoided due to its 64k allocation size limit
> when the library is incorporated into a PEI component.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
> Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
> Signed-off-by: chitralekha ck <chitralekha.ck@intel.com>
> ---
>  MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
> index c5e885d7a6..a7ebcd1d65 100644
> --- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
> +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
> @@ -52,7 +52,7 @@ const BMP_IMAGE_HEADER  mBmpImageHeaderTemplate = {
>  /**
>    Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
>    is passed in a GopBlt buffer will be allocated by this routine using
> -  EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it will be
> +  EFI_BOOT_SERVICES.AllocatePages(). If a GopBlt buffer is passed in it will be
>    used if it is big enough.
>
>    @param[in]       BmpImage      Pointer to BMP file.
> @@ -312,7 +312,7 @@ TranslateBmpToGopBlt (
>      //
>      DEBUG ((DEBUG_INFO, "Bmp Support: Allocating 0x%X bytes of memory\n", BltBufferSize));
>      *GopBltSize = (UINTN)BltBufferSize;
> -    *GopBlt     = AllocatePool (*GopBltSize);
> +    *GopBlt     = AllocatePages (*GopBltSize);
>      IsAllocated = TRUE;
>      if (*GopBlt == NULL) {
>        return RETURN_OUT_OF_RESOURCES;
> --
> 2.38.1.windows.1
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107585): https://edk2.groups.io/g/devel/message/107585
Mute This Topic: https://groups.io/mt/100551576/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH v3] MdeModulePkg: AllocatePages for TranslateBmpToGopBlt
  2023-08-03  9:29 [edk2-devel] [PATCH v3] MdeModulePkg: AllocatePages for TranslateBmpToGopBlt chitralekha ck
  2023-08-04 19:12 ` Mike Maslenkin
@ 2023-09-01  5:29 ` Ni, Ray
  1 sibling, 0 replies; 3+ messages in thread
From: Ni, Ray @ 2023-09-01  5:29 UTC (permalink / raw)
  To: Ck, Chitralekha, devel@edk2.groups.io
  Cc: Gao, Zhichao, S, Ashraf Ali, Duggapu, Chinni B

[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]

-    *GopBlt     = AllocatePool (*GopBltSize);
+    *GopBlt     = AllocatePages (*GopBltSize);

It doesn't look right. You cannot pass in the same value origilly passed to AllocatePool().

Thanks,
Ray
________________________________
From: Ck, Chitralekha <chitralekha.ck@intel.com>
Sent: Thursday, August 3, 2023 5:29 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Ck, Chitralekha <chitralekha.ck@intel.com>; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; S, Ashraf Ali <ashraf.ali.s@intel.com>; Duggapu, Chinni B <chinni.b.duggapu@intel.com>
Subject: [PATCH v3] MdeModulePkg: AllocatePages for TranslateBmpToGopBlt

https://bugzilla.tianocore.org/show_bug.cgi?id=4507
AllocatePool limits to allocate memory of 64 KB at most in PEI Phase.
AllocatePool() is being avoided due to its 64k allocation size limit
when the library is incorporated into a PEI component.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Signed-off-by: chitralekha ck <chitralekha.ck@intel.com>
---
 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
index c5e885d7a6..a7ebcd1d65 100644
--- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
+++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
@@ -52,7 +52,7 @@ const BMP_IMAGE_HEADER  mBmpImageHeaderTemplate = {
 /**
   Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
   is passed in a GopBlt buffer will be allocated by this routine using
-  EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it will be
+  EFI_BOOT_SERVICES.AllocatePages(). If a GopBlt buffer is passed in it will be
   used if it is big enough.

   @param[in]       BmpImage      Pointer to BMP file.
@@ -312,7 +312,7 @@ TranslateBmpToGopBlt (
     //
     DEBUG ((DEBUG_INFO, "Bmp Support: Allocating 0x%X bytes of memory\n", BltBufferSize));
     *GopBltSize = (UINTN)BltBufferSize;
-    *GopBlt     = AllocatePool (*GopBltSize);
+    *GopBlt     = AllocatePages (*GopBltSize);
     IsAllocated = TRUE;
     if (*GopBlt == NULL) {
       return RETURN_OUT_OF_RESOURCES;
--
2.38.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108225): https://edk2.groups.io/g/devel/message/108225
Mute This Topic: https://groups.io/mt/100551576/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 7420 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-01  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03  9:29 [edk2-devel] [PATCH v3] MdeModulePkg: AllocatePages for TranslateBmpToGopBlt chitralekha ck
2023-08-04 19:12 ` Mike Maslenkin
2023-09-01  5:29 ` Ni, Ray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox