Page 1 of 1

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

Posted: Thu Jul 16, 2020 11:29 am
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.

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

Posted: Mon Jul 20, 2020 10:52 pm
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.

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

Posted: Tue Jul 21, 2020 5:43 am
by nexos
Paging and virtual addressing are required for Long Mode. If you don't want to use them, stay in 32 bit mode.

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

Posted: Tue Jul 21, 2020 5:55 am
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

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

Posted: Tue Jul 21, 2020 6:40 am
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.