* correct way to reserve memory from PrePi?
@ 2016-12-14 10:02 Michael Zimmermann
2016-12-14 10:21 ` Ard Biesheuvel
0 siblings, 1 reply; 8+ messages in thread
From: Michael Zimmermann @ 2016-12-14 10:02 UTC (permalink / raw)
To: edk2-devel@lists.01.org, Ard Biesheuvel
I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
but apparently they don't have any effect.
When I look at the output of the shell's memmap command there aren't
any reserved/unavailable pages.
Furthermore, when using AllocatePages with one of the physical
addresses which I've reserved it succeeds which means that it's not
just a problem of how the memmap command works.
Am I doing something wrong or is this a bug?
Thanks
Michael
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: correct way to reserve memory from PrePi?
2016-12-14 10:02 correct way to reserve memory from PrePi? Michael Zimmermann
@ 2016-12-14 10:21 ` Ard Biesheuvel
2016-12-14 15:13 ` Michael Zimmermann
0 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2016-12-14 10:21 UTC (permalink / raw)
To: Michael Zimmermann; +Cc: edk2-devel@lists.01.org
On 14 December 2016 at 10:02, Michael Zimmermann
<sigmaepsilon92@gmail.com> wrote:
> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
> but apparently they don't have any effect.
> When I look at the output of the shell's memmap command there aren't
> any reserved/unavailable pages.
>
> Furthermore, when using AllocatePages with one of the physical
> addresses which I've reserved it succeeds which means that it's not
> just a problem of how the memmap command works.
>
> Am I doing something wrong or is this a bug?
>
I think you need to ensure that they don't overlap existing resource
descriptors: if you declare a region as reserved, you should not
declare it as memory first
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: correct way to reserve memory from PrePi?
2016-12-14 10:21 ` Ard Biesheuvel
@ 2016-12-14 15:13 ` Michael Zimmermann
2016-12-14 17:57 ` Michael Zimmermann
0 siblings, 1 reply; 8+ messages in thread
From: Michael Zimmermann @ 2016-12-14 15:13 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org
As far as I know the proper way is to create resource descriptors
using BuildResourceDescriptorHob and then allocate reserved areas
using BuildMemoryAllocationHob. This way I don't have any overlapping
descriptors - I just allocated some memory very early.
I ran many tests and it looks like all calls to
BuildMemoryAllocationHob get ignored if my dram hobs look like this:
0x00000000 - 0x40000000
If I split this range into two Hob's like this everything seems to
work just fine:
0x00000000 - 0x20000000
0x20000000 - 0x20000000
I took a look at other platforms like Juno and they add big dram Hob's
(2GB and 6GB) too so why is this a problem?
Thanks
Michael
On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
> On 14 December 2016 at 10:02, Michael Zimmermann
> <sigmaepsilon92@gmail.com> wrote:
>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
>> but apparently they don't have any effect.
>> When I look at the output of the shell's memmap command there aren't
>> any reserved/unavailable pages.
>>
>> Furthermore, when using AllocatePages with one of the physical
>> addresses which I've reserved it succeeds which means that it's not
>> just a problem of how the memmap command works.
>>
>> Am I doing something wrong or is this a bug?
>>
>
> I think you need to ensure that they don't overlap existing resource
> descriptors: if you declare a region as reserved, you should not
> declare it as memory first
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: correct way to reserve memory from PrePi?
2016-12-14 15:13 ` Michael Zimmermann
@ 2016-12-14 17:57 ` Michael Zimmermann
2016-12-15 4:55 ` Gao, Liming
0 siblings, 1 reply; 8+ messages in thread
From: Michael Zimmermann @ 2016-12-14 17:57 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org
I've enabled GCD debugging and apparently it doesn't accept the allocation:
GCD:AllocateMemorySpace(Base=0000000090000000,Length=0000000010000000)
GcdAllocateType = AtAddress
GcdMemoryType = SystemMem
Alignment = 0000000000000001
ImageHandle = FDE28F90
DeviceHandle = 0
CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
CoreAllocateSpace:1130
Status = Not Found
GCDMemType Range Capabilities
Attributes
========== ================================= ================
================
NonExist 0000000000000000-000000007FFFFFFF 0000000000000000
0000000000000000
SystemMem 0000000080000000-00000000FDFFFFFF 800000000000000E
0000000000000000*
NonExist 00000000FE000000-00000000FE3FFFFF 0000000000000000
0000000000000000
SystemMem 00000000FE400000-00000000FFFE5FFF 800000000000000E
0000000000000000
SystemMem 00000000FFFE6000-00000000FFFEEFFF 800000000000000E
0000000000000000*
SystemMem 00000000FFFEF000-00000000FFFFFFFF 800000000000000E 0000000000000000
It fails in this line:
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Gcd/Gcd.c#L982
In this example I've used(start,size) 0x80000000,0x80000000 for the
resource descriptors.
If I use 0x80000000,0x40000000 and 0xc0000000,0x40000000 everything
works just fine.
Thanks
Michael
On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
<sigmaepsilon92@gmail.com> wrote:
> As far as I know the proper way is to create resource descriptors
> using BuildResourceDescriptorHob and then allocate reserved areas
> using BuildMemoryAllocationHob. This way I don't have any overlapping
> descriptors - I just allocated some memory very early.
>
> I ran many tests and it looks like all calls to
> BuildMemoryAllocationHob get ignored if my dram hobs look like this:
> 0x00000000 - 0x40000000
>
> If I split this range into two Hob's like this everything seems to
> work just fine:
> 0x00000000 - 0x20000000
> 0x20000000 - 0x20000000
>
> I took a look at other platforms like Juno and they add big dram Hob's
> (2GB and 6GB) too so why is this a problem?
>
> Thanks
> Michael
>
> On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
> <ard.biesheuvel@linaro.org> wrote:
>> On 14 December 2016 at 10:02, Michael Zimmermann
>> <sigmaepsilon92@gmail.com> wrote:
>>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
>>> but apparently they don't have any effect.
>>> When I look at the output of the shell's memmap command there aren't
>>> any reserved/unavailable pages.
>>>
>>> Furthermore, when using AllocatePages with one of the physical
>>> addresses which I've reserved it succeeds which means that it's not
>>> just a problem of how the memmap command works.
>>>
>>> Am I doing something wrong or is this a bug?
>>>
>>
>> I think you need to ensure that they don't overlap existing resource
>> descriptors: if you declare a region as reserved, you should not
>> declare it as memory first
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: correct way to reserve memory from PrePi?
2016-12-14 17:57 ` Michael Zimmermann
@ 2016-12-15 4:55 ` Gao, Liming
2016-12-15 5:02 ` Michael Zimmermann
0 siblings, 1 reply; 8+ messages in thread
From: Gao, Liming @ 2016-12-15 4:55 UTC (permalink / raw)
To: Michael Zimmermann, Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Gao, Liming
Michael:
I understand your usage that BuildResourceDescriptorHob adds system memory range, BuildMemoryAllocationHob allocate the full memory range as reserved memory. Then, you expect they can be shown in EFI memory map. Right?
BuildResourceDescriptorHob() with (start,size) 0x80000000,0x80000000, then BuildMemoryAllocationHob() with (start,size) 0x80000000,0x80000000. It doesn't work.
Two BuildResourceDescriptorHob() with (start,size) 0x80000000,0x40000000 and 0xc0000000,0x40000000, then two BuildMemoryAllocationHob(). It does work. Right?
Thanks
Liming
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Michael Zimmermann
> Sent: Thursday, December 15, 2016 1:57 AM
> To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: edk2-devel@lists.01.org <edk2-devel@ml01.01.org>
> Subject: Re: [edk2] correct way to reserve memory from PrePi?
>
> I've enabled GCD debugging and apparently it doesn't accept the allocation:
> GCD:AllocateMemorySpace(Base=0000000090000000,Length=0000000010000
> 000)
> GcdAllocateType = AtAddress
> GcdMemoryType = SystemMem
> Alignment = 0000000000000001
> ImageHandle = FDE28F90
> DeviceHandle = 0
> CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
> CoreAllocateSpace:1130
> Status = Not Found
> GCDMemType Range Capabilities
> Attributes
> ========== =================================
> ================
> ================
> NonExist 0000000000000000-000000007FFFFFFF 0000000000000000
> 0000000000000000
> SystemMem 0000000080000000-00000000FDFFFFFF 800000000000000E
> 0000000000000000*
> NonExist 00000000FE000000-00000000FE3FFFFF 0000000000000000
> 0000000000000000
> SystemMem 00000000FE400000-00000000FFFE5FFF 800000000000000E
> 0000000000000000
> SystemMem 00000000FFFE6000-00000000FFFEEFFF 800000000000000E
> 0000000000000000*
> SystemMem 00000000FFFEF000-00000000FFFFFFFF 800000000000000E
> 0000000000000000
>
>
> It fails in this line:
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe
> /Gcd/Gcd.c#L982
> In this example I've used(start,size) 0x80000000,0x80000000 for the
> resource descriptors.
> If I use 0x80000000,0x40000000 and 0xc0000000,0x40000000 everything
> works just fine.
>
> Thanks
> Michael
>
> On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
> <sigmaepsilon92@gmail.com> wrote:
> > As far as I know the proper way is to create resource descriptors
> > using BuildResourceDescriptorHob and then allocate reserved areas
> > using BuildMemoryAllocationHob. This way I don't have any overlapping
> > descriptors - I just allocated some memory very early.
> >
> > I ran many tests and it looks like all calls to
> > BuildMemoryAllocationHob get ignored if my dram hobs look like this:
> > 0x00000000 - 0x40000000
> >
> > If I split this range into two Hob's like this everything seems to
> > work just fine:
> > 0x00000000 - 0x20000000
> > 0x20000000 - 0x20000000
> >
> > I took a look at other platforms like Juno and they add big dram Hob's
> > (2GB and 6GB) too so why is this a problem?
> >
> > Thanks
> > Michael
> >
> > On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
> > <ard.biesheuvel@linaro.org> wrote:
> >> On 14 December 2016 at 10:02, Michael Zimmermann
> >> <sigmaepsilon92@gmail.com> wrote:
> >>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
> >>> but apparently they don't have any effect.
> >>> When I look at the output of the shell's memmap command there aren't
> >>> any reserved/unavailable pages.
> >>>
> >>> Furthermore, when using AllocatePages with one of the physical
> >>> addresses which I've reserved it succeeds which means that it's not
> >>> just a problem of how the memmap command works.
> >>>
> >>> Am I doing something wrong or is this a bug?
> >>>
> >>
> >> I think you need to ensure that they don't overlap existing resource
> >> descriptors: if you declare a region as reserved, you should not
> >> declare it as memory first
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: correct way to reserve memory from PrePi?
2016-12-15 4:55 ` Gao, Liming
@ 2016-12-15 5:02 ` Michael Zimmermann
2016-12-15 5:12 ` Gao, Liming
0 siblings, 1 reply; 8+ messages in thread
From: Michael Zimmermann @ 2016-12-15 5:02 UTC (permalink / raw)
To: Gao, Liming; +Cc: Ard Biesheuvel, edk2-devel@lists.01.org, Star Zeng, Feng Tian
I do not want to allocate the full memory range, just small parts of
it. I have one or two ranges(depending on how the system config
reports it) for all ram. e.g a 2gb device usually uses either
0x0000000-0x80000000 or 0x00000000-0x40000000 and
0x40000000-0x40000000.
So I digged even further and it looks like upon boot, the highest
available memory resource descriptor is selected and allocated for the
DxeCore.
So if I have one memory resource only, the whole DRAM will be
allocated by/for DxeCore. Is that really the intended behavior?
Because this way I'm unable to reserve any RAM from the highest
resource descriptor. The reason why it works when I have split the
DRAM in two descriptors is that DxeCore will only allocate the upper
half and I'm usually trying to reserve a few low memory ranges - which
isn't always the case.
Thanks
Michael
On Thu, Dec 15, 2016 at 5:55 AM, Gao, Liming <liming.gao@intel.com> wrote:
> Michael:
> I understand your usage that BuildResourceDescriptorHob adds system memory range, BuildMemoryAllocationHob allocate the full memory range as reserved memory. Then, you expect they can be shown in EFI memory map. Right?
>
> BuildResourceDescriptorHob() with (start,size) 0x80000000,0x80000000, then BuildMemoryAllocationHob() with (start,size) 0x80000000,0x80000000. It doesn't work.
> Two BuildResourceDescriptorHob() with (start,size) 0x80000000,0x40000000 and 0xc0000000,0x40000000, then two BuildMemoryAllocationHob(). It does work. Right?
>
> Thanks
> Liming
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> Michael Zimmermann
>> Sent: Thursday, December 15, 2016 1:57 AM
>> To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> Cc: edk2-devel@lists.01.org <edk2-devel@ml01.01.org>
>> Subject: Re: [edk2] correct way to reserve memory from PrePi?
>>
>> I've enabled GCD debugging and apparently it doesn't accept the allocation:
>> GCD:AllocateMemorySpace(Base=0000000090000000,Length=0000000010000
>> 000)
>> GcdAllocateType = AtAddress
>> GcdMemoryType = SystemMem
>> Alignment = 0000000000000001
>> ImageHandle = FDE28F90
>> DeviceHandle = 0
>> CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
>> CoreAllocateSpace:1130
>> Status = Not Found
>> GCDMemType Range Capabilities
>> Attributes
>> ========== =================================
>> ================
>> ================
>> NonExist 0000000000000000-000000007FFFFFFF 0000000000000000
>> 0000000000000000
>> SystemMem 0000000080000000-00000000FDFFFFFF 800000000000000E
>> 0000000000000000*
>> NonExist 00000000FE000000-00000000FE3FFFFF 0000000000000000
>> 0000000000000000
>> SystemMem 00000000FE400000-00000000FFFE5FFF 800000000000000E
>> 0000000000000000
>> SystemMem 00000000FFFE6000-00000000FFFEEFFF 800000000000000E
>> 0000000000000000*
>> SystemMem 00000000FFFEF000-00000000FFFFFFFF 800000000000000E
>> 0000000000000000
>>
>>
>> It fails in this line:
>> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe
>> /Gcd/Gcd.c#L982
>> In this example I've used(start,size) 0x80000000,0x80000000 for the
>> resource descriptors.
>> If I use 0x80000000,0x40000000 and 0xc0000000,0x40000000 everything
>> works just fine.
>>
>> Thanks
>> Michael
>>
>> On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
>> <sigmaepsilon92@gmail.com> wrote:
>> > As far as I know the proper way is to create resource descriptors
>> > using BuildResourceDescriptorHob and then allocate reserved areas
>> > using BuildMemoryAllocationHob. This way I don't have any overlapping
>> > descriptors - I just allocated some memory very early.
>> >
>> > I ran many tests and it looks like all calls to
>> > BuildMemoryAllocationHob get ignored if my dram hobs look like this:
>> > 0x00000000 - 0x40000000
>> >
>> > If I split this range into two Hob's like this everything seems to
>> > work just fine:
>> > 0x00000000 - 0x20000000
>> > 0x20000000 - 0x20000000
>> >
>> > I took a look at other platforms like Juno and they add big dram Hob's
>> > (2GB and 6GB) too so why is this a problem?
>> >
>> > Thanks
>> > Michael
>> >
>> > On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
>> > <ard.biesheuvel@linaro.org> wrote:
>> >> On 14 December 2016 at 10:02, Michael Zimmermann
>> >> <sigmaepsilon92@gmail.com> wrote:
>> >>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob
>> >>> but apparently they don't have any effect.
>> >>> When I look at the output of the shell's memmap command there aren't
>> >>> any reserved/unavailable pages.
>> >>>
>> >>> Furthermore, when using AllocatePages with one of the physical
>> >>> addresses which I've reserved it succeeds which means that it's not
>> >>> just a problem of how the memmap command works.
>> >>>
>> >>> Am I doing something wrong or is this a bug?
>> >>>
>> >>
>> >> I think you need to ensure that they don't overlap existing resource
>> >> descriptors: if you declare a region as reserved, you should not
>> >> declare it as memory first
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: correct way to reserve memory from PrePi?
2016-12-15 5:02 ` Michael Zimmermann
@ 2016-12-15 5:12 ` Gao, Liming
2016-12-15 5:27 ` Michael Zimmermann
0 siblings, 1 reply; 8+ messages in thread
From: Gao, Liming @ 2016-12-15 5:12 UTC (permalink / raw)
To: Michael Zimmermann
Cc: Ard Biesheuvel, edk2-devel@lists.01.org, Zeng, Star, Tian, Feng
Michael:
I agree this is an issue that DxeCore doesn't consider the allocated memory range when it allocates the first memory range. Could you submit it in bugzilla with the detail usage model? Then, we can continue to investgate how to resolve it.
Thanks
Liming
> -----Original Message-----
> From: Michael Zimmermann [mailto:sigmaepsilon92@gmail.com]
> Sent: Thursday, December 15, 2016 1:02 PM
> To: Gao, Liming <liming.gao@intel.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org
> <edk2-devel@ml01.01.org>; Zeng, Star <star.zeng@intel.com>; Tian, Feng
> <feng.tian@intel.com>
> Subject: Re: [edk2] correct way to reserve memory from PrePi?
>
> I do not want to allocate the full memory range, just small parts of
> it. I have one or two ranges(depending on how the system config
> reports it) for all ram. e.g a 2gb device usually uses either
> 0x0000000-0x80000000 or 0x00000000-0x40000000 and
> 0x40000000-0x40000000.
>
> So I digged even further and it looks like upon boot, the highest
> available memory resource descriptor is selected and allocated for the
> DxeCore.
> So if I have one memory resource only, the whole DRAM will be
> allocated by/for DxeCore. Is that really the intended behavior?
> Because this way I'm unable to reserve any RAM from the highest
> resource descriptor. The reason why it works when I have split the
> DRAM in two descriptors is that DxeCore will only allocate the upper
> half and I'm usually trying to reserve a few low memory ranges - which
> isn't always the case.
>
> Thanks
> Michael
>
> On Thu, Dec 15, 2016 at 5:55 AM, Gao, Liming <liming.gao@intel.com> wrote:
> > Michael:
> > I understand your usage that BuildResourceDescriptorHob adds system
> memory range, BuildMemoryAllocationHob allocate the full memory range as
> reserved memory. Then, you expect they can be shown in EFI memory map.
> Right?
> >
> > BuildResourceDescriptorHob() with (start,size) 0x80000000,0x80000000,
> then BuildMemoryAllocationHob() with (start,size) 0x80000000,0x80000000.
> It doesn't work.
> > Two BuildResourceDescriptorHob() with (start,size)
> 0x80000000,0x40000000 and 0xc0000000,0x40000000, then two
> BuildMemoryAllocationHob(). It does work. Right?
> >
> > Thanks
> > Liming
> >> -----Original Message-----
> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> >> Michael Zimmermann
> >> Sent: Thursday, December 15, 2016 1:57 AM
> >> To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> >> Cc: edk2-devel@lists.01.org <edk2-devel@ml01.01.org>
> >> Subject: Re: [edk2] correct way to reserve memory from PrePi?
> >>
> >> I've enabled GCD debugging and apparently it doesn't accept the
> allocation:
> >>
> GCD:AllocateMemorySpace(Base=0000000090000000,Length=0000000010000
> >> 000)
> >> GcdAllocateType = AtAddress
> >> GcdMemoryType = SystemMem
> >> Alignment = 0000000000000001
> >> ImageHandle = FDE28F90
> >> DeviceHandle = 0
> >> CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
> >> CoreAllocateSpace:1130
> >> Status = Not Found
> >> GCDMemType Range Capabilities
> >> Attributes
> >> ========== =================================
> >> ================
> >> ================
> >> NonExist 0000000000000000-000000007FFFFFFF 0000000000000000
> >> 0000000000000000
> >> SystemMem 0000000080000000-00000000FDFFFFFF 800000000000000E
> >> 0000000000000000*
> >> NonExist 00000000FE000000-00000000FE3FFFFF 0000000000000000
> >> 0000000000000000
> >> SystemMem 00000000FE400000-00000000FFFE5FFF 800000000000000E
> >> 0000000000000000
> >> SystemMem 00000000FFFE6000-00000000FFFEEFFF 800000000000000E
> >> 0000000000000000*
> >> SystemMem 00000000FFFEF000-00000000FFFFFFFF 800000000000000E
> >> 0000000000000000
> >>
> >>
> >> It fails in this line:
> >>
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe
> >> /Gcd/Gcd.c#L982
> >> In this example I've used(start,size) 0x80000000,0x80000000 for the
> >> resource descriptors.
> >> If I use 0x80000000,0x40000000 and 0xc0000000,0x40000000 everything
> >> works just fine.
> >>
> >> Thanks
> >> Michael
> >>
> >> On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
> >> <sigmaepsilon92@gmail.com> wrote:
> >> > As far as I know the proper way is to create resource descriptors
> >> > using BuildResourceDescriptorHob and then allocate reserved areas
> >> > using BuildMemoryAllocationHob. This way I don't have any overlapping
> >> > descriptors - I just allocated some memory very early.
> >> >
> >> > I ran many tests and it looks like all calls to
> >> > BuildMemoryAllocationHob get ignored if my dram hobs look like this:
> >> > 0x00000000 - 0x40000000
> >> >
> >> > If I split this range into two Hob's like this everything seems to
> >> > work just fine:
> >> > 0x00000000 - 0x20000000
> >> > 0x20000000 - 0x20000000
> >> >
> >> > I took a look at other platforms like Juno and they add big dram Hob's
> >> > (2GB and 6GB) too so why is this a problem?
> >> >
> >> > Thanks
> >> > Michael
> >> >
> >> > On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
> >> > <ard.biesheuvel@linaro.org> wrote:
> >> >> On 14 December 2016 at 10:02, Michael Zimmermann
> >> >> <sigmaepsilon92@gmail.com> wrote:
> >> >>> I tried both BuildResourceDescriptorHob and
> BuildMemoryAllocationHob
> >> >>> but apparently they don't have any effect.
> >> >>> When I look at the output of the shell's memmap command there
> aren't
> >> >>> any reserved/unavailable pages.
> >> >>>
> >> >>> Furthermore, when using AllocatePages with one of the physical
> >> >>> addresses which I've reserved it succeeds which means that it's not
> >> >>> just a problem of how the memmap command works.
> >> >>>
> >> >>> Am I doing something wrong or is this a bug?
> >> >>>
> >> >>
> >> >> I think you need to ensure that they don't overlap existing resource
> >> >> descriptors: if you declare a region as reserved, you should not
> >> >> declare it as memory first
> >> _______________________________________________
> >> edk2-devel mailing list
> >> edk2-devel@lists.01.org
> >> https://lists.01.org/mailman/listinfo/edk2-devel
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: correct way to reserve memory from PrePi?
2016-12-15 5:12 ` Gao, Liming
@ 2016-12-15 5:27 ` Michael Zimmermann
0 siblings, 0 replies; 8+ messages in thread
From: Michael Zimmermann @ 2016-12-15 5:27 UTC (permalink / raw)
To: Gao, Liming
Cc: Ard Biesheuvel, edk2-devel@lists.01.org, Zeng, Star, Tian, Feng
I've submitted the issue to bugzilla:
https://bugzilla.tianocore.org/show_bug.cgi?id=295
Thanks
Michael
On Thu, Dec 15, 2016 at 6:12 AM, Gao, Liming <liming.gao@intel.com> wrote:
> Michael:
> I agree this is an issue that DxeCore doesn't consider the allocated memory range when it allocates the first memory range. Could you submit it in bugzilla with the detail usage model? Then, we can continue to investgate how to resolve it.
>
> Thanks
> Liming
>> -----Original Message-----
>> From: Michael Zimmermann [mailto:sigmaepsilon92@gmail.com]
>> Sent: Thursday, December 15, 2016 1:02 PM
>> To: Gao, Liming <liming.gao@intel.com>
>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org
>> <edk2-devel@ml01.01.org>; Zeng, Star <star.zeng@intel.com>; Tian, Feng
>> <feng.tian@intel.com>
>> Subject: Re: [edk2] correct way to reserve memory from PrePi?
>>
>> I do not want to allocate the full memory range, just small parts of
>> it. I have one or two ranges(depending on how the system config
>> reports it) for all ram. e.g a 2gb device usually uses either
>> 0x0000000-0x80000000 or 0x00000000-0x40000000 and
>> 0x40000000-0x40000000.
>>
>> So I digged even further and it looks like upon boot, the highest
>> available memory resource descriptor is selected and allocated for the
>> DxeCore.
>> So if I have one memory resource only, the whole DRAM will be
>> allocated by/for DxeCore. Is that really the intended behavior?
>> Because this way I'm unable to reserve any RAM from the highest
>> resource descriptor. The reason why it works when I have split the
>> DRAM in two descriptors is that DxeCore will only allocate the upper
>> half and I'm usually trying to reserve a few low memory ranges - which
>> isn't always the case.
>>
>> Thanks
>> Michael
>>
>> On Thu, Dec 15, 2016 at 5:55 AM, Gao, Liming <liming.gao@intel.com> wrote:
>> > Michael:
>> > I understand your usage that BuildResourceDescriptorHob adds system
>> memory range, BuildMemoryAllocationHob allocate the full memory range as
>> reserved memory. Then, you expect they can be shown in EFI memory map.
>> Right?
>> >
>> > BuildResourceDescriptorHob() with (start,size) 0x80000000,0x80000000,
>> then BuildMemoryAllocationHob() with (start,size) 0x80000000,0x80000000.
>> It doesn't work.
>> > Two BuildResourceDescriptorHob() with (start,size)
>> 0x80000000,0x40000000 and 0xc0000000,0x40000000, then two
>> BuildMemoryAllocationHob(). It does work. Right?
>> >
>> > Thanks
>> > Liming
>> >> -----Original Message-----
>> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> >> Michael Zimmermann
>> >> Sent: Thursday, December 15, 2016 1:57 AM
>> >> To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> >> Cc: edk2-devel@lists.01.org <edk2-devel@ml01.01.org>
>> >> Subject: Re: [edk2] correct way to reserve memory from PrePi?
>> >>
>> >> I've enabled GCD debugging and apparently it doesn't accept the
>> allocation:
>> >>
>> GCD:AllocateMemorySpace(Base=0000000090000000,Length=0000000010000
>> >> 000)
>> >> GcdAllocateType = AtAddress
>> >> GcdMemoryType = SystemMem
>> >> Alignment = 0000000000000001
>> >> ImageHandle = FDE28F90
>> >> DeviceHandle = 0
>> >> CoreAllocateSpaceCheckEntry:982 handle=FDE28F90
>> >> CoreAllocateSpace:1130
>> >> Status = Not Found
>> >> GCDMemType Range Capabilities
>> >> Attributes
>> >> ========== =================================
>> >> ================
>> >> ================
>> >> NonExist 0000000000000000-000000007FFFFFFF 0000000000000000
>> >> 0000000000000000
>> >> SystemMem 0000000080000000-00000000FDFFFFFF 800000000000000E
>> >> 0000000000000000*
>> >> NonExist 00000000FE000000-00000000FE3FFFFF 0000000000000000
>> >> 0000000000000000
>> >> SystemMem 00000000FE400000-00000000FFFE5FFF 800000000000000E
>> >> 0000000000000000
>> >> SystemMem 00000000FFFE6000-00000000FFFEEFFF 800000000000000E
>> >> 0000000000000000*
>> >> SystemMem 00000000FFFEF000-00000000FFFFFFFF 800000000000000E
>> >> 0000000000000000
>> >>
>> >>
>> >> It fails in this line:
>> >>
>> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe
>> >> /Gcd/Gcd.c#L982
>> >> In this example I've used(start,size) 0x80000000,0x80000000 for the
>> >> resource descriptors.
>> >> If I use 0x80000000,0x40000000 and 0xc0000000,0x40000000 everything
>> >> works just fine.
>> >>
>> >> Thanks
>> >> Michael
>> >>
>> >> On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann
>> >> <sigmaepsilon92@gmail.com> wrote:
>> >> > As far as I know the proper way is to create resource descriptors
>> >> > using BuildResourceDescriptorHob and then allocate reserved areas
>> >> > using BuildMemoryAllocationHob. This way I don't have any overlapping
>> >> > descriptors - I just allocated some memory very early.
>> >> >
>> >> > I ran many tests and it looks like all calls to
>> >> > BuildMemoryAllocationHob get ignored if my dram hobs look like this:
>> >> > 0x00000000 - 0x40000000
>> >> >
>> >> > If I split this range into two Hob's like this everything seems to
>> >> > work just fine:
>> >> > 0x00000000 - 0x20000000
>> >> > 0x20000000 - 0x20000000
>> >> >
>> >> > I took a look at other platforms like Juno and they add big dram Hob's
>> >> > (2GB and 6GB) too so why is this a problem?
>> >> >
>> >> > Thanks
>> >> > Michael
>> >> >
>> >> > On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel
>> >> > <ard.biesheuvel@linaro.org> wrote:
>> >> >> On 14 December 2016 at 10:02, Michael Zimmermann
>> >> >> <sigmaepsilon92@gmail.com> wrote:
>> >> >>> I tried both BuildResourceDescriptorHob and
>> BuildMemoryAllocationHob
>> >> >>> but apparently they don't have any effect.
>> >> >>> When I look at the output of the shell's memmap command there
>> aren't
>> >> >>> any reserved/unavailable pages.
>> >> >>>
>> >> >>> Furthermore, when using AllocatePages with one of the physical
>> >> >>> addresses which I've reserved it succeeds which means that it's not
>> >> >>> just a problem of how the memmap command works.
>> >> >>>
>> >> >>> Am I doing something wrong or is this a bug?
>> >> >>>
>> >> >>
>> >> >> I think you need to ensure that they don't overlap existing resource
>> >> >> descriptors: if you declare a region as reserved, you should not
>> >> >> declare it as memory first
>> >> _______________________________________________
>> >> edk2-devel mailing list
>> >> edk2-devel@lists.01.org
>> >> https://lists.01.org/mailman/listinfo/edk2-devel
>> > _______________________________________________
>> > edk2-devel mailing list
>> > edk2-devel@lists.01.org
>> > https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-12-15 5:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-14 10:02 correct way to reserve memory from PrePi? Michael Zimmermann
2016-12-14 10:21 ` Ard Biesheuvel
2016-12-14 15:13 ` Michael Zimmermann
2016-12-14 17:57 ` Michael Zimmermann
2016-12-15 4:55 ` Gao, Liming
2016-12-15 5:02 ` Michael Zimmermann
2016-12-15 5:12 ` Gao, Liming
2016-12-15 5:27 ` Michael Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox