lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YcCV0TECWE31fYV7@hirez.programming.kicks-ass.net>
Date:   Mon, 20 Dec 2021 15:40:17 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     Mathias Nyman <mathias.nyman@...ux.intel.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Lu Baolu <baolu.lu@...ux.intel.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
        Chunfeng Yun <chunfeng.yun@...iatek.com>
Subject: Re: earlyprintk=xdbc seems broken

On Fri, Dec 17, 2021 at 04:19:20PM +0100, Greg KH wrote:
> On Fri, Dec 17, 2021 at 02:55:07PM +0100, Peter Zijlstra wrote:
> > On Fri, Dec 17, 2021 at 01:01:43PM +0200, Mathias Nyman wrote:
> > > I can reproduce this.
> > > Looks like problems started when driver converted to readl_poll_timeout_atomic() in:
> > > 
> > > 796eed4b2342 usb: early: convert to readl_poll_timeout_atomic()
> > 
> > I can confirm, reverting that solves the boot hang, things aren't quite
> > working for me though.
> > 
> > > Seems to hang when read_poll_timeout_atomic() calls ktime_* functions.
> > > Maybe  it's too early for ktime.
> > 
> > It certainly is, using ktime for delay loops sounds daft to me anyhow.
> 
> It was a "find a pattern and replace it with a function call" type of
> cleanup series.  It's obviously wrong, I will go revert it now.

796eed4b2342 is definitely wrong, but instead of a straight up revert,
perhaps do something like this ?

---
Subject: usb: early: Revert from readl_poll_timeout_atomic()

Reverts commit 796eed4b2342 ("usb: early: convert to
readl_poll_timeout_atomic()") and puts in a comment to avoid the same
happening again.

Specifically that commit is wrong because readl_poll_timeout_atomic()
relies on ktime() working while this earlyprintk driver should be usable
long before that.

Fixes: 796eed4b2342 ("usb: early: convert to readl_poll_timeout_atomic()")
Debugged-by: Mathias Nyman <mathias.nyman@...ux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radaed.org>
---
 drivers/usb/early/xhci-dbc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 933d77ad0a64..ff279a830653 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -14,7 +14,6 @@
 #include <linux/pci_ids.h>
 #include <linux/memblock.h>
 #include <linux/io.h>
-#include <linux/iopoll.h>
 #include <asm/pci-direct.h>
 #include <asm/fixmap.h>
 #include <linux/bcd.h>
@@ -136,9 +135,20 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait, int delay)
 {
 	u32 result;
 
-	return readl_poll_timeout_atomic(ptr, result,
-					 ((result & mask) == done),
-					 delay, wait);
+	/*
+	 * This must not be readl_poll_timeout_atomic(), as this is used
+	 * *early*, before ktime lives.
+	 */
+	do {
+		result = readl(ptr);
+		result &= mask;
+		if (result == done)
+			return 0;
+		udelay(delay);
+		wait -= delay;
+	} while (wait > 0);
+
+	return -ETIMEDOUT;
 }
 
 static void __init xdbc_bios_handoff(void)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ