Skip to contentSkip to conversation

x86: warn on native_io_delay() before DMI scan

PATCH RESEND In review Mateusz Jończyk 2 participants 2 messages Oct 17, 2021 – Dec 23, 2021 x86

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 x86: warn on native_io_delay() before DMI scan

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.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>

---

v2: make io_delay_dmi_scanned static

 arch/x86/kernel/io_delay.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/kernel/io_delay.c +5 -0
index fdb6506ceaaa..d6deca551a5c 100644
@@ -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)
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 7 lines · Mateusz Jończyk

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.

When/how does this happen?

io_delay_init() gets called pretty early in setup_arch()...

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette