Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2623481pxb; Sun, 17 Oct 2021 20:48:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVyh/tYaeDpLOHLGIv7ee5DtU+aZHqNpUh1/fkV/qHcYLAnXxKBLGZICRqsmggwCWl1isO X-Received: by 2002:a17:90a:e7ca:: with SMTP id kb10mr44603343pjb.139.1634528842970; Sun, 17 Oct 2021 20:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528842; cv=none; d=google.com; s=arc-20160816; b=o687WDsBG252jmT31+rKIk1iIYdCt2baFHNVmgSfFu1DwHdGykr/CThIi7MKNgL3Zh /5TLI3nLblqMJ40npCg8FITyys++XVdmF+adaccSoul5wt9cPnxSJW672/KVcqvuv4RC JwDQAXyZFHUw5IHvyc+ejSpO0MtFn1iDBvpdpo2xSD+l2BU9Nt6zv+8T1v07cTtoUv1O J1vbmCndGo7MXAE19IjAHymg9gFX5+1uYCGruJMGQ4wIexyQQhZwtyWgXURmikpZDkGz nDZWkxXRyl4mByv43D/pjpSpKBeD5g1YMpBhm7zDI5IpiZJFj0eixM6CcLGbT/rPRZLX c0HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=K4x9QhXuKOZkWxOZ1tfZPtZ3zxAXUZxqrJhTrhSSoaM=; b=CcGJ+b4d+eJGXHmcj1ZAQkpBRbdXzqbk5iBQVxfcZvTMHYKi7dhRLrB1MpjGPtqCiF f7fnlcSySn45y7SS/JoKSlJF83jDHLISCsQkNDObjcCV58WUaYpgZ9lsYIW3wFM1bZeK dj0Zeu0WDoVYZsx3xiSzN66cdypMFWh4bqY1UbmUePhiNQXppfgqNQEH30VrDboQrs/E Efo+3ERFGjf3tFGJeO+8+ZoP0ZwbMNLSN/LxDM8G0Da/snWkxlz16tGcVRYbjRcqQWJN egr05mwYdya5uARB38zunBv2SEh9q28w4i7lr8Bxi9Yu1K3Dxa11zN4tbEuqU1cBTJts EaPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@o2.pl header.s=1024a header.b=XqGREuta; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=o2.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 20si12439891pgo.301.2021.10.17.20.47.10; Sun, 17 Oct 2021 20:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@o2.pl header.s=1024a header.b=XqGREuta; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=o2.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238401AbhJQT2a (ORCPT + 98 others); Sun, 17 Oct 2021 15:28:30 -0400 Received: from mx-out.tlen.pl ([193.222.135.158]:38792 "EHLO mx-out.tlen.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344499AbhJQT2a (ORCPT ); Sun, 17 Oct 2021 15:28:30 -0400 Received: (wp-smtpd smtp.tlen.pl 16948 invoked from network); 17 Oct 2021 21:26:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1634498777; bh=K4x9QhXuKOZkWxOZ1tfZPtZ3zxAXUZxqrJhTrhSSoaM=; h=From:To:Cc:Subject; b=XqGREuta1s0qalf2wmlNmSmRBkx9QEkpQGw1pBKAKrOUnhGwfQLLIqrZmh/jxW4Ug bTFGlybuXKKd5dI4ZpN57/oKiaLMWpfvpwKsThSytV1q21BGNRIhyWylSQNtvac4Aa 8JT4UIgqgyIC7gOxfNOpgdpgFZcSDpGfFLTnmchs= Received: from aaet142.neoplus.adsl.tpnet.pl (HELO localhost.localdomain) (mat.jonczyk@o2.pl@[83.4.123.142]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with SMTP for ; 17 Oct 2021 21:26:17 +0200 From: =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov Subject: [PATCH RESEND v2] x86: warn on native_io_delay() before DMI scan Date: Sun, 17 Oct 2021 21:25:58 +0200 Message-Id: <20211017192558.266809-1-mat.jonczyk@o2.pl> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-WP-MailID: 14a9d553ccf097e6b09d7531a967c5c6 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000000 [AQO0] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov --- 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