Linux内核ARM转换表基地(TTB0和TTB1) [英] Linux kernel ARM Translation table base (TTB0 and TTB1)

查看:4830
本文介绍了Linux内核ARM转换表基地(TTB0和TTB1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译Linux内核2.6.34.3对ARMv7(Cortex-A8的)

Compiled Linux kernel 2.6.34.3 for ARMv7 (Cortex-a8)

我看着内核code,它看起来像Linux内核设置上TTB1内核地址空间(一切都在为0xC0000000)上ttb0在硬件页表(转换表基地)和用户进程(一切为0xC0000000),它改变了每个进程上下文切换。它是否正确?我仍然困惑的MMU是如何知道看的翻译哪些TTB?

I looked into the kernel code and it looks like the Linux kernel sets the hardware page tables for the kernel address space (everything over 0xC0000000)on TTB1 (translation table base) and the user process on ttb0 (everything under 0xC0000000) which changes for every process context switch. Is this correct? I'm still confused how the MMU knows which ttb to look at for translations?

我读到,TTBCR(转换表基控制寄存器)决定当MVA找不到走路其中TTB寄存器,但寄存器总是读0这意味着总是在ARM架构参考手册使用TTBR0。这怎么可能?谁能给我解释一下Linux内核是如何使用这两个TTBS?

I read that the TTBCR (translation table base control register) determines which of the ttb register to walk when an MVA is not found, however the register always reads 0 which means always use TTBR0 in the ARM architecture reference manual. How is that possible? Can anyone explain to me how the Linux kernel uses these two ttbs?

我看了是如何从这个网站 HTTP: //www.cs.rutgers.edu/~pxk/416/notes/09a-paging.html 但我还是不明白内核是如何使用两个TTBS

I read how the ttb works from this site http://www.cs.rutgers.edu/~pxk/416/notes/09a-paging.html but I still dont understand how the kernel use the two ttbs

(双重检查内核code,由于某种原因,既ttb0和ttb1设置,但似乎从未使用ttb1,我的TTB1寄存器设置为0,Linux内核继续照常运行)

(Double checked the kernel code, for some reason both ttb0 and ttb1 is set, but it seems like ttb1 is never used, i set the TTB1 register to 0 and the Linux kernel continue to run as usual)

推荐答案

该TTBR寄存器一起使用,以确定寻址完整的32位或40位的地址空间。这寄存器是用来做什么地址范围是通过在TTBCR的tXsz位控制。没有为t0sz对应TTBR0和t1sz为TTBR1的条目。

The TTBR registers are used together to determine addressing for the full 32-bit or 40-bit address space. Which register is used for what address ranges is controlled via the tXsz bits in the TTBCR. There is an entry for t0sz corresponding to TTBR0 and t1sz for TTBR1.

每个TTBRx寄存器寻址页表是独立的,但你通常会发现大多数Linux实现只使用TTBR0。 Linux的希望能够使用3G / 1G的地址空间的分区方案,这是不是ARM支持。如果你看一下ARMv7架构参考手册B3-1345页面,你会看到t0sz中的​​价值和t1sz确定分别TTBR0和TTBR1支持的地址范围。添加混淆迷惑,甚至有可能对具有不邻接的地址空间,其中TTBR0和TTBR1支持范围是不连续的,从而在系统地址空间的孔。好时光!

The page tables addressed by each TTBRx register are independent, but you typically find most Linux implementations just use TTBR0. Linux expects to be able to use a 3G/1G address space partitioning scheme, which is not supported by ARM. If you look at page B3-1345 of the ARMv7 Architecture Reference Manual, you'll see that the value of t0sz and t1sz determine the address ranges supported by TTBR0 and TTBR1 respectively. To add confusion to disorientation, it is even possible to have disjoined address spaces where TTBR0 and TTBR1 support ranges that are not contiguous, resulting in a hole in the system address space. Good times!

要虽然回答您的主要问题,这是由ARM建议TTBR0用来存储所述偏移到由用户进程所使用的页表,并且TTBR1用来存储所述偏移到由内核所使用的页表。我还没有看到一个单一的实现,实际上做到这一点。几乎完全TTBR0是在所有情况下使用的,与含有在L1表的副本TTBR1

To answer your main question though, it is recommended by ARM that TTBR0 be used to store the offset to the page tables used by USER processes, and TTBR1 be used to store the offset to the page tables used by the KERNEL. I have yet to see a single implementation that actually does this. Almost exclusively TTBR0 is used in all cases, with TTBR1 containing a duplicate copy of the L1 tables.

那么如何工作的呢? TTBR的值存储为过程状态的部分,只是每次恢复了与切换出的处理。这是它预期如何工作。本来,TTBR1将持有内核表的恒定值,并永远无法被取代或交换出去,而TTBR0会在每次上下文的进程之间切换时更改。显然,大多数Linux实现了ARM已经决定只基本消除使用TTBR1,并坚持使用TTBR0的一切。

So how does this work? The value of TTBR is stored as part of the process state and simply restored each time a process with switched out. This is how it is expected to work. Originally, TTBR1 would hold a constant value for the kernel tables and never be replaced or swapped out, whereas TTBR0 would be changed each time you context switch between processes. Apparently most Linux implementations for ARM have decided to just basically eliminate the use of TTBR1 and stick to using TTBR0 for everything.

如果你想测试你的设备上的这一理论,尝试重击TTBR1,看什么都不发生。然后尝试重击TTBR0,看你的系统崩溃。我还没有遇到一个单一实例并未导致此相同的结果。长话短说,TTBR1是Linux的没用,TTBR0几乎只用简单地换出。

If you want to test this theory on your device, try whacking TTBR1 and watch nothing happen. Then try whacking TTBR0 and watch your system crash. I've yet to encounter a single instance that didn't result in this exact same result. Long story short, TTBR1 is useless by Linux, and TTBR0 is used almost exclusively and simply swapped out.

现在,一旦你到LPAE支持,抛出此一切,并重新开始。在这里,您将开始看到t0sz和t1sz比为零的东西的价值,因此N作为很好的落实。

Now, once you get to LPAE support, throw all this away and start over again. This is the implementation where you will start to see the value of t0sz and t1sz being something other than zero, and hence N as well.

这篇关于Linux内核ARM转换表基地(TTB0和TTB1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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