OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 10:59 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Bochs showing only 32-bit linear addresses for PML4
PostPosted: Sun May 27, 2018 5:01 pm 
Offline
Member
Member

Joined: Wed May 02, 2018 1:26 pm
Posts: 55
I'm currently trying to jump into the 64-bit kernel using a separate loader.
Though I think I set everything up correctly, the page table inspection in bochs tells me, that I am mapping 32-bit linear addresses to 64-bit physical addresses (I assume so, since the output shows 16 hexadecimal chars for the physical addresses).

However, my kernel is linked at 0xffffffff80200000 (In the linker file from the kernel):
Code:
ENTRY(_entry)

KERNEL_BASE_ADDR = 0xffffffff80200000;

SECTIONS
{
   . = KERNEL_BASE_ADDR;
...

And the elf64 header I parse from the article using a separate loader also says that
Code:
elf64_phdr->p_vaddr

matches the address in the linker file. Everything seems to work, except either the mapping I do for the kernel results in some troubles or bochs seems to show wrong entries in the page table: https://imageshack.com/a/img921/8867/Dlwe8L.png
The result of the far jump to the kernel results in an grayish screen, which seems to be the effect of an interrupt. As this interrupt is most likely resulting from a page fault, the paging mechanism seems to have a bug.

With your help I want to check if my build up is correct the way I did it so far:

Boot -> Grub:
    - The entry in the grub bootloader starts the separate loader of mine, which is very similar to the one in the tutorial.
    - I'm setting up the GDT (32-bit), IDT(64-bit) and the Paging (with PML4, 4-level paging). -> Setup in this exact order (GDT, IDT, Paging).
    - I'm parsing the elf64 header from the multiboot struct, just as in the tutorial, and retrieve the kernel entry point address, which is 0xffffffff80200000.
    - I enable paging.
    - I setup the GDT for 64-bit and far jump into the kernel entry point (0xffffffff80200000).

After that, the screen becomes grey and the system comes to a halt.
If this build up is correct, then the mistake might be on my side, most likely in the paging mechanism. However, the bochs page table output irritates me a little, since it only shows 32-bit linear addresses, even though I am mapping 64-bit linear addresses (48-bit, since the last 16 bits are a copy of bit 47).

I hope you can give me a hint or tell me if my build up is wrong.


Top
 Profile  
 
 Post subject: Re: Bochs showing only 32-bit linear addresses for PML4
PostPosted: Sun May 27, 2018 8:54 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 692
There is a user patch a few years ago for BOCHS for the full 64-bit addresses. I tried it previously and it did work although I'm not sure if it works for current releases. https://sourceforge.net/p/bochs/patches/497/#d315


Top
 Profile  
 
 Post subject: Re: Bochs showing only 32-bit linear addresses for PML4
PostPosted: Mon May 28, 2018 3:14 am 
Offline
Member
Member

Joined: Wed May 02, 2018 1:26 pm
Posts: 55
I am using Bochs 2.6.9 and I was building it myself. According to the forum, 2.6.9 should be a fine version number, as the patch was applied there (as far as I understand).

EDIT: Seems like i was wrong, I just checked the source code of my compiled bochs and the patches aren't applied to it. I'm going to check if the patches work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 91 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group