How do I avoid virtual addressing in long mode (x86-64)?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
TanookiSuit
Posts: 1
Joined: Thu Jul 16, 2020 11:07 am
Libera.chat IRC: TanookiSuit

How do I avoid virtual addressing in long mode (x86-64)?

Post by TanookiSuit »

Hello,

I've spent some time reading about how paging is required in long mode but I don't like the indirection of having both physical and virtual addresses. Is there a way around this that doesn't involve going with 32-bit flat mode?

I would be fine with only being able to map 1 GB.

Thanks.
Octocontrabass
Member
Member
Posts: 5885
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do I avoid virtual addressing in long mode (x86-64)?

Post by Octocontrabass »

Why don't you like virtual addressing? Unless you have a very good reason to avoid it, you should use it.

If you do happen to come up with one such good reason, you can set up the page tables so that virtual addresses are equal to physical addresses and then never worry about it again. If you decide to use 2M or 1G pages, avoid using them to map address ranges that span a boundary between RAM and not-RAM. In most cases, it won't work correctly, and probably crash as a result.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: How do I avoid virtual addressing in long mode (x86-64)?

Post by nexos »

Paging and virtual addressing are required for Long Mode. If you don't want to use them, stay in 32 bit mode.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
bellezzasolo
Member
Member
Posts: 120
Joined: Sun Feb 20, 2011 2:01 pm

Re: How do I avoid virtual addressing in long mode (x86-64)?

Post by bellezzasolo »

You could identity map all memory, but virtual memory rocks.

My kernel is based at 0xFFFFC00000000000, with the standard library dynamically linked at 0xFFFFC00080000000

Using UEFI, so the loader isn't higher half, but is an ideal place to put a dynamic linker!

https://github.com/ChaiSoft/ChaiOS/blob ... ientry.cpp
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
User avatar
iansjack
Member
Member
Posts: 4834
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do I avoid virtual addressing in long mode (x86-64)?

Post by iansjack »

Even if you identity map all memory, you are still using virtual addresses. It's just unavoidable in long mode. And the advantages are so compelling that you seriously need to consider whether your design is fatally flawed.
Post Reply