OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 12:02 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Virtual address allocator in 64bit kernel
PostPosted: Thu Apr 20, 2023 9:12 pm 
Offline

Joined: Tue Jul 19, 2022 8:09 am
Posts: 1
Is it necessary to implement a virtual address (or virtual space) allocator in a 64bit kernel?

When in the 32bit kennel, there are usually not enough virtual space to identically (offset) mapping the whole physical address space. And when kernel wants to access the physical memory where is not identically mapped to the kernel's virtual address space, it requests the kernel to find a free virtual address space to temporarily map that physical space.
In this way, there should be a virtual address allocator in the kernel for allocating the free virtual address spaces and recycle them when they are not used any more.

While in the 64bit kernel, there are enough virtual space in the kernel for creating a whole permanent identical (offset) mapping to the physical space.
And now the kernel wants to access the physical memory, it can just request the physical frame allocator for the physical memory and caculate its virtual address in its virtual address space.

So I think there should be no need to write a virtual address allocator in the 64bit kernel. Is there something I get wrong or missed?


Top
 Profile  
 
 Post subject: Re: Virtual address allocator in 64bit kernel
PostPosted: Sun May 07, 2023 12:55 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
You may still want a logical mapping of some memory to some other addresses. Personally, while I have a linear mapping at 0xfff8'0000'0000'0000, it only extends up to 0xfffb'ffff'fffff'ffff, and the rest of virtual space still needs management. My kernel runs at the -2GB line, so that part is taken care of. Also, I want to have a contiguous kernel heap independent of memory fragmentation in physical RAM. I mean, I don't anticipate needing any large objects, but you never know. And maybe in future some other need will arise.

Managing memory directly on top of physical RAM runs into the issue that you are tied directly to its fragmentation. At work, I once had a problem with that. On a system with very little RAM and no virtual memory, the only memory blocks left free were 2MB in one place and 3MB in another. So naturally, a request for 4MB failed. Although enough RAM would have been free to fulfill the request, it was not contiguous, and the system had no way to make it appear contiguous.

_________________
Carpe diem!


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], Google [Bot], SemrushBot [Bot] and 77 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