[英]How to create 1:1 MMU mapping in ARM64 Linux?
I'm trying to switch off MMU to run some test code.我正在尝试关闭 MMU 以运行一些测试代码。 I need to create exactly 1:1 virtual to physical memory mapping for code to run after MMU turned off.我需要创建精确的 1:1 虚拟到物理 memory 映射,以便在 MMU 关闭后运行代码。
In this question a guy described a method to create such a mapping with assembly code, but it seems like by the time he creates mapping, system is unfunctional. 在这个问题中,一个人描述了一种使用汇编代码创建这种映射的方法,但似乎在他创建映射时,系统已经无法正常工作。
My question is:我的问题是:
I need to create exactly 1:1 virtual to physical memory mapping for code to run after MMU turned off我需要创建精确的 1:1 虚拟到物理 memory 映射,以便在 MMU 关闭后运行代码
That simply does not make sense.这根本没有意义。 Memory mapping is used only when MMU is ON . Memory 映射仅在 MMU 为ON时使用。
Once MMU is off there is no virtual-to-physical translations and memory is access by physical addresses.一旦 MMU 关闭,就没有虚拟到物理的转换,并且 memory 可以通过物理地址访问。 Well in such way it could be described as '1:1 virtual to physical'.嗯,以这种方式,它可以被描述为“1:1 虚拟到物理”。
Problem with switching off MMU is that code which does that should be specially build to run with that 1:1 mapping.关闭 MMU 的问题是应该专门构建以使用该 1:1 映射运行的代码。
For example code is build to call function with virtual address 0x8000
.例如,构建代码以使用虚拟地址0x8000
调用 function 。 OS is placing you program at physical address 0x00C0_0000
.操作系统将您的程序放置在物理地址0x00C0_0000
。 So basically jump into 0x8000
is jumping to physical 0x00C0_8000
.所以基本上跳转到0x8000
就是跳转到物理0x00C0_8000
。
Once MMU is off, jump into 0x8000
would be into physical 0x8000
.一旦 MMU 关闭,跳转到0x8000
将进入物理0x8000
。
Additionally, make sure that caches are flushed before turning MMU off.此外,请确保在关闭 MMU 之前刷新缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.