Actually it looks like the the CpuDxe driver is coded to only run if it it is loaded under 4 GB? Is that following the spec? Is that intentional?
I noticed that SetCodeSelector is coded to use a far jump and that is a 32-bit absolute value? Note [rsp+4] https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm#L28 ASM_PFX(SetCodeSelector): sub rsp, 0x10 lea rax, [setCodeSelectorLongJump] mov [rsp], rax mov [rsp+4], cx jmp dword far [rsp] setCodeSelectorLongJump: add rsp, 0x10 ret Thanks, Andrew Fish > On Mar 7, 2019, at 2:37 PM, Andrew Fish <af...@apple.com> wrote: > > I'm trying to understand why gdtPtr.Base is casting to (UINT32)? > 1) gdtPtr.Base is a a UINTN > 2) It is legal for AllocateRuntimePool() to return an address > 4GB > > It seems like the code should just cast to (UINTN)? > > > https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/CpuDxe/CpuGdt.c#L151 > <https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/CpuDxe/CpuGdt.c#L151> > > > > VOID > InitGlobalDescriptorTable ( > VOID > ) > { > GDT_ENTRIES *gdt; > IA32_DESCRIPTOR gdtPtr; > > // > // Allocate Runtime Data for the GDT > // > gdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8); > ASSERT (gdt != NULL); > gdt = ALIGN_POINTER (gdt, 8); > > // > // Initialize all GDT entries > // > CopyMem (gdt, &GdtTemplate, sizeof (GdtTemplate)); > > // > // Write GDT register > // > gdtPtr.Base = (UINT32)(UINTN)(VOID*) gdt; > gdtPtr.Limit = (UINT16) (sizeof (GdtTemplate) - 1); > AsmWriteGdtr (&gdtPtr); > > Thanks, > > Andrew Fish _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel