Vectors page mapping in linux for ARM

戏子无情 提交于 2019-12-01 06:14:10

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/36649551/vectors-page-mapping-in-linux-for-arm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!