public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
@ 2022-01-07 19:36 Stacy Howell
  2022-01-11  1:59 ` 回复: [edk2-devel] " gaoliming
  0 siblings, 1 reply; 8+ messages in thread
From: Stacy Howell @ 2022-01-07 19:36 UTC (permalink / raw)
  To: devel; +Cc: Stacy Howell, Dandan Bi, Liming Gao

REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
CC: Dandan Bi <dandan.bi@intel.com>
CC: Liming Gao <gaoliming@byosoft.com.cn>

Updated CoreInternalAllocatePages() to call PromoteMemoryResource() and
re-attempt the allocation if unable to convert the specified memory range

Signed-off-by: Stacy Howell <stacy.howell@intel.com>
---
 MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c
index 47d4c5d92e..cc0b90ac0d 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Page.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
@@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
     Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
   }
 
+  if (EFI_ERROR (Status)) {
+    //
+    // If requested memory region is unavailable it may be untested memory
+    // Attempt to promote memory resources, then re-attempt the allocation
+    //
+    if (PromoteMemoryResource ()) {
+      if (NeedGuard) {
+        Status = CoreConvertPagesWithGuard (Start, NumberOfPages, MemoryType);
+      } else {
+        Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
+      }
+    }
+  }
+
 Done:
   CoreReleaseMemoryLock ();
 
-- 
2.32.0.windows.2


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

* 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
  2022-01-07 19:36 [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory Stacy Howell
@ 2022-01-11  1:59 ` gaoliming
  2022-01-11  2:47   ` Sean
  0 siblings, 1 reply; 8+ messages in thread
From: gaoliming @ 2022-01-11  1:59 UTC (permalink / raw)
  To: devel, stacy.howell; +Cc: 'Dandan Bi'

Stacy:
  This fix covers the case with AllocateAddress allocation type. I agree
this fix. Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Stacy Howell
> 发送时间: 2022年1月8日 3:36
> 收件人: devel@edk2.groups.io
> 抄送: Stacy Howell <stacy.howell@intel.com>; Dandan Bi
> <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
> 主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to
> use untested memory
> 
> REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
> CC: Dandan Bi <dandan.bi@intel.com>
> CC: Liming Gao <gaoliming@byosoft.com.cn>
> 
> Updated CoreInternalAllocatePages() to call PromoteMemoryResource() and
> re-attempt the allocation if unable to convert the specified memory range
> 
> Signed-off-by: Stacy Howell <stacy.howell@intel.com>
> ---
>  MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c
> b/MdeModulePkg/Core/Dxe/Mem/Page.c
> index 47d4c5d92e..cc0b90ac0d 100644
> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c
> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
> @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
>      Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
>    }
> 
> +  if (EFI_ERROR (Status)) {
> +    //
> +    // If requested memory region is unavailable it may be untested
> memory
> +    // Attempt to promote memory resources, then re-attempt the
> allocation
> +    //
> +    if (PromoteMemoryResource ()) {
> +      if (NeedGuard) {
> +        Status = CoreConvertPagesWithGuard (Start, NumberOfPages,
> MemoryType);
> +      } else {
> +        Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> +      }
> +    }
> +  }
> +
>  Done:
>    CoreReleaseMemoryLock ();
> 
> --
> 2.32.0.windows.2
> 
> 
> 
> 
> 




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

* Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
  2022-01-11  1:59 ` 回复: [edk2-devel] " gaoliming
@ 2022-01-11  2:47   ` Sean
  2022-01-11  3:08     ` 回复: " gaoliming
  2022-01-11 15:57     ` Michael D Kinney
  0 siblings, 2 replies; 8+ messages in thread
From: Sean @ 2022-01-11  2:47 UTC (permalink / raw)
  To: devel, gaoliming, stacy.howell; +Cc: 'Dandan Bi'

if this is auto promotion is happening in the core then what is the 
value of memory testing and tracking that state.   Is memory testing 
state a necessary feature of the Dxe Core?


I think it makes more sense that if you platform wants to use a given 
range your platform should either test it and/or mark it as tested.

OR

The dxe core should do away with the memory testing tracking.


On most platforms i have seen in the past few years all memory is marked 
as tested without doing any testing.  The only value in the flag is keep 
the initial memory allocations in a given low range (below 4gb).




On 1/10/2022 5:59 PM, gaoliming wrote:
> Stacy:
>    This fix covers the case with AllocateAddress allocation type. I agree
> this fix. Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> 
> Thanks
> Liming
>> -----邮件原件-----
>> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Stacy Howell
>> 发送时间: 2022年1月8日 3:36
>> 收件人: devel@edk2.groups.io
>> 抄送: Stacy Howell <stacy.howell@intel.com>; Dandan Bi
>> <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
>> 主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to
>> use untested memory
>>
>> REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
>> CC: Dandan Bi <dandan.bi@intel.com>
>> CC: Liming Gao <gaoliming@byosoft.com.cn>
>>
>> Updated CoreInternalAllocatePages() to call PromoteMemoryResource() and
>> re-attempt the allocation if unable to convert the specified memory range
>>
>> Signed-off-by: Stacy Howell <stacy.howell@intel.com>
>> ---
>>   MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c
>> b/MdeModulePkg/Core/Dxe/Mem/Page.c
>> index 47d4c5d92e..cc0b90ac0d 100644
>> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c
>> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
>> @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
>>       Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
>>     }
>>
>> +  if (EFI_ERROR (Status)) {
>> +    //
>> +    // If requested memory region is unavailable it may be untested
>> memory
>> +    // Attempt to promote memory resources, then re-attempt the
>> allocation
>> +    //
>> +    if (PromoteMemoryResource ()) {
>> +      if (NeedGuard) {
>> +        Status = CoreConvertPagesWithGuard (Start, NumberOfPages,
>> MemoryType);
>> +      } else {
>> +        Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
>> +      }
>> +    }
>> +  }
>> +
>>   Done:
>>     CoreReleaseMemoryLock ();
>>
>> --
>> 2.32.0.windows.2
>>
>>
>>
>>
>>
> 
> 
> 
> 
> 
> 
> 
> 

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

* 回复: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
  2022-01-11  2:47   ` Sean
@ 2022-01-11  3:08     ` gaoliming
  2022-01-11 15:57     ` Michael D Kinney
  1 sibling, 0 replies; 8+ messages in thread
From: gaoliming @ 2022-01-11  3:08 UTC (permalink / raw)
  To: devel, spbrogan, stacy.howell
  Cc: 'Dandan Bi', 'Michael D Kinney'

Sean:
 Yes. Platform can report the tested memory for the specific range. 

Stacy:
 Can you evaluate Sean's solution for your problem?

Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sean
> 发送时间: 2022年1月11日 10:47
> 收件人: devel@edk2.groups.io; gaoliming@byosoft.com.cn;
> stacy.howell@intel.com
> 抄送: 'Dandan Bi' <dandan.bi@intel.com>
> 主题: Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE
> Drivers to use untested memory
> 
> if this is auto promotion is happening in the core then what is the
> value of memory testing and tracking that state.   Is memory testing
> state a necessary feature of the Dxe Core?
> 
> 
> I think it makes more sense that if you platform wants to use a given
> range your platform should either test it and/or mark it as tested.
> 
> OR
> 
> The dxe core should do away with the memory testing tracking.
> 
> 
> On most platforms i have seen in the past few years all memory is marked
> as tested without doing any testing.  The only value in the flag is keep
> the initial memory allocations in a given low range (below 4gb).
> 
> 
> 
> 
> On 1/10/2022 5:59 PM, gaoliming wrote:
> > Stacy:
> >    This fix covers the case with AllocateAddress allocation type. I agree
> > this fix. Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> >
> > Thanks
> > Liming
> >> -----邮件原件-----
> >> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Stacy
> Howell
> >> 发送时间: 2022年1月8日 3:36
> >> 收件人: devel@edk2.groups.io
> >> 抄送: Stacy Howell <stacy.howell@intel.com>; Dandan Bi
> >> <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
> >> 主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers
> to
> >> use untested memory
> >>
> >> REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
> >> CC: Dandan Bi <dandan.bi@intel.com>
> >> CC: Liming Gao <gaoliming@byosoft.com.cn>
> >>
> >> Updated CoreInternalAllocatePages() to call PromoteMemoryResource()
> and
> >> re-attempt the allocation if unable to convert the specified memory range
> >>
> >> Signed-off-by: Stacy Howell <stacy.howell@intel.com>
> >> ---
> >>   MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
> >>   1 file changed, 14 insertions(+)
> >>
> >> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> index 47d4c5d92e..cc0b90ac0d 100644
> >> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
> >>       Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> >>     }
> >>
> >> +  if (EFI_ERROR (Status)) {
> >> +    //
> >> +    // If requested memory region is unavailable it may be untested
> >> memory
> >> +    // Attempt to promote memory resources, then re-attempt the
> >> allocation
> >> +    //
> >> +    if (PromoteMemoryResource ()) {
> >> +      if (NeedGuard) {
> >> +        Status = CoreConvertPagesWithGuard (Start, NumberOfPages,
> >> MemoryType);
> >> +      } else {
> >> +        Status = CoreConvertPages (Start, NumberOfPages,
> MemoryType);
> >> +      }
> >> +    }
> >> +  }
> >> +
> >>   Done:
> >>     CoreReleaseMemoryLock ();
> >>
> >> --
> >> 2.32.0.windows.2
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 




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

* Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
  2022-01-11  2:47   ` Sean
  2022-01-11  3:08     ` 回复: " gaoliming
@ 2022-01-11 15:57     ` Michael D Kinney
  2022-01-14 21:12       ` Howell, Stacy
  1 sibling, 1 reply; 8+ messages in thread
From: Michael D Kinney @ 2022-01-11 15:57 UTC (permalink / raw)
  To: devel@edk2.groups.io, spbrogan@outlook.com, Gao, Liming,
	Howell, Stacy, Kinney, Michael D
  Cc: Bi, Dandan

Hi Sean,

The auto promotion of memory was only intended as a dev/debug feature to maximize
platform boot without having to tune what memory is tested in PEI phase.

In my opinion, a production platform should never trigger any auto promotions of
untested to tested memory, and part of production validation should make sure this
event never occurs in any production boot scenarios.

The specific bug being fix here is that auto promotion was not symmetric across
all memory allocation types.  It simply aligns this dev/debug feature.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean
> Sent: Monday, January 10, 2022 6:47 PM
> To: devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Howell, Stacy <stacy.howell@intel.com>
> Cc: Bi, Dandan <dandan.bi@intel.com>
> Subject: Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
> 
> if this is auto promotion is happening in the core then what is the
> value of memory testing and tracking that state.   Is memory testing
> state a necessary feature of the Dxe Core?
> 
> 
> I think it makes more sense that if you platform wants to use a given
> range your platform should either test it and/or mark it as tested.
> 
> OR
> 
> The dxe core should do away with the memory testing tracking.
> 
> 
> On most platforms i have seen in the past few years all memory is marked
> as tested without doing any testing.  The only value in the flag is keep
> the initial memory allocations in a given low range (below 4gb).
> 
> 
> 
> 
> On 1/10/2022 5:59 PM, gaoliming wrote:
> > Stacy:
> >    This fix covers the case with AllocateAddress allocation type. I agree
> > this fix. Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> >
> > Thanks
> > Liming
> >> -----邮件原件-----
> >> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Stacy Howell
> >> 发送时间: 2022年1月8日 3:36
> >> 收件人: devel@edk2.groups.io
> >> 抄送: Stacy Howell <stacy.howell@intel.com>; Dandan Bi
> >> <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
> >> 主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to
> >> use untested memory
> >>
> >> REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
> >> CC: Dandan Bi <dandan.bi@intel.com>
> >> CC: Liming Gao <gaoliming@byosoft.com.cn>
> >>
> >> Updated CoreInternalAllocatePages() to call PromoteMemoryResource() and
> >> re-attempt the allocation if unable to convert the specified memory range
> >>
> >> Signed-off-by: Stacy Howell <stacy.howell@intel.com>
> >> ---
> >>   MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
> >>   1 file changed, 14 insertions(+)
> >>
> >> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> index 47d4c5d92e..cc0b90ac0d 100644
> >> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
> >>       Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> >>     }
> >>
> >> +  if (EFI_ERROR (Status)) {
> >> +    //
> >> +    // If requested memory region is unavailable it may be untested
> >> memory
> >> +    // Attempt to promote memory resources, then re-attempt the
> >> allocation
> >> +    //
> >> +    if (PromoteMemoryResource ()) {
> >> +      if (NeedGuard) {
> >> +        Status = CoreConvertPagesWithGuard (Start, NumberOfPages,
> >> MemoryType);
> >> +      } else {
> >> +        Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> >> +      }
> >> +    }
> >> +  }
> >> +
> >>   Done:
> >>     CoreReleaseMemoryLock ();
> >>
> >> --
> >> 2.32.0.windows.2
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 


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

* Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
  2022-01-11 15:57     ` Michael D Kinney
@ 2022-01-14 21:12       ` Howell, Stacy
  2022-04-25 14:10         ` Howell, Stacy
  0 siblings, 1 reply; 8+ messages in thread
From: Howell, Stacy @ 2022-01-14 21:12 UTC (permalink / raw)
  To: Kinney, Michael D, devel@edk2.groups.io, spbrogan@outlook.com,
	Gao, Liming
  Cc: Bi, Dandan, Howell, Stacy

Hi Sean,
Setting all memory as tested in PEI is a workaround for the issue that this patch addresses.  However, promoting all memory in PEI is not a workable solution for BIOSes that incorporate full memory testing functionality, as this relies on the tested flag to determine which memory regions to test.

This patch addresses a discrepancy in EDK2 core regarding how untested memory is treated for allocation by DXE drivers.  In the case where a DXE driver does not request a specific memory region DXE Core will promote untested memory if necessary to provide memory to the driver.  In the case where a DXE driver requests a specific memory range of untested memory, DXE Core will currently return an error instead of promoting untested memory to make the region available for the driver.

Thanks,
Stacy

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@intel.com> 
Sent: Tuesday, January 11, 2022 10:57 AM
To: devel@edk2.groups.io; spbrogan@outlook.com; Gao, Liming <gaoliming@byosoft.com.cn>; Howell, Stacy <stacy.howell@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Cc: Bi, Dandan <dandan.bi@intel.com>
Subject: RE: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory

Hi Sean,

The auto promotion of memory was only intended as a dev/debug feature to maximize platform boot without having to tune what memory is tested in PEI phase.

In my opinion, a production platform should never trigger any auto promotions of untested to tested memory, and part of production validation should make sure this event never occurs in any production boot scenarios.

The specific bug being fix here is that auto promotion was not symmetric across all memory allocation types.  It simply aligns this dev/debug feature.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean
> Sent: Monday, January 10, 2022 6:47 PM
> To: devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; 
> Howell, Stacy <stacy.howell@intel.com>
> Cc: Bi, Dandan <dandan.bi@intel.com>
> Subject: Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE 
> Drivers to use untested memory
> 
> if this is auto promotion is happening in the core then what is the
> value of memory testing and tracking that state.   Is memory testing
> state a necessary feature of the Dxe Core?
> 
> 
> I think it makes more sense that if you platform wants to use a given 
> range your platform should either test it and/or mark it as tested.
> 
> OR
> 
> The dxe core should do away with the memory testing tracking.
> 
> 
> On most platforms i have seen in the past few years all memory is 
> marked as tested without doing any testing.  The only value in the 
> flag is keep the initial memory allocations in a given low range (below 4gb).
> 
> 
> 
> 
> On 1/10/2022 5:59 PM, gaoliming wrote:
> > Stacy:
> >    This fix covers the case with AllocateAddress allocation type. I 
> > agree this fix. Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> >
> > Thanks
> > Liming
> >> -----邮件原件-----
> >> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Stacy Howell
> >> 发送时间: 2022年1月8日 3:36
> >> 收件人: devel@edk2.groups.io
> >> 抄送: Stacy Howell <stacy.howell@intel.com>; Dandan Bi 
> >> <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
> >> 主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to 
> >> use untested memory
> >>
> >> REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
> >> CC: Dandan Bi <dandan.bi@intel.com>
> >> CC: Liming Gao <gaoliming@byosoft.com.cn>
> >>
> >> Updated CoreInternalAllocatePages() to call PromoteMemoryResource() 
> >> and re-attempt the allocation if unable to convert the specified 
> >> memory range
> >>
> >> Signed-off-by: Stacy Howell <stacy.howell@intel.com>
> >> ---
> >>   MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
> >>   1 file changed, 14 insertions(+)
> >>
> >> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> index 47d4c5d92e..cc0b90ac0d 100644
> >> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
> >>       Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> >>     }
> >>
> >> +  if (EFI_ERROR (Status)) {
> >> +    //
> >> +    // If requested memory region is unavailable it may be 
> >> + untested
> >> memory
> >> +    // Attempt to promote memory resources, then re-attempt the
> >> allocation
> >> +    //
> >> +    if (PromoteMemoryResource ()) {
> >> +      if (NeedGuard) {
> >> +        Status = CoreConvertPagesWithGuard (Start, NumberOfPages,
> >> MemoryType);
> >> +      } else {
> >> +        Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> >> +      }
> >> +    }
> >> +  }
> >> +
> >>   Done:
> >>     CoreReleaseMemoryLock ();
> >>
> >> --
> >> 2.32.0.windows.2
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 


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

* Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
  2022-01-14 21:12       ` Howell, Stacy
@ 2022-04-25 14:10         ` Howell, Stacy
  2022-07-16  3:24           ` 回复: " gaoliming
  0 siblings, 1 reply; 8+ messages in thread
From: Howell, Stacy @ 2022-04-25 14:10 UTC (permalink / raw)
  To: Kinney, Michael D, devel@edk2.groups.io, spbrogan@outlook.com,
	Gao, Liming
  Cc: Bi, Dandan, Howell, Stacy

Hi all,
Are there any other comments or concerns regarding this patch?

Thanks,
Stacy

-----Original Message-----
From: Howell, Stacy 
Sent: Friday, January 14, 2022 4:13 PM
To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io; spbrogan@outlook.com; Gao, Liming <gaoliming@byosoft.com.cn>
Cc: Bi, Dandan <dandan.bi@intel.com>; Howell, Stacy <stacy.howell@intel.com>
Subject: RE: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory

Hi Sean,
Setting all memory as tested in PEI is a workaround for the issue that this patch addresses.  However, promoting all memory in PEI is not a workable solution for BIOSes that incorporate full memory testing functionality, as this relies on the tested flag to determine which memory regions to test.

This patch addresses a discrepancy in EDK2 core regarding how untested memory is treated for allocation by DXE drivers.  In the case where a DXE driver does not request a specific memory region DXE Core will promote untested memory if necessary to provide memory to the driver.  In the case where a DXE driver requests a specific memory range of untested memory, DXE Core will currently return an error instead of promoting untested memory to make the region available for the driver.

Thanks,
Stacy

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@intel.com>
Sent: Tuesday, January 11, 2022 10:57 AM
To: devel@edk2.groups.io; spbrogan@outlook.com; Gao, Liming <gaoliming@byosoft.com.cn>; Howell, Stacy <stacy.howell@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Cc: Bi, Dandan <dandan.bi@intel.com>
Subject: RE: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory

Hi Sean,

The auto promotion of memory was only intended as a dev/debug feature to maximize platform boot without having to tune what memory is tested in PEI phase.

In my opinion, a production platform should never trigger any auto promotions of untested to tested memory, and part of production validation should make sure this event never occurs in any production boot scenarios.

The specific bug being fix here is that auto promotion was not symmetric across all memory allocation types.  It simply aligns this dev/debug feature.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean
> Sent: Monday, January 10, 2022 6:47 PM
> To: devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; 
> Howell, Stacy <stacy.howell@intel.com>
> Cc: Bi, Dandan <dandan.bi@intel.com>
> Subject: Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE 
> Drivers to use untested memory
> 
> if this is auto promotion is happening in the core then what is the
> value of memory testing and tracking that state.   Is memory testing
> state a necessary feature of the Dxe Core?
> 
> 
> I think it makes more sense that if you platform wants to use a given 
> range your platform should either test it and/or mark it as tested.
> 
> OR
> 
> The dxe core should do away with the memory testing tracking.
> 
> 
> On most platforms i have seen in the past few years all memory is 
> marked as tested without doing any testing.  The only value in the 
> flag is keep the initial memory allocations in a given low range (below 4gb).
> 
> 
> 
> 
> On 1/10/2022 5:59 PM, gaoliming wrote:
> > Stacy:
> >    This fix covers the case with AllocateAddress allocation type. I 
> > agree this fix. Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> >
> > Thanks
> > Liming
> >> -----邮件原件-----
> >> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Stacy Howell
> >> 发送时间: 2022年1月8日 3:36
> >> 收件人: devel@edk2.groups.io
> >> 抄送: Stacy Howell <stacy.howell@intel.com>; Dandan Bi 
> >> <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
> >> 主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to 
> >> use untested memory
> >>
> >> REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
> >> CC: Dandan Bi <dandan.bi@intel.com>
> >> CC: Liming Gao <gaoliming@byosoft.com.cn>
> >>
> >> Updated CoreInternalAllocatePages() to call PromoteMemoryResource() 
> >> and re-attempt the allocation if unable to convert the specified 
> >> memory range
> >>
> >> Signed-off-by: Stacy Howell <stacy.howell@intel.com>
> >> ---
> >>   MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
> >>   1 file changed, 14 insertions(+)
> >>
> >> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> index 47d4c5d92e..cc0b90ac0d 100644
> >> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
> >> @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
> >>       Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> >>     }
> >>
> >> +  if (EFI_ERROR (Status)) {
> >> +    //
> >> +    // If requested memory region is unavailable it may be 
> >> + untested
> >> memory
> >> +    // Attempt to promote memory resources, then re-attempt the
> >> allocation
> >> +    //
> >> +    if (PromoteMemoryResource ()) {
> >> +      if (NeedGuard) {
> >> +        Status = CoreConvertPagesWithGuard (Start, NumberOfPages,
> >> MemoryType);
> >> +      } else {
> >> +        Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
> >> +      }
> >> +    }
> >> +  }
> >> +
> >>   Done:
> >>     CoreReleaseMemoryLock ();
> >>
> >> --
> >> 2.32.0.windows.2
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 


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

* 回复: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory
  2022-04-25 14:10         ` Howell, Stacy
@ 2022-07-16  3:24           ` gaoliming
  0 siblings, 0 replies; 8+ messages in thread
From: gaoliming @ 2022-07-16  3:24 UTC (permalink / raw)
  To: devel, stacy.howell, 'Kinney, Michael D', spbrogan
  Cc: 'Bi, Dandan'

If no other objection, I will merge this patch next week. 

Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Howell, Stacy
> 发送时间: 2022年4月25日 22:11
> 收件人: Kinney, Michael D <michael.d.kinney@intel.com>;
> devel@edk2.groups.io; spbrogan@outlook.com; Gao, Liming
> <gaoliming@byosoft.com.cn>
> 抄送: Bi, Dandan <dandan.bi@intel.com>; Howell, Stacy
> <stacy.howell@intel.com>
> 主题: Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE
> Drivers to use untested memory
> 
> Hi all,
> Are there any other comments or concerns regarding this patch?
> 
> Thanks,
> Stacy
> 
> -----Original Message-----
> From: Howell, Stacy
> Sent: Friday, January 14, 2022 4:13 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io;
> spbrogan@outlook.com; Gao, Liming <gaoliming@byosoft.com.cn>
> Cc: Bi, Dandan <dandan.bi@intel.com>; Howell, Stacy
> <stacy.howell@intel.com>
> Subject: RE: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE
> Drivers to use untested memory
> 
> Hi Sean,
> Setting all memory as tested in PEI is a workaround for the issue that this
> patch addresses.  However, promoting all memory in PEI is not a workable
> solution for BIOSes that incorporate full memory testing functionality, as this
> relies on the tested flag to determine which memory regions to test.
> 
> This patch addresses a discrepancy in EDK2 core regarding how untested
> memory is treated for allocation by DXE drivers.  In the case where a DXE
> driver does not request a specific memory region DXE Core will promote
> untested memory if necessary to provide memory to the driver.  In the case
> where a DXE driver requests a specific memory range of untested memory,
> DXE Core will currently return an error instead of promoting untested memory
> to make the region available for the driver.
> 
> Thanks,
> Stacy
> 
> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Tuesday, January 11, 2022 10:57 AM
> To: devel@edk2.groups.io; spbrogan@outlook.com; Gao, Liming
> <gaoliming@byosoft.com.cn>; Howell, Stacy <stacy.howell@intel.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Bi, Dandan <dandan.bi@intel.com>
> Subject: RE: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE
> Drivers to use untested memory
> 
> Hi Sean,
> 
> The auto promotion of memory was only intended as a dev/debug feature to
> maximize platform boot without having to tune what memory is tested in PEI
> phase.
> 
> In my opinion, a production platform should never trigger any auto
> promotions of untested to tested memory, and part of production validation
> should make sure this event never occurs in any production boot scenarios.
> 
> The specific bug being fix here is that auto promotion was not symmetric
> across all memory allocation types.  It simply aligns this dev/debug feature.
> 
> Mike
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean
> > Sent: Monday, January 10, 2022 6:47 PM
> > To: devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>;
> > Howell, Stacy <stacy.howell@intel.com>
> > Cc: Bi, Dandan <dandan.bi@intel.com>
> > Subject: Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow
> DXE
> > Drivers to use untested memory
> >
> > if this is auto promotion is happening in the core then what is the
> > value of memory testing and tracking that state.   Is memory testing
> > state a necessary feature of the Dxe Core?
> >
> >
> > I think it makes more sense that if you platform wants to use a given
> > range your platform should either test it and/or mark it as tested.
> >
> > OR
> >
> > The dxe core should do away with the memory testing tracking.
> >
> >
> > On most platforms i have seen in the past few years all memory is
> > marked as tested without doing any testing.  The only value in the
> > flag is keep the initial memory allocations in a given low range (below 4gb).
> >
> >
> >
> >
> > On 1/10/2022 5:59 PM, gaoliming wrote:
> > > Stacy:
> > >    This fix covers the case with AllocateAddress allocation type. I
> > > agree this fix. Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> > >
> > > Thanks
> > > Liming
> > >> -----邮件原件-----
> > >> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Stacy
> Howell
> > >> 发送时间: 2022年1月8日 3:36
> > >> 收件人: devel@edk2.groups.io
> > >> 抄送: Stacy Howell <stacy.howell@intel.com>; Dandan Bi
> > >> <dandan.bi@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
> > >> 主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers
> to
> > >> use untested memory
> > >>
> > >> REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795
> > >> CC: Dandan Bi <dandan.bi@intel.com>
> > >> CC: Liming Gao <gaoliming@byosoft.com.cn>
> > >>
> > >> Updated CoreInternalAllocatePages() to call PromoteMemoryResource()
> > >> and re-attempt the allocation if unable to convert the specified
> > >> memory range
> > >>
> > >> Signed-off-by: Stacy Howell <stacy.howell@intel.com>
> > >> ---
> > >>   MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++
> > >>   1 file changed, 14 insertions(+)
> > >>
> > >> diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c
> > >> b/MdeModulePkg/Core/Dxe/Mem/Page.c
> > >> index 47d4c5d92e..cc0b90ac0d 100644
> > >> --- a/MdeModulePkg/Core/Dxe/Mem/Page.c
> > >> +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
> > >> @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages (
> > >>       Status = CoreConvertPages (Start, NumberOfPages,
> MemoryType);
> > >>     }
> > >>
> > >> +  if (EFI_ERROR (Status)) {
> > >> +    //
> > >> +    // If requested memory region is unavailable it may be
> > >> + untested
> > >> memory
> > >> +    // Attempt to promote memory resources, then re-attempt the
> > >> allocation
> > >> +    //
> > >> +    if (PromoteMemoryResource ()) {
> > >> +      if (NeedGuard) {
> > >> +        Status = CoreConvertPagesWithGuard (Start,
> NumberOfPages,
> > >> MemoryType);
> > >> +      } else {
> > >> +        Status = CoreConvertPages (Start, NumberOfPages,
> MemoryType);
> > >> +      }
> > >> +    }
> > >> +  }
> > >> +
> > >>   Done:
> > >>     CoreReleaseMemoryLock ();
> > >>
> > >> --
> > >> 2.32.0.windows.2
> > >>
> > >>
> > >>
> > >>
> > >>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> 
> 
> 
> 
> 




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

end of thread, other threads:[~2022-07-16  3:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-07 19:36 [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory Stacy Howell
2022-01-11  1:59 ` 回复: [edk2-devel] " gaoliming
2022-01-11  2:47   ` Sean
2022-01-11  3:08     ` 回复: " gaoliming
2022-01-11 15:57     ` Michael D Kinney
2022-01-14 21:12       ` Howell, Stacy
2022-04-25 14:10         ` Howell, Stacy
2022-07-16  3:24           ` 回复: " gaoliming

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