[Fw_Os_Forum] Why does UEFI firmware on x64 not initialize "long mode" GDT?

Brett Stahlman brettstahlman at gmail.com
Mon Jun 6 18:54:04 EDT 2016

Thanks. I'll probably do that, but I'd just like to be sure that my
expectations are based on a correct understanding of the UEFI spec
(and Intel docs). As I read the section on x64 handoff, a GDT
descriptor value of 0x000000000000ffff makes no sense in a loader
that's running in 64-bit long mode. For one thing, the P (Present)
flag is clear for all segments. For another, the L (Long mode) flag is
clear. I'm thinking it should be set, at least for code segments. As
for code segments, there don't appear to be any, as all Type fields
are 0.

The UEFI spec says something about segments being effectively "unused"
in 64-bit long mode, but even for "flat" mode, they have to be
configured correctly, right? It's just hard for me to believe that 2
popular firmware implementation have gotten it so wrong... Hoping
someone in this forum can tell me whether my understanding of the spec
is flawed...

Brett S.

On Mon, Jun 6, 2016 at 5:30 PM,  <Aaron.Pop at congatec.com> wrote:
> Hi Brett,
> Since this question is in relation to the EDK2's QEMU (OVMF) project, you
> might get a better answer by emailing the EDK2 development list.
> http://www.tianocore.org/docs/member-faq.html
> From:        Brett Stahlman <brettstahlman at gmail.com>
> To:        fw_os_forum at mailman.uefi.org
> Date:        06/06/2016 03:14 PM
> Subject:        [Fw_Os_Forum] Why does UEFI firmware on x64 not initialize
> "long        mode" GDT?
> Sent by:        fw_os_forum-bounces at mailman.uefi.org
> ________________________________
> Just inside my 64-bit x64 EFI boot loader, I print out the contents of
> the GDT to see how it was initialized by the firmware. I've tried
> running the boot loader both in QEMU (OVMF) and VMware ESXi. In both
> cases, the first 5 descriptors after the leading null descriptor look
> like this:
> 0x000000000000ffff
> Note all the leading zeroes: in particular, flags such as D/B and L
> being clear seem to suggest a GDT that's inappropriate for 64-bit long
> mode. I've verified by looking at CR* registers and such that the
> firmware has indeed placed me in IA32e "long mode" with identity
> paging. This is what I would expect, in light of section 2.3.4 in the
> UEFI spec. But why does the GDT have all leading 0's?
> Thanks,
> Brett S.
> _______________________________________________
> Fw_os_forum mailing list
> Fw_os_forum at mailman.uefi.org
> http://lists.mailman.uefi.org/mailman/listinfo/fw_os_forum

More information about the Fw_os_forum mailing list