From 716ccf0492610e4d9e4c9325626b6b217db5b462 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sun, 14 Apr 2019 22:05:47 -0400 Subject: [PATCH] XHCI: If the capability parameters are invalid, bail. This is the cause of #14557. It seems that OpenBSD does the same thing. I didn't read the spec yet to determine precisely what this means, so for now, just do what OpenBSD does and bail. This only seems to happen with a secondary XHCI controller on that device, so hopefully most USB ports will still work. --- src/add-ons/kernel/busses/usb/xhci.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index 3cff17ecc3..d6f28aef2b 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -271,12 +271,16 @@ XHCI::XHCI(pci_info *info, Stack *stack) TRACE_ALWAYS("structural parameters: 1:0x%08" B_PRIx32 " 2:0x%08" B_PRIx32 " 3:0x%08" B_PRIx32 "\n", ReadCapReg32(XHCI_HCSPARAMS1), ReadCapReg32(XHCI_HCSPARAMS2), ReadCapReg32(XHCI_HCSPARAMS3)); + uint32 cparams = ReadCapReg32(XHCI_HCCPARAMS); + if (cparams == 0xffffffff) + return; TRACE_ALWAYS("capability params: 0x%08" B_PRIx32 "\n", cparams); // if 64 bytes context structures, then 1 fContextSizeShift = HCC_CSZ(cparams); + // Assume ownership of the controller from the BIOS. uint32 eec = 0xffffffff; uint32 eecp = HCS0_XECP(cparams) << 2; for (; eecp != 0 && XECP_NEXT(eec); eecp += XECP_NEXT(eec) << 2) {