mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mateusz Jończyk" <mat.jonczyk@o2.pl>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: "Mateusz Jończyk" <mat.jonczyk@o2.pl>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>
Subject: [PATCH RESEND v2] x86: warn on native_io_delay() before DMI scan
Date: Sun, 17 Oct 2021 21:25:58 +0200	[thread overview]
Message-ID: <20211017192558.266809-1-mat.jonczyk@o2.pl> (raw)

Writing to IO port 0x80 in native_io_delay() causes system lockups on
some laptops. This is handled by io_delay_init(), which scans DMI info
and changes io_delay_type on these laptops.

Therefore, calling native_io_delay() / outb_p() / inb_p() / etc. before
io_delay_init() may cause problems there and may constitute a kernel
bug. Warn if this happens.

Signed-off-by: Mateusz Jończyk <mat.jonczyk@o2.pl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
---

v2: make io_delay_dmi_scanned static

 arch/x86/kernel/io_delay.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
index fdb6506ceaaa..d6deca551a5c 100644
--- a/arch/x86/kernel/io_delay.c
+++ b/arch/x86/kernel/io_delay.c
@@ -29,6 +29,7 @@
 #endif
 
 int io_delay_type __read_mostly = DEFAULT_IO_DELAY_TYPE;
+static int io_delay_dmi_scanned __read_mostly;
 
 static int __initdata io_delay_override;
 
@@ -37,6 +38,8 @@ static int __initdata io_delay_override;
  */
 void native_io_delay(void)
 {
+	WARN_ON_ONCE(!io_delay_dmi_scanned);
+
 	switch (io_delay_type) {
 	default:
 	case IO_DELAY_TYPE_0X80:
@@ -123,6 +126,8 @@ void __init io_delay_init(void)
 {
 	if (!io_delay_override)
 		dmi_check_system(io_delay_0xed_port_dmi_table);
+
+	io_delay_dmi_scanned = 1;
 }
 
 static int __init io_delay_param(char *s)
-- 
2.25.1


             reply	other threads:[~2021-10-17 19:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-17 19:25 Mateusz Jończyk [this message]
2021-12-23 11:05 ` Borislav Petkov

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=20211017192558.266809-1-mat.jonczyk@o2.pl \
    --to=mat.jonczyk@o2.pl \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®