What happens when you lose the virtual address of the page directory?

流过昼夜 提交于 2020-06-01 01:40:29

问题


I'm writing a memory manager for my kernel (32 bit x86) In the course of this... I'm facing a bit of a dilemma....

Description of virtual memory map:

  • Identity map of first 4 Mb
  • Virtual address 0xC0000000 mapped to physical address 0x100000 (Also a 4 Mb map)

My page directory is at physical address 0x9c000. My page table 1 is at physical address 0x9d000. My page table 2 is at physical addres 0x9e000.

(I need only two page tables here :) ... These correspond to the identity map and higher memory map respectively)

Bless the identity mapping.... I can safely access my page directory and page tables as if paging wasn't even enabled. This makes it really easy for me to modify page tables,etc.

Now comes the issue: I may remove this identity mapping... If so, I can already imagine problems creeping up.. Eg. I have physical addresses that I want to access... But I can only access virtual ones. In order to map the virtual address to the required physical address, I need to access the page directory. But I have the physical address of the page directory... *I realize that I'm back where I started.

So, I'm guessing there's a need for some permanent mapping (or some sort of identity mapping for tables and the directory) so that I can forget about all this and get on with my life.

But if I map something permanently, I feel that I'm reducing the flexibilty of the program(kernel) in some sort of way.

What's the way one deals with this issue?

What happens when you lose the virtual address of the page directory? You can always get the physical address from cr3, but you have no idea where it's mapped, how to access it, and whatnot. In this case, I don't think one can even change the page directory location using cr3 because you'd be loading a physical address into it, but all that you can view are virtual addresses... It seems like a really scary situation here

Am I missing something?


回答1:


Don't lose your virtual Page directory address! You need at least a small portion of the page directory at a know physical and a known virtual address (they do not need identity mapped).



来源:https://stackoverflow.com/questions/60228298/what-happens-when-you-lose-the-virtual-address-of-the-page-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!