我试图了解向量页面如何映射到0xffff0000.
我指的是3.14内核。
根据early_trap_init()
traps.c中的评论,向量会从 entry-armv.S 复制到矢量页。
early_trap_init()
mmu.c似乎调用devicemaps_init()
。
在调用early_trap_init()
之前,它正在使用early_alloc()
创建向量页面,我在这里看不到任何映射。
您能帮助理解矢量页面映射是如何完成的吗?
答案 0 :(得分:2)
答案在您的devicemaps_init()
链接中(关于3.14中的第1250行)。
/*
* 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);
还有其他代码可用于制作更多映射。请注意,物理向量指令加上code to transition modes。这是通过vector_stub
汇编程序宏完成的。评论中的解释非常好(另见第二个相关链接)。
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.
所以我们可以在向量中使用分支表示向量表中的第一条指令。
相关:Find the physical address of exception vector table
Linux kernel arm exception stack init