Discussion:
[edk2] EFI_MEMORY_DESCRIPTOR 8 byte padding on x86_64
romil shah
2011-09-08 20:41:53 UTC
Permalink
Hi,

Can someone explain me why EFI_MEMORY_DESCRIPTOR structure is reported as 48
bytes and not 40 bytes for x86_64 ?

typedef struct {
UINT32 Type;
EFI_PHYSICAL_ADDRESS PhysicalStart;
EFI_VIRTUAL_ADDRESS VirtualStart;
UINT64 NumberOfPages;
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;

According to the structure definition in the Spec and EDK2, it should be:
UINT32+4*UINT64 = 36 + 4 bytes padding = 40 bytes.

The GetMemoryMap call returns EFI_MEMORY_DESCRIPTOR size as 48 bytes instead
of 40 bytes.

Thanks,
--
Romil
Jordan Justen
2011-09-08 20:53:30 UTC
Permalink
Post by romil shah
Can someone explain me why EFI_MEMORY_DESCRIPTOR structure is reported as 48
bytes and not 40 bytes for x86_64 ?
MdeModulePkg/Core/Dxe/Mem/Page.c =>
CoreGetMemoryMap:

//
// Make sure Size != sizeof(EFI_MEMORY_DESCRIPTOR). This will
// prevent people from having pointer math bugs in their code.
// now you have to use *DescriptorSize to make things work.
//
Size += sizeof(UINT64) - (Size % sizeof (UINT64));

-Jordan
Post by romil shah
typedef struct {
UINT32 Type;
EFI_PHYSICAL_ADDRESS PhysicalStart;
EFI_VIRTUAL_ADDRESS VirtualStart;
UINT64 NumberOfPages;
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;
UINT32+4*UINT64 = 36 + 4 bytes padding = 40 bytes.
The GetMemoryMap call returns EFI_MEMORY_DESCRIPTOR size as 48 bytes instead
of 40 bytes.
Thanks,
--
Romil
------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops?   How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Andrew Fish
2011-09-08 21:04:57 UTC
Permalink
This comes from the original EFI specification.

We wanted to opportunity in the future to add entries to the EFI_MEMORY_DESCRIPTOR so we wanted to force callers to use DescriptorSize and not sizeof (EFI_MEMORY_DESCRIPTOR).

Andrew Fish
Hi,
Can someone explain me why EFI_MEMORY_DESCRIPTOR structure is reported as 48 bytes and not 40 bytes for x86_64 ?
typedef struct {
UINT32 Type;
EFI_PHYSICAL_ADDRESS PhysicalStart;
EFI_VIRTUAL_ADDRESS VirtualStart;
UINT64 NumberOfPages;
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;
According to the structure definition in the Spec and EDK2, it should be: UINT32+4*UINT64 = 36 + 4 bytes padding = 40 bytes.
The GetMemoryMap call returns EFI_MEMORY_DESCRIPTOR size as 48 bytes instead of 40 bytes.
Thanks,
--
Romil
------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops? How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
romil shah
2011-09-08 21:33:04 UTC
Permalink
Got it, thanks.
Post by Andrew Fish
This comes from the original EFI specification.
We wanted to opportunity in the future to add entries to the
EFI_MEMORY_DESCRIPTOR so we wanted to force callers to use DescriptorSize
and not sizeof (EFI_MEMORY_DESCRIPTOR).
Andrew Fish
Post by romil shah
Hi,
Can someone explain me why EFI_MEMORY_DESCRIPTOR structure is reported as
48 bytes and not 40 bytes for x86_64 ?
Post by romil shah
typedef struct {
UINT32 Type;
EFI_PHYSICAL_ADDRESS PhysicalStart;
EFI_VIRTUAL_ADDRESS VirtualStart;
UINT64 NumberOfPages;
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;
UINT32+4*UINT64 = 36 + 4 bytes padding = 40 bytes.
Post by romil shah
The GetMemoryMap call returns EFI_MEMORY_DESCRIPTOR size as 48 bytes
instead of 40 bytes.
Post by romil shah
Thanks,
--
Romil
------------------------------------------------------------------------------
Post by romil shah
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops? How do next-generation virtual
desktops
Post by romil shah
provide companies an easier-to-deploy, easier-to-manage and more
affordable
Post by romil shah
virtual desktop model.
http://www.accelacomm.com/jaw/sfnl/114/51426474/_______________________________________________
Post by romil shah
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops? How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Loading...