内核虚拟地址和内核逻辑地址的区别? [英] Difference between Kernel Virtual Address and Kernel Logical Address?

查看:34
本文介绍了内核虚拟地址和内核逻辑地址的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法准确区分内核逻辑地址和虚拟地址.在 Linux 设备驱动程序书中,它说所有逻辑地址都是内核虚拟地址,虚拟地址没有任何线性映射.但是当我们说它是合乎逻辑的时,当我们说虚拟时,我们在什么情况下使用这两个?

I am not able to exactly difference between kernel logical address and virtual address. In Linux device driver book it says that all logical address are kernel virtual address, and virtual address doesn't have any linear mapping. But logically wise when we say it is logical and when we say virtual and in which situation we use these two ?

推荐答案

Linux 内核映射大部分属于内核的虚拟地址空间,以物理内存第一部分的偏移量进行 1:1 映射.(对于 32 位 x86 的 1Gb 略少,对于其他处理器或配置可能有所不同).例如,对于 x86 地址上的内核代码,0xc00000001 映射到物理地址 0x1.

The Linux kernel maps most of the virtual address space that belongs to the kernel to perform 1:1 mapping with an offset of the first part of physical memory. (slightly less then for 1Gb for 32bit x86, can be different for other processors or configurations). For example, for kernel code on x86 address 0xc00000001 is mapped to physical address 0x1.

这称为逻辑映射 - 一种 1:1 映射(带有偏移量),允许内核访问机器的大部分物理内存.

This is called logical mapping - a 1:1 mapping (with an offset) that allows the kernel to access most of the physical memory of the machine.

但这还不够——有时我们在 32 位机器上有超过 1Gb 的物理内存,有时我们想将非连续物理内存块引用为连续的以使事情简单,有时我们想映射内存映射的 IO 区域,这些区域是不是内存.

But this is not enough - sometime we have more then 1Gb physical memory on a 32bit machine, sometime we want to reference non contiguous physical memory blocks as contiguous to make thing simple, sometime we want to map memory mapped IO regions which are not RAM.

为此,内核在其虚拟地址空间的顶部保留一个区域,在该区域进行随机"页面到页面映射.那里的映射不遵循逻辑映射区域的 1:1 模式.这就是我们所说的虚拟映射.

For this, the kernel keeps a region at the top of its virtual address space where it does a "random" page to page mapping. The mapping there do not follow the 1:1 pattern of the logical mapping area. This is what we call the virtual mapping.

重要的是要补充一点,在许多平台上(x86 是一个例子),逻辑和虚拟映射都是使用相同的硬件机制(TLB 控制虚拟内存)完成的.在许多情况下,逻辑映射"实际上是使用处理器的虚拟内存设施来完成的,所以这可能有点令人困惑.因此,不同之处在于完成映射所依据的模式:逻辑为 1:1,虚拟为随机.

It is important to add that on many platforms (x86 is an example), both the logical and virtual mapping are done using the same hardware mechanism (TLB controlling virtual memory). In many cases, the "logical mapping" is actually done using virtual memory facility of the processor, so this can be a little confusing. The difference therefore is the pattern according to which the mapping is done: 1:1 for logical, something random for virtual.

这篇关于内核虚拟地址和内核逻辑地址的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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