The Place to Start for Operating System Developers
It is currently Tue Sep 29, 2020 10:01 pm

All times are UTC - 6 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Picking a kernel heap and user space heap
PostPosted: Tue Aug 07, 2018 12:42 am 

Joined: Wed Aug 01, 2018 9:09 pm
Posts: 10
I am writing an x86_64 kernel with grub2 as the bootloader. I have paging set up and a simple frame allocator which takes a virtual address and maps it to an available physical frame. I have identity mapped the kernel, the multiboot2 header, VGA address, etc. My question is, how do you choose a place for the kernel heap? e.g. I want a virtual address that starts the heap, such that I can allocate enough frames for the kernel's memory needs.

Currently, I've arbitrarily chosen 0xffff800000000000ull as the kernel heap start (growing down in increasing order) because it is guaranteed not to conflict with any of the identity mapped segments described above. However, the kernel heap needs to be preserved and mapped in the page table for child processes, so now I need to find a suitable virtual address for the children.

What is a sensible way to set up virtual addressing for a heap for both the kernel as well as user space threads/processes?

Another option I was thinking of was using 0xffff8* for all user code (stack, heap, etc) and 0x0000* for all kernel code. And then using 0x00007fffffffffff as the bottom of the kernel heap (growing upward i.e. to decreasing addresses).

Also, what is the best way of setting up page tables for child processes? I need to maintain the identity map of the kernel code, the VGA drivers, etc as well as the kernel heap. What is the easiest way of just cloning these parts of the page tables?

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours

Who is online

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