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

Merge tag 'x86-irq-2021-06-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 interrupt related updates from Thomas Gleixner:

- Consolidate the VECTOR defines and the usage sites.

- Cleanup GDT/IDT related code and replace open coded ASM with proper
native helper functions.

* tag 'x86-irq-2021-06-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/kexec: Set_[gi]dt() -> native_[gi]dt_invalidate() in machine_kexec_*.c
x86: Add native_[ig]dt_invalidate()
x86/idt: Remove address argument from idt_invalidate()
x86/irq: Add and use NR_EXTERNAL_VECTORS and NR_SYSTEM_VECTORS
x86/irq: Remove unused vectors defines

+40 -55
+21 -1
arch/x86/include/asm/desc.h
··· 224 224 asm volatile("sidt %0":"=m" (*dtr)); 225 225 } 226 226 227 + static inline void native_gdt_invalidate(void) 228 + { 229 + const struct desc_ptr invalid_gdt = { 230 + .address = 0, 231 + .size = 0 232 + }; 233 + 234 + native_load_gdt(&invalid_gdt); 235 + } 236 + 237 + static inline void native_idt_invalidate(void) 238 + { 239 + const struct desc_ptr invalid_idt = { 240 + .address = 0, 241 + .size = 0 242 + }; 243 + 244 + native_load_idt(&invalid_idt); 245 + } 246 + 227 247 /* 228 248 * The LTR instruction marks the TSS GDT entry as busy. On 64-bit, the GDT is 229 249 * a read-only remapping. To prevent a page fault, the GDT is switched to the ··· 445 425 static inline void idt_setup_early_pf(void) { } 446 426 #endif 447 427 448 - extern void idt_invalidate(void *addr); 428 + extern void idt_invalidate(void); 449 429 450 430 #endif /* _ASM_X86_DESC_H */
+2 -2
arch/x86/include/asm/idtentry.h
··· 495 495 .align 8 496 496 SYM_CODE_START(irq_entries_start) 497 497 vector=FIRST_EXTERNAL_VECTOR 498 - .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR) 498 + .rept NR_EXTERNAL_VECTORS 499 499 UNWIND_HINT_IRET_REGS 500 500 0 : 501 501 .byte 0x6a, vector ··· 511 511 .align 8 512 512 SYM_CODE_START(spurious_entries_start) 513 513 vector=FIRST_SYSTEM_VECTOR 514 - .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR) 514 + .rept NR_SYSTEM_VECTORS 515 515 UNWIND_HINT_IRET_REGS 516 516 0 : 517 517 .byte 0x6a, vector
+5 -2
arch/x86/include/asm/irq_vectors.h
··· 26 26 * This file enumerates the exact layout of them: 27 27 */ 28 28 29 + /* This is used as an interrupt vector when programming the APIC. */ 29 30 #define NMI_VECTOR 0x02 30 - #define MCE_VECTOR 0x12 31 31 32 32 /* 33 33 * IDT vectors usable for external interrupt sources start at 0x20. ··· 84 84 */ 85 85 #define IRQ_WORK_VECTOR 0xf6 86 86 87 - #define UV_BAU_MESSAGE 0xf5 87 + /* 0xf5 - unused, was UV_BAU_MESSAGE */ 88 88 #define DEFERRED_ERROR_VECTOR 0xf4 89 89 90 90 /* Vector on which hypervisor callbacks will be delivered */ ··· 113 113 #else 114 114 #define FIRST_SYSTEM_VECTOR NR_VECTORS 115 115 #endif 116 + 117 + #define NR_EXTERNAL_VECTORS (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR) 118 + #define NR_SYSTEM_VECTORS (NR_VECTORS - FIRST_SYSTEM_VECTOR) 116 119 117 120 /* 118 121 * Size the maximum number of interrupts.
+2 -3
arch/x86/kernel/idt.c
··· 315 315 316 316 /** 317 317 * idt_invalidate - Invalidate interrupt descriptor table 318 - * @addr: The virtual address of the 'invalid' IDT 319 318 */ 320 - void idt_invalidate(void *addr) 319 + void idt_invalidate(void) 321 320 { 322 - struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 }; 321 + static const struct desc_ptr idt = { .address = 0, .size = 0 }; 323 322 324 323 load_idt(&idt); 325 324 }
+2 -13
arch/x86/kernel/machine_kexec_32.c
··· 23 23 #include <asm/set_memory.h> 24 24 #include <asm/debugreg.h> 25 25 26 - static void set_gdt(void *newgdt, __u16 limit) 27 - { 28 - struct desc_ptr curgdt; 29 - 30 - /* ia32 supports unaligned loads & stores */ 31 - curgdt.size = limit; 32 - curgdt.address = (unsigned long)newgdt; 33 - 34 - load_gdt(&curgdt); 35 - } 36 - 37 26 static void load_segments(void) 38 27 { 39 28 #define __STR(X) #X ··· 221 232 * The gdt & idt are now invalid. 222 233 * If you want to load them you must set up your own idt & gdt. 223 234 */ 224 - idt_invalidate(phys_to_virt(0)); 225 - set_gdt(phys_to_virt(0), 0); 235 + native_idt_invalidate(); 236 + native_gdt_invalidate(); 226 237 227 238 /* now call it */ 228 239 image->start = relocate_kernel_ptr((unsigned long)image->head,
+2 -31
arch/x86/kernel/machine_kexec_64.c
··· 256 256 return init_transition_pgtable(image, level4p); 257 257 } 258 258 259 - static void set_idt(void *newidt, u16 limit) 260 - { 261 - struct desc_ptr curidt; 262 - 263 - /* x86-64 supports unaligned loads & stores */ 264 - curidt.size = limit; 265 - curidt.address = (unsigned long)newidt; 266 - 267 - __asm__ __volatile__ ( 268 - "lidtq %0\n" 269 - : : "m" (curidt) 270 - ); 271 - }; 272 - 273 - 274 - static void set_gdt(void *newgdt, u16 limit) 275 - { 276 - struct desc_ptr curgdt; 277 - 278 - /* x86-64 supports unaligned loads & stores */ 279 - curgdt.size = limit; 280 - curgdt.address = (unsigned long)newgdt; 281 - 282 - __asm__ __volatile__ ( 283 - "lgdtq %0\n" 284 - : : "m" (curgdt) 285 - ); 286 - }; 287 - 288 259 static void load_segments(void) 289 260 { 290 261 __asm__ __volatile__ ( ··· 350 379 * The gdt & idt are now invalid. 351 380 * If you want to load them you must set up your own idt & gdt. 352 381 */ 353 - set_gdt(phys_to_virt(0), 0); 354 - set_idt(phys_to_virt(0), 0); 382 + native_idt_invalidate(); 383 + native_gdt_invalidate(); 355 384 356 385 /* now call it */ 357 386 image->start = relocate_kernel((unsigned long)image->head,
+1 -1
arch/x86/kernel/reboot.c
··· 669 669 break; 670 670 671 671 case BOOT_TRIPLE: 672 - idt_invalidate(NULL); 672 + idt_invalidate(); 673 673 __asm__ __volatile__("int3"); 674 674 675 675 /* We're probably dead after this, but... */
+5 -2
tools/arch/x86/include/asm/irq_vectors.h
··· 26 26 * This file enumerates the exact layout of them: 27 27 */ 28 28 29 + /* This is used as an interrupt vector when programming the APIC. */ 29 30 #define NMI_VECTOR 0x02 30 - #define MCE_VECTOR 0x12 31 31 32 32 /* 33 33 * IDT vectors usable for external interrupt sources start at 0x20. ··· 84 84 */ 85 85 #define IRQ_WORK_VECTOR 0xf6 86 86 87 - #define UV_BAU_MESSAGE 0xf5 87 + /* 0xf5 - unused, was UV_BAU_MESSAGE */ 88 88 #define DEFERRED_ERROR_VECTOR 0xf4 89 89 90 90 /* Vector on which hypervisor callbacks will be delivered */ ··· 113 113 #else 114 114 #define FIRST_SYSTEM_VECTOR NR_VECTORS 115 115 #endif 116 + 117 + #define NR_EXTERNAL_VECTORS (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR) 118 + #define NR_SYSTEM_VECTORS (NR_VECTORS - FIRST_SYSTEM_VECTOR) 116 119 117 120 /* 118 121 * Size the maximum number of interrupts.