Vectors page mapping in linux for ARM

前端 未结 1 1966
悲&欢浪女
悲&欢浪女 2021-01-06 15:46

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() tra

相关标签:
1条回答
  • 2021-01-06 16:29

    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

    0 讨论(0)
提交回复
热议问题