2016-04-15 39 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