中的矢量页面映射

中的矢量页面映射

本文介绍了用于 ARM 的 linux 中的矢量页面映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

根据 early_trap_init() 中的评论 traps.c 向量从 entry-armv.S 复制到向量页面.

似乎 early_trap_init() 是从 devicemaps_init() 调用的 mmu.c.

在调用 early_trap_init() 之前,它正在使用 early_alloc() 创建向量页面,我在这里看不到任何映射.

能否请您帮助了解矢量页面映射是如何完成的?

解决方案

答案在你的 devicemaps_init() 链接(关于 3.14 中的第 1250 行).

/** 在高向量处为机器向量创建映射* 位置 (0xffff0000).如果我们不使用高向量,也* 在低向量虚拟地址创建映射.*/map.pfn = __phys_to_pfn(virt_to_phys(vectors));map.virtual = 0xffff0000;map.length = PAGE_SIZE;#ifdef CONFIG_KUSER_HELPERSmap.type = MT_HIGH_VECTORS;#别的map.type = MT_LOW_VECTORS;#万一create_mapping(&map);

那里有额外的代码来进行更多的映射.注意有物理向量指令加代码转换模式.这是通过 vector_stub 汇编程序宏完成的.评论中的解释非常好(另见第二个相关链接).

矢量存根.这段代码被复制到 0xffff1000 以便我们可以在向量,而不是 ldr.注意这个代码不能超过一个页面大小.常见的存根入口宏:进入IRQ模式,spsr = SVC/USR CPSR,lr = SVC/USR PCSP 指向最少量的处理器专用内存,地址其中被复制到 r0 以用于模式特定的中止处理程序.

所以我们可以在向量中使用分支表示向量表中的第一条指令.

相关:查找异常向量表的物理地址
Linux内核arm异常栈初始化

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.

It seems early_trap_init() is called from devicemaps_init() mmu.c.

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

这篇关于用于 ARM 的 linux 中的矢量页面映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 08:38