1

I have successfully entered 32 bit protected mode and wish to go to 64 bit long mode now. I understand the code to do this but do not understand how the 64 bit tables work compared to the 32 bit GDT. I wondered if there was a tutorial on this or an easy way to explain it or do I just have to read the AMD manual (not easy to follow). I know the structure is

PML4T[0] -> PDPT.
PDPT[0] -> PDT.
PDT[0] -> PT.
PT 

But I'm not sure how to use it. I presume the GDT from the 32 bit mode is not used in 64 bit long mode?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Bipman
  • 53
  • 8
  • 2
    Well that makes no sense. The GDT and paging both exist in 32bit and 64bit modes, and have nothing to do with each other. You do need both. – harold Mar 14 '17 at 17:12
  • I mean that once you change to 64 bit mode and don't want to go back, the 32 bit GDT is no longer used. – Bipman Mar 14 '17 at 17:36
  • 1
    OK, I see now that the GDT is used in long mode but only for the 64 bit settings. Say I wanted to set up 2MB paging with code starting from 4MB-10MB and data from 10MB to end of memory. How on earth do I set the PDT tables and the control registers? It seems a little confusing in the AMD manual ....... – Bipman Mar 14 '17 at 20:08
  • See https://wiki.osdev.org/Setting_Up_Long_Mode#Setting_up_the_Paging and related other links on the osdev wiki like https://wiki.osdev.org/X86-64#How_do_I_enable_Long_Mode_.3F. The x86-64 page-table format is different, based on the PAE page-table format but 4 levels deep. See [Why in 64bit the virtual address are 4 bits short (48bit long) compared with the physical address (52 bit long)?](https://stackoverflow.com/q/46509152) for diagrams of the entry formats. – Peter Cordes Dec 24 '18 at 22:19

0 Answers0