2016-04-15 79 views
3

我想了解矢量页面如何映射到0xffff0000. 我指的是3.14内核。Linux中的矢量页面映射ARM

作为每注释中early_trap_init()traps.c的向量从入门armv.S到矢量页复制。

看起来early_trap_init()被称为devicemaps_init()mmu.c

在致电early_trap_init()之前,它使用early_alloc()创建矢量页面,我在这里看不到任何映射。

你能帮助理解向量页面映射是如何完成的吗?

回答

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汇编程序宏完成的。评论中的解释非常好(另请参阅第2条相关链接)。

 
    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

+0

我是在假定“最初记忆将是矢量页面创建(物理地址)和将映射到虚拟地址0xffff0000然后矢量将被复制到矢量页面“,但在看到回复后第一个为矢量页面创建的内存(使用ea rly_alloc(),它返回虚拟地址),通过调用early_trap_init()复制向量,然后映射为0xffff0000的矢量页面完成。我怀疑这里有两个虚拟映射是为矢量页面发生的吗?(第一个虚拟地址由early_alloc()返回,第二个虚拟地址在显式映射中,如上面的回复所示)。 – user3693586

+0

是的,有多个映射。没事儿?有些是可读/写的,而其他是只读的。有些可以通过用户空间访问,其他则不可以。 *我想了解向量页面如何映射到0xffff0000。*是我回答的问题。你从来没有说过关于两种映射的疑问。 –

+0

最初我的疑问是关于矢量页面映射,看到回复后,我对矢量页面的两个虚拟映射有疑问。 – user3693586