x86/idt: Remove address argument from idt_invalidate()
authorH. Peter Anvin (Intel) <hpa@zytor.com>
Wed, 19 May 2021 21:21:50 +0000 (14:21 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 21 May 2021 10:36:45 +0000 (12:36 +0200)
There is no reason to specify any specific address to idt_invalidate(). It
looks mostly like an artifact of unifying code done differently by
accident. The most "sensible" address to set here is a NULL pointer -
virtual address zero, just as a visual marker.

This also makes it possible to mark the struct desc_ptr in idt_invalidate()
as static const.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210519212154.511983-5-hpa@zytor.com
arch/x86/include/asm/desc.h
arch/x86/kernel/idt.c
arch/x86/kernel/machine_kexec_32.c
arch/x86/kernel/reboot.c

index 476082a83d1c1147e975bdf22107360fdfd1eef6..b8429ae50b71ce1e4e12028d560e57cdc5ee1bd4 100644 (file)
@@ -427,6 +427,6 @@ static inline void idt_setup_early_pf(void) { }
 static inline void idt_setup_ist_traps(void) { }
 #endif
 
-extern void idt_invalidate(void *addr);
+extern void idt_invalidate(void);
 
 #endif /* _ASM_X86_DESC_H */
index d552f177eca0e927c7a56efcff2c7fcbe7af21e3..2779f5226dc21ded1f6e242ec5d24ddda56ff02d 100644 (file)
@@ -331,11 +331,10 @@ void __init idt_setup_early_handler(void)
 
 /**
  * idt_invalidate - Invalidate interrupt descriptor table
- * @addr:      The virtual address of the 'invalid' IDT
  */
-void idt_invalidate(void *addr)
+void idt_invalidate(void)
 {
-       struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 };
+       static const struct desc_ptr idt = { .address = 0, .size = 0 };
 
        load_idt(&idt);
 }
index 64b00b0d7fe8065ebbe6525f026f43039d68dcda..1e34feebcd5de57a5fd56facd61ab47911efbc20 100644 (file)
@@ -232,7 +232,7 @@ void machine_kexec(struct kimage *image)
         * The gdt & idt are now invalid.
         * If you want to load them you must set up your own idt & gdt.
         */
-       idt_invalidate(phys_to_virt(0));
+       idt_invalidate();
        set_gdt(phys_to_virt(0), 0);
 
        /* now call it */
index b29657b76e3fa1ba6db1575f145ea393af540488..ebfb9110823267102d2277a2f076cafe99d7fd89 100644 (file)
@@ -669,7 +669,7 @@ static void native_machine_emergency_restart(void)
                        break;
 
                case BOOT_TRIPLE:
-                       idt_invalidate(NULL);
+                       idt_invalidate();
                        __asm__ __volatile__("int3");
 
                        /* We're probably dead after this, but... */