Linux中用于ARM的向量页面映射 [英] Vectors page mapping in linux for ARM
问题描述
我试图了解向量页面如何映射到0xffff0000.
我指的是3.14内核.
I am trying to understand how vectors page is mapped to 0xffff0000.
I am referring 3.14 kernel.
As per the comment in early_trap_init()
traps.c the vectors are copied from entry-armv.S to vector page.
似乎early_trap_init()
从devicemaps_init()
被调用 mmu.c .
在调用early_trap_init()
之前,它正在使用early_alloc()
创建矢量页面,我在这里看不到任何映射.
Before calling early_trap_init()
, it is creating vectors page using early_alloc()
and I couldn't see any mapping here.
能帮您了解向量页映射的完成方式吗?
Can you please help to understand how vectors page mapping is done?
推荐答案
The answer is in your devicemaps_init()
link (about line 1250 in 3.14).
/*
* Create a mapping for the machine vectors at the high-vectors
* location (0xffff0000). If we aren't using high-vectors, also
* create a mapping at the low-vectors virtual address.
*/
map.pfn = __phys_to_pfn(virt_to_phys(vectors));
map.virtual = 0xffff0000;
map.length = PAGE_SIZE;
#ifdef CONFIG_KUSER_HELPERS
map.type = MT_HIGH_VECTORS;
#else
map.type = MT_LOW_VECTORS;
#endif
create_mapping(&map);
那里还有其他代码可以进行更多映射.请注意,这里有物理矢量指令以及
There is additional code there to make more mappings. Note that there are the physical vector instruction plus code to transition modes. This is done via the vector_stub
assembler macro. An explanation in the comments is very good (also see the 2nd related link).
Vector stubs.
This code is copied to 0xffff1000 so we can use branches in the
vectors, rather than ldr's. Note that this code must not exceed
a page size.
Common stub entry macro:
Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
SP points to a minimal amount of processor-private memory, the address
of which is copied into r0 for the mode specific abort handler.
所以我们可以在向量中使用分支表示向量表中的第一条指令.
so we can use branches in the vectors means the very first instruction in the vector table.
相关:查找向量表的物理地址
Related: Find the physical address of exception vector table
Linux kernel arm exception stack init
这篇关于Linux中用于ARM的向量页面映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!