当您丢失页面目录的虚拟地址时会发生什么? [英] What happens when you lose the virtual address of the page directory?

查看:112
本文介绍了当您丢失页面目录的虚拟地址时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的内核(32位x86)编写一个内存管理器. 在此过程中...我面临一些困境....

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....

虚拟内存映射的描述:

  • 前4 Mb的身份图
  • 虚拟地址0xC0000000映射到物理地址0x100000(也有4 Mb映射)

我的页面目录位于物理地址0x9c000. 我的页表1位于物理地址0x9d000. 我的页面表2位于物理地址0x9e000.

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?

丢失页面目录的虚拟地址会怎样?您始终可以从cr3获取物理地址,但是您不知道它的映射位置,访问方式以及其他内容.在这种情况下,我认为没有人甚至可以使用cr3来更改页面目录位置,因为您将向其中加载物理地址,但是您只能查看虚拟地址...这似乎是一种非常可怕的情况这里

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

我想念什么吗?

推荐答案

不要丢失您的虚拟页面目录地址!您至少需要页面目录的一小部分位于一个已知的物理地址和一个已知的虚拟地址(它们不需要身份映射).

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).

这篇关于当您丢失页面目录的虚拟地址时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆