> On May 9, 2015, at 10:30 PM, Jordan Justen <jordan.l.jus...@intel.com> wrote:
> 
> On 2015-05-09 13:15:42, Ard Biesheuvel wrote:
>> According to the UEFIv2.5 spec section 6.2, the allocations returned
>> by the AllocatePool () boot service must be 8 byte aligned.
>> 
>> So make our implementation conform to the spec, by rearranging the
>> pool head struct so that its size is always a multiple of 8 bytes.
>> 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org 
>> <mailto:ard.biesheu...@linaro.org>>
>> ---
>> MdeModulePkg/Core/Dxe/Mem/Pool.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c 
>> b/MdeModulePkg/Core/Dxe/Mem/Pool.c
>> index ac717fb65f7a..6f8f5cfb295d 100644
>> --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c
>> +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c
>> @@ -26,9 +26,9 @@ typedef struct {
>> #define POOL_HEAD_SIGNATURE   SIGNATURE_32('p','h','d','0')
>> typedef struct {
>>   UINT32          Signature;
>> -  UINT32          Reserved;
>>   EFI_MEMORY_TYPE Type;
>>   UINTN           Size;
>> +  UINTN           Reserved;
>>   CHAR8           Data[1];
>> } POOL_HEAD;
> 
> So the issue is if sizeof(EFI_MEMORY_TYPE) == 4 on a 64-bit machine and the
> compiler doesn't 64-bit align the 64-bit Size field?
> 

For the EFI ABI things are naturally aligned. So a 64-bit field is 64-bit 
aligned by the compiler. This is not the default behavior for all compilers. 

Thanks,

Andrew Fish

> With your change, couldn't there be an issue if the compiler made
> EFI_MEMORY_TYPE 64-bits, and once again chose not to 64-bit align Size
> and Reserved?
> 
> Maybe this alignment should be handled in CoreAllocatePoolI? (Could we
> try to drop both Reserved and Data from that structure?)
> 

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to