public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* UefiCpuPkg CpuDxe GDT init question?
@ 2019-03-07 22:37 Andrew Fish
  2019-03-08  5:02 ` Andrew Fish
  2019-03-08  7:59 ` Laszlo Ersek
  0 siblings, 2 replies; 10+ messages in thread
From: Andrew Fish @ 2019-03-07 22:37 UTC (permalink / raw)
  To: edk2-devel

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



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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-03-11 21:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-07 22:37 UefiCpuPkg CpuDxe GDT init question? Andrew Fish
2019-03-08  5:02 ` Andrew Fish
2019-03-08  7:59 ` Laszlo Ersek
2019-03-08 14:13   ` Yao, Jiewen
2019-03-08 15:08     ` Laszlo Ersek
2019-03-09  3:10       ` Andrew Fish
2019-03-11 15:59         ` Andrew Fish
2019-03-11 16:04           ` Yao, Jiewen
2019-03-11 16:30             ` Andrew Fish
2019-03-11 21:04               ` Yao, Jiewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox