如果访问X86系统中不存在的物理地址怎么办? [英] What if accessing a non-existing physical address in X86 system?

查看:213
本文介绍了如果访问X86系统中不存在的物理地址怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Linux内核模块,该模块通过玩进程的页表将物理地址范围映射到进程的虚拟地址空间. 然后,我脑子里有一个问题,如果PTE指向不存在的物理地址会发生什么?
例如,我的X86笔记本电脑具有8GB DRAM,并且如果PTE的值为0x8000000400001227,CPU会为此访问无效地址生成一些异常吗?
我对此进行了快速测试,但是没有发生任何异常情况,我完全感到困惑.

I am working on a Linux kernel module, which maps a physical address range to a process virtual address space, by playing with process's page tables.
Then, I have a question in my head, what will happen if a PTE points to a non-existing physical address?
For example, my X86 laptop has 8GB DRAM, and if a PTE has the value of 0x8000000400001227, will the CPU generate some exception for this invalid address accessing?
I did a quick a test with that, but there is NOthing unusual happened, and I got confused totally.

请帮助阐明背后的原因,或者让我知道我是否真的需要阅读一些X86文档.

Please help clarifying the reason behind, or let me know if I really need to read some X86 documents.

推荐答案

通常,读取到不存在的内存将返回所有FF,并且将丢弃内存. (在某些平台和/或某些地址范围内,读取结果可能返回0.这取决于芯片组对地址范围的解码方式.)

Typically a memory read to non-existent memory will return all FF's and a memory write will be discarded. (With some platforms and/or some address ranges, reads may return 0. It depends on how the address range is decoded by the chipset.)

页表入口位51:M被保留(其中M是处理器支持的物理地址宽度),因此,如果您映射并尝试访问大于物理地址宽度的地址,则会由于页面错误保留位违规.对于客户,我认为M通常为39位;更多用于服务器.您可以使用eax = 80000008的CPUID并检查eax的7:0位来找到系统的值.

Page table entry bits 51:M are reserved (where M is the physical address width supported by the processor), so if you map and try to access an address greater than the physical address width, you will get a page fault due to a reserved bit violation. I think M is typically 39 bits for clients; more for servers. You can find out the value for your system using CPUID with eax=80000008 and examining bits 7:0 of eax.

这篇关于如果访问X86系统中不存在的物理地址怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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