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

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

问题描述

我无法完全区分内核逻辑地址和虚拟地址.在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区域,不是RAM.

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天全站免登陆