Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xtensa: allow merging vectors into .text section

Currently code for exception/IRQ vectors is stored in kernel image as
initialization data and is copied to its working addresses during
startup. It doesn't always make sense. In many cases vectors location
can be automatically decided at kernel link time and code can be placed
right there. This is especially useful for XIP kernel.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

+48
+4
arch/xtensa/include/asm/vectors.h
··· 67 67 #endif /* CONFIG_MMU */ 68 68 69 69 #define RESET_VECTOR1_VADDR (XCHAL_RESET_VECTOR1_VADDR) 70 + #ifdef CONFIG_VECTORS_OFFSET 70 71 #define VECBASE_VADDR (KERNELOFFSET - CONFIG_VECTORS_OFFSET) 72 + #else 73 + #define VECBASE_VADDR _vecbase 74 + #endif 71 75 72 76 #if defined(XCHAL_HAVE_VECBASE) && XCHAL_HAVE_VECBASE 73 77
+3
arch/xtensa/kernel/setup.c
··· 455 455 456 456 mem_reserve(__pa(&_stext), __pa(&_end)); 457 457 458 + #ifdef CONFIG_VECTORS_OFFSET 458 459 mem_reserve(__pa(&_WindowVectors_text_start), 459 460 __pa(&_WindowVectors_text_end)); 460 461 ··· 491 490 mem_reserve(__pa(&_Level6InterruptVector_text_start), 492 491 __pa(&_Level6InterruptVector_text_end)); 493 492 #endif 493 + 494 + #endif /* CONFIG_VECTORS_OFFSET */ 494 495 495 496 #ifdef CONFIG_SMP 496 497 mem_reserve(__pa(&_SecondaryResetVector_text_start),
+41
arch/xtensa/kernel/vmlinux.lds.S
··· 59 59 * garbage.) 60 60 */ 61 61 62 + #ifdef CONFIG_VECTORS_OFFSET 62 63 #define SECTION_VECTOR(sym, section, addr, max_prevsec_size, prevsec) \ 63 64 section addr : AT((MIN(LOADADDR(prevsec) + max_prevsec_size, \ 64 65 LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \ ··· 69 68 *(section) \ 70 69 sym ## _end = ABSOLUTE(.); \ 71 70 } 71 + #else 72 + #define SECTION_VECTOR(section, addr) \ 73 + . = addr; \ 74 + *(section) 75 + #endif 72 76 73 77 /* 74 78 * Mapping of input sections to output sections when linking. ··· 91 85 { 92 86 /* The HEAD_TEXT section must be the first section! */ 93 87 HEAD_TEXT 88 + 89 + #ifndef CONFIG_VECTORS_OFFSET 90 + . = ALIGN(PAGE_SIZE); 91 + _vecbase = .; 92 + 93 + SECTION_VECTOR (.WindowVectors.text, WINDOW_VECTORS_VADDR) 94 + #if XCHAL_EXCM_LEVEL >= 2 95 + SECTION_VECTOR (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR) 96 + #endif 97 + #if XCHAL_EXCM_LEVEL >= 3 98 + SECTION_VECTOR (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR) 99 + #endif 100 + #if XCHAL_EXCM_LEVEL >= 4 101 + SECTION_VECTOR (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR) 102 + #endif 103 + #if XCHAL_EXCM_LEVEL >= 5 104 + SECTION_VECTOR (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR) 105 + #endif 106 + #if XCHAL_EXCM_LEVEL >= 6 107 + SECTION_VECTOR (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR) 108 + #endif 109 + SECTION_VECTOR (.DebugInterruptVector.literal, DEBUG_VECTOR_VADDR - 4) 110 + SECTION_VECTOR (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR) 111 + SECTION_VECTOR (.KernelExceptionVector.literal, KERNEL_VECTOR_VADDR - 4) 112 + SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR) 113 + SECTION_VECTOR (.UserExceptionVector.literal, USER_VECTOR_VADDR - 4) 114 + SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR) 115 + SECTION_VECTOR (.DoubleExceptionVector.literal, DOUBLEEXC_VECTOR_VADDR - 48) 116 + SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR) 117 + #endif 118 + 94 119 TEXT_TEXT 95 120 VMLINUX_SYMBOL(__sched_text_start) = .; 96 121 *(.sched.literal .sched.text) ··· 169 132 . = ALIGN(16); 170 133 __boot_reloc_table_start = ABSOLUTE(.); 171 134 135 + #ifdef CONFIG_VECTORS_OFFSET 172 136 RELOCATE_ENTRY(_WindowVectors_text, 173 137 .WindowVectors.text); 174 138 #if XCHAL_EXCM_LEVEL >= 2 ··· 202 164 .DoubleExceptionVector.text); 203 165 RELOCATE_ENTRY(_DebugInterruptVector_text, 204 166 .DebugInterruptVector.text); 167 + #endif 205 168 #if defined(CONFIG_SMP) 206 169 RELOCATE_ENTRY(_SecondaryResetVector_text, 207 170 .SecondaryResetVector.text); ··· 225 186 . = ALIGN(4); 226 187 .dummy : { LONG(0) } 227 188 189 + #ifdef CONFIG_VECTORS_OFFSET 228 190 /* The vectors are relocated to the real position at startup time */ 229 191 230 192 SECTION_VECTOR (_WindowVectors_text, ··· 317 277 318 278 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; 319 279 280 + #endif 320 281 #if defined(CONFIG_SMP) 321 282 322 283 SECTION_VECTOR (_SecondaryResetVector_text,