用于 ARM 的 Linux 中的向量页面映射 [英] Vectors page mapping in linux for ARM

查看:17
本文介绍了用于 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 中的向量页面映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆