Skip to content

Commit a22c3f6

Browse files
committed
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
2 parents a941a03 + 056c52f commit a22c3f6

File tree

8 files changed

+40
-55
lines changed

8 files changed

+40
-55
lines changed

arch/x86/include/asm/desc.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,26 @@ static inline void store_idt(struct desc_ptr *dtr)
224224
asm volatile("sidt %0":"=m" (*dtr));
225225
}
226226

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+
227247
/*
228248
* The LTR instruction marks the TSS GDT entry as busy. On 64-bit, the GDT is
229249
* a read-only remapping. To prevent a page fault, the GDT is switched to the
@@ -425,6 +445,6 @@ extern void idt_setup_early_pf(void);
425445
static inline void idt_setup_early_pf(void) { }
426446
#endif
427447

428-
extern void idt_invalidate(void *addr);
448+
extern void idt_invalidate(void);
429449

430450
#endif /* _ASM_X86_DESC_H */

arch/x86/include/asm/idtentry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ __visible noinstr void func(struct pt_regs *regs, \
495495
.align 8
496496
SYM_CODE_START(irq_entries_start)
497497
vector=FIRST_EXTERNAL_VECTOR
498-
.rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
498+
.rept NR_EXTERNAL_VECTORS
499499
UNWIND_HINT_IRET_REGS
500500
0 :
501501
.byte 0x6a, vector
@@ -511,7 +511,7 @@ SYM_CODE_END(irq_entries_start)
511511
.align 8
512512
SYM_CODE_START(spurious_entries_start)
513513
vector=FIRST_SYSTEM_VECTOR
514-
.rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
514+
.rept NR_SYSTEM_VECTORS
515515
UNWIND_HINT_IRET_REGS
516516
0 :
517517
.byte 0x6a, vector

arch/x86/include/asm/irq_vectors.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* This file enumerates the exact layout of them:
2727
*/
2828

29+
/* This is used as an interrupt vector when programming the APIC. */
2930
#define NMI_VECTOR 0x02
30-
#define MCE_VECTOR 0x12
3131

3232
/*
3333
* IDT vectors usable for external interrupt sources start at 0x20.
@@ -84,7 +84,7 @@
8484
*/
8585
#define IRQ_WORK_VECTOR 0xf6
8686

87-
#define UV_BAU_MESSAGE 0xf5
87+
/* 0xf5 - unused, was UV_BAU_MESSAGE */
8888
#define DEFERRED_ERROR_VECTOR 0xf4
8989

9090
/* Vector on which hypervisor callbacks will be delivered */
@@ -114,6 +114,9 @@
114114
#define FIRST_SYSTEM_VECTOR NR_VECTORS
115115
#endif
116116

117+
#define NR_EXTERNAL_VECTORS (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
118+
#define NR_SYSTEM_VECTORS (NR_VECTORS - FIRST_SYSTEM_VECTOR)
119+
117120
/*
118121
* Size the maximum number of interrupts.
119122
*

arch/x86/kernel/idt.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,10 @@ void __init idt_setup_early_handler(void)
315315

316316
/**
317317
* idt_invalidate - Invalidate interrupt descriptor table
318-
* @addr: The virtual address of the 'invalid' IDT
319318
*/
320-
void idt_invalidate(void *addr)
319+
void idt_invalidate(void)
321320
{
322-
struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 };
321+
static const struct desc_ptr idt = { .address = 0, .size = 0 };
323322

324323
load_idt(&idt);
325324
}

arch/x86/kernel/machine_kexec_32.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@
2323
#include <asm/set_memory.h>
2424
#include <asm/debugreg.h>
2525

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-
3726
static void load_segments(void)
3827
{
3928
#define __STR(X) #X
@@ -232,8 +221,8 @@ void machine_kexec(struct kimage *image)
232221
* The gdt & idt are now invalid.
233222
* If you want to load them you must set up your own idt & gdt.
234223
*/
235-
idt_invalidate(phys_to_virt(0));
236-
set_gdt(phys_to_virt(0), 0);
224+
native_idt_invalidate();
225+
native_gdt_invalidate();
237226

238227
/* now call it */
239228
image->start = relocate_kernel_ptr((unsigned long)image->head,

arch/x86/kernel/machine_kexec_64.c

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -256,35 +256,6 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
256256
return init_transition_pgtable(image, level4p);
257257
}
258258

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-
288259
static void load_segments(void)
289260
{
290261
__asm__ __volatile__ (
@@ -379,8 +350,8 @@ void machine_kexec(struct kimage *image)
379350
* The gdt & idt are now invalid.
380351
* If you want to load them you must set up your own idt & gdt.
381352
*/
382-
set_gdt(phys_to_virt(0), 0);
383-
set_idt(phys_to_virt(0), 0);
353+
native_idt_invalidate();
354+
native_gdt_invalidate();
384355

385356
/* now call it */
386357
image->start = relocate_kernel((unsigned long)image->head,

arch/x86/kernel/reboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static void native_machine_emergency_restart(void)
669669
break;
670670

671671
case BOOT_TRIPLE:
672-
idt_invalidate(NULL);
672+
idt_invalidate();
673673
__asm__ __volatile__("int3");
674674

675675
/* We're probably dead after this, but... */

tools/arch/x86/include/asm/irq_vectors.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* This file enumerates the exact layout of them:
2727
*/
2828

29+
/* This is used as an interrupt vector when programming the APIC. */
2930
#define NMI_VECTOR 0x02
30-
#define MCE_VECTOR 0x12
3131

3232
/*
3333
* IDT vectors usable for external interrupt sources start at 0x20.
@@ -84,7 +84,7 @@
8484
*/
8585
#define IRQ_WORK_VECTOR 0xf6
8686

87-
#define UV_BAU_MESSAGE 0xf5
87+
/* 0xf5 - unused, was UV_BAU_MESSAGE */
8888
#define DEFERRED_ERROR_VECTOR 0xf4
8989

9090
/* Vector on which hypervisor callbacks will be delivered */
@@ -114,6 +114,9 @@
114114
#define FIRST_SYSTEM_VECTOR NR_VECTORS
115115
#endif
116116

117+
#define NR_EXTERNAL_VECTORS (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
118+
#define NR_SYSTEM_VECTORS (NR_VECTORS - FIRST_SYSTEM_VECTOR)
119+
117120
/*
118121
* Size the maximum number of interrupts.
119122
*

0 commit comments

Comments
 (0)