[RESOLVED] 2meg pages working fine, but not 1gig pages?
Posted: Thu Jan 13, 2011 7:53 am
Hey guys, my plan is as follows...
To keep kernel purely 64bit, I switch to long mode in my stage 1.5.
Presently, i've been using 2meg pages. The first 2meg is identity mapped,
and the second physical page is mapped to the top 2gig of my virtual address space ( kernel runs here ).
This is all up and working fine.
To keep things simple in the early stages of my kernel startup, I would like to be able to access all of my physical memory at a constant virtual offset.
I have been trying to map a single 1 gig page at the top of my virtual address space ( for kernel )
and map a few 1 gig pages starting from virtual 0xffff800000000000 to physical 0x0000.
the idea here is that i will be able to access physical address X at virtual address (X + 0xffff800000000000)
The problem i am having, is that bochs crashes when i try to enable paging. complaining that only 32bit physical address is emulated, it gives a bogus physical address, and mentions the PDP ( PDP shouldn't be used in 1gig tables )
for now, I have disabled the kernel mapping, and im trying to get a single 1 gig page identity mapped to the first gigabyte of memory.
PML4E @ physical address 0x10000.
1st entry present, writeable, user, pt_write_through flags set.
points to physical address 0x11000 ( my PDPE )
PDPE @ physical address 0x11000
1st entry present, writeable, user, pt_write_through, global, TERMINAL flags set.
points to physical address 0x0000 ( identity mapped )
now time to enter long mode...
1) set PAE and PGE in cr4
2) load page PML4E (0x10000) to cr3
3) set bit 0x100 in mrs 0x80 to enable long mode
4) set bits 0x80000001 in cr0 to enable paging ant protection.
5) load GDT
6) long jump to long mode.
this crashes at stage 4) with bochs error, only 32bit physical addresses are emulated.
I have checked cpuid, and bochs supports 1gig pages.
EFER register is at value 0x500 ( LMA and LME bits set )
What else am i missing ?
AMD64 manual volume 2 says that a terminal bit in PDPE, with LMA and LME is enough to select 1 gig pages.
I am very confused :S
I must be missing something ? or doing something really stupid ?
Like i mentioned earlier, if i add a PDE, with a terminal flag, and clear PDPE terminal flag,
then my kernel boots, and runs fine with 2meg pages.
Very greatful for any prods in the right direction.
THANKS
Chris.
To keep kernel purely 64bit, I switch to long mode in my stage 1.5.
Presently, i've been using 2meg pages. The first 2meg is identity mapped,
and the second physical page is mapped to the top 2gig of my virtual address space ( kernel runs here ).
This is all up and working fine.
To keep things simple in the early stages of my kernel startup, I would like to be able to access all of my physical memory at a constant virtual offset.
I have been trying to map a single 1 gig page at the top of my virtual address space ( for kernel )
and map a few 1 gig pages starting from virtual 0xffff800000000000 to physical 0x0000.
the idea here is that i will be able to access physical address X at virtual address (X + 0xffff800000000000)
The problem i am having, is that bochs crashes when i try to enable paging. complaining that only 32bit physical address is emulated, it gives a bogus physical address, and mentions the PDP ( PDP shouldn't be used in 1gig tables )
for now, I have disabled the kernel mapping, and im trying to get a single 1 gig page identity mapped to the first gigabyte of memory.
PML4E @ physical address 0x10000.
1st entry present, writeable, user, pt_write_through flags set.
points to physical address 0x11000 ( my PDPE )
PDPE @ physical address 0x11000
1st entry present, writeable, user, pt_write_through, global, TERMINAL flags set.
points to physical address 0x0000 ( identity mapped )
now time to enter long mode...
1) set PAE and PGE in cr4
2) load page PML4E (0x10000) to cr3
3) set bit 0x100 in mrs 0x80 to enable long mode
4) set bits 0x80000001 in cr0 to enable paging ant protection.
5) load GDT
6) long jump to long mode.
this crashes at stage 4) with bochs error, only 32bit physical addresses are emulated.
I have checked cpuid, and bochs supports 1gig pages.
EFER register is at value 0x500 ( LMA and LME bits set )
What else am i missing ?
AMD64 manual volume 2 says that a terminal bit in PDPE, with LMA and LME is enough to select 1 gig pages.
I am very confused :S
I must be missing something ? or doing something really stupid ?
Like i mentioned earlier, if i add a PDE, with a terminal flag, and clear PDPE terminal flag,
then my kernel boots, and runs fine with 2meg pages.
Very greatful for any prods in the right direction.
THANKS
Chris.