OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Oct 23, 2019 6:49 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Typical mechanisms to jump to virtual address space
PostPosted: Fri Jun 28, 2019 10:44 am 
Offline

Joined: Sun Apr 30, 2017 10:14 am
Posts: 14
I'm writing an OS for ARM. The OS is compiled to run at a very high virtual address. One of the first things I do, using only PIC while running in physical address space, is setting up some page tables which map the OS image and allocate a few more pages for stack and such. To jump to a high address in virtual space, I also create an identity mapping of the OS image so that when I enable the MMU I don't get an exception and am able to jump to a known virtual address. After this, I remove this identity mapping from the page tables.

So, this works, but I'm wondering if there are any "standard" techniques to do this. What do mainstream OSes such as Linux do? What do you do in your implementations?

Thank you in advance


Top
 Profile  
 
 Post subject: Re: Typical mechanisms to jump to virtual address space
PostPosted: Sat Jun 29, 2019 7:33 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 392
Hi,

josecm wrote:
So, this works, but I'm wondering if there are any "standard" techniques to do this. What do mainstream OSes such as Linux do? What do you do in your implementations?

Thank you in advance
Pretty much that's all. There are not much magic here, you must have an identity mapping and a higher half mapping at the same time before you jump. That's not just standard, but it is a must, otherwise you get a prefetch abort.

Here's a really good doc with source: https://github.com/s-matyukevich/raspberry-pi-os/blob/master/docs/lesson06/rpi-os.md
Linux does not do much either (except for KASLR when it applies dynamic relocations): https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/head.S#L848

Cheers,
bzt


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], thomtl and 13 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