All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Andy Lutomirski <luto@kernel.org>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH v3 4/8] x86/idt: remove address argument to idt_invalidate()
Date: Wed, 19 May 2021 14:21:50 -0700	[thread overview]
Message-ID: <20210519212154.511983-5-hpa@zytor.com> (raw)
In-Reply-To: <20210519212154.511983-1-hpa@zytor.com>

From: "H. Peter Anvin (Intel)" <hpa@zytor.com>

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>
---
 arch/x86/include/asm/desc.h        | 2 +-
 arch/x86/kernel/idt.c              | 5 ++---
 arch/x86/kernel/machine_kexec_32.c | 2 +-
 arch/x86/kernel/reboot.c           | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index 476082a83d1c..b8429ae50b71 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -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 */
diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
index d552f177eca0..2779f5226dc2 100644
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -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);
 }
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
index 64b00b0d7fe8..1e34feebcd5d 100644
--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -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 */
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index b29657b76e3f..ebfb91108232 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -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... */
-- 
2.31.1


  parent reply	other threads:[~2021-05-19 21:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 21:21 [PATCH v3 0/8] x86/irq: trap and interrupt cleanups H. Peter Anvin
2021-05-19 21:21 ` [PATCH v3 1/8] x86/traps: add X86_NR_HW_TRAPS to <asm/trapnr.h> H. Peter Anvin
2021-05-19 22:17   ` Thomas Gleixner
2021-05-19 22:24     ` H. Peter Anvin
2021-05-20  7:10       ` Thomas Gleixner
2021-05-19 21:21 ` [PATCH v3 2/8] x86/irqvector: add NR_EXTERNAL_VECTORS and NR_SYSTEM_VECTORS H. Peter Anvin
2021-05-25  9:29   ` [tip: x86/irq] x86/irq: Add and use " tip-bot2 for H. Peter Anvin (Intel)
2021-05-19 21:21 ` [PATCH v3 3/8] x86/irq: remove unused vectors from <asm/irq_vectors.h> H. Peter Anvin
2021-05-25  9:29   ` [tip: x86/irq] x86/irq: Remove unused vectors defines tip-bot2 for H. Peter Anvin (Intel)
2021-05-19 21:21 ` H. Peter Anvin [this message]
2021-05-25  9:29   ` [tip: x86/irq] x86/idt: Remove address argument from idt_invalidate() tip-bot2 for H. Peter Anvin (Intel)
2021-05-19 21:21 ` [PATCH v3 5/8] x86/desc: add native_[ig]dt_invalidate() to <asm/desc.h> H. Peter Anvin
2021-05-25  9:29   ` [tip: x86/irq] x86: Add native_[ig]dt_invalidate() tip-bot2 for H. Peter Anvin (Intel)
2021-05-19 21:21 ` [PATCH v3 6/8] x86/kexec: set_[gi]dt() -> native_[gi]dt_invalidate() in machine_kexec_*.c H. Peter Anvin
2021-05-25  9:29   ` [tip: x86/irq] x86/kexec: Set_[gi]dt() " tip-bot2 for H. Peter Anvin (Intel)
2021-05-19 21:21 ` [PATCH v3 7/8] x86/irq: WARN_ONCE() if irq_move_cleanup is called on a pending interrupt H. Peter Anvin
2021-05-20 14:00   ` Thomas Gleixner
2021-05-19 21:21 ` [PATCH v3 8/8] x86/irq: merge and functionalize common code in DECLARE/DEFINE_IDTENTRY_* H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210519212154.511983-5-hpa@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.