OSDev.org
https://forum.osdev.org/

Long mode paging only works well for the first 2MB
https://forum.osdev.org/viewtopic.php?f=1&t=33497
Page 1 of 1

Author:  PhantomR [ Mon Feb 11, 2019 7:56 pm ]
Post subject:  Long mode paging only works well for the first 2MB

I'm experiencing some very weird issues with long mode paging.. it seems like my first two MB identity mapping works very well. However, if I try mapping the 2MB starting at 0xFF00_0000_0000 (255TiB), accessing that location does not work. Strangely enough, if I map the 2MB region starting at 512GB (index 1 in the PML4T), I can access it, but I run into other weird issues like not getting the right value from a location in the area...

Please, if anyone has some time, could you tell me if you could spot a bug in my code? I'm already in protected mode .. the code sets up the paging tables and jumps into long mode. I'm also posting a link to my 64bit GDT.

Thank you so much.

https://pastebin.com/ghBLv1Db (Page tables + long mode)

https://pastebin.com/WHC4ZSJG (GDT for 64bits)

Author:  MichaelPetch [ Mon Feb 11, 2019 9:52 pm ]
Post subject:  Re: Long mode paging only works well for the first 2MB

Are you on a system where the virtual address space is 48 bits. If so the canonical addresses that are valid are:
0x0000000000000000 and 0x00007FFFFFFFFFFF
0xFFFF800000000000 and 0xFFFFFFFFFFFFFFFF
Anything in between is not a canonical address. Unless I counted things up incorrectly 0x0000FF0000000000 is outside those ranges. Maybe you mapped 0xFFFFFF0000000000 in your page table which is 0x0000FF0000000000 where the value at bit 47 is copied into bits 48 to 63.

Author:  PhantomR [ Tue Feb 12, 2019 7:18 am ]
Post subject:  Re: Long mode paging only works well for the first 2MB

I .. can't believe I forgot about that, our assembly teacher actually mentioned this in one of the courses. Thank you very, very much! That was indeed the problem!!

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/