kmalloc 如何返回大于物理地址大小的物理地址? [英] How can kmalloc return a physical address greater than the size of the physical address?

查看:86
本文介绍了kmalloc 如何返回大于物理地址大小的物理地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Linux 的设备驱动程序中使用 kmalloc 分配一块内存.我得到的地址是0xffff880000180000.我正在使用具有 46 位物理地址空间的 IvyBridge 处理器.这意味着 CPU 的寻址引脚不超过 46 个,因此它无法访问 0x00003fffffffffff 以上的任何地址.我得到的地址显然大于那个,因为它设置了第 47 位.

I am allocating a block of memory with kmalloc in a device driver in Linux. The address that I get is 0xffff880000180000. I am using an IvyBridge processor with a 46-bit physical address space. That means that the CPU doesn't have more than 46 addressing pins, so it can't access any address above 0x00003fffffffffff. The address I'm getting is obviously greater than that, as it has bit 47 set.

假设 kmalloc 返回一个物理指针(即虚拟地址、线性地址和物理地址相同的指针),如果无法通过中央处理器?

Assuming that kmalloc returns a physical pointer (that is, a pointer where the virtual, linear and physical addresses are the same), how can I be getting such an address, if it's not accessible by the CPU?

这个问题与为什么我在 Linux 中使用 kmalloc 和 GFP_DMA 时得到高地址?".然而,它并不完全相同.这个问题是关于kmalloc 一般返回的物理地址,而链接的问题是关于GFP_DMA 的使用及其与返回地址的关系.

This question is related to "Why am I getting a high address when I use kmalloc with GFP_DMA in Linux?". However, it is not identical. This question is about the physical addresses kmalloc returns in general, whereas the linked question is about use of GFP_DMA and its relationship to the returned address.

推荐答案

它显然不是物理地址,而是线性或虚拟地址,并且是规范形式",其中第 47 位的值被符号扩展"到第 63 位.

It's clearly not a physical address but a linear or virtual address, and is in 'canonical form' where the value of bit 47 is 'sign extended' up to bit 63.

这篇关于kmalloc 如何返回大于物理地址大小的物理地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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