From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793208220; b=MQbIiAStz6DPtrQV3q+/Xzs/uEnwOr+cMXTugI0C8vxxNiGY2TeDIEgT1zF9KVJu9R1b Kaa+/sMR3dhpl3sAGSizlIcUVUBaUXwA+CPvLLaSi7a7VwvRiTxS+RsDSLu9etiId70xr Ymte/rdwNpqd3EXzJS+CYWnsTFbyxaxcGnUGsSKqniKNu1MZl09AlVhw70AFOFTXm0E2I T1mB5+63CQUGaMW+saoetHW0RzT6JOKA7JgVdq0H2VwgYEo7OqyP1qY7UeRqfqZXTESq3 uSfea8d5UFGk73LtHdGhjM+jBqMt5o/RedsFp89VE18PDYCq4mFDHQCf3nTIVev5E1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793208220; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=/52aDS0CDVH7NLcae28xrYYNEU/Eqqg608YBj29X+k8=; b=EP0FIAx6w61HR4Qm8W3582KRGvS554N2c8OUgKDs1BLMO+AXzQYJoeKwhad+a34Qj3lJ dUtKaaWv8HvEIHWsmS89WtJG6SjrbDsFZQcoCMT62L0YvV0SJSr2n3uedNc/MusmSsAjN 1G3k1AXU4LPYAf9sdo607v22PMy/PAeGgQPk6sZfzxIB8tl29BV7kPJjT7bUQZobJLhwV mC5W8jEGW5chqPLxmwOAUrdu6P5pUOuVTe7IWqmZba7JVQLRxVnY2NxjNXNyUpREwYMQT D0X+DU0i/u15vf7YlNihf46Jm/QMha2q51iK6gV7w1XEftD+RRjX8jVh/BZpEttNkDw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b+jmV1Py; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F194606A31A; Wed, 28 Oct 2026 17:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b+jmV1Py Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF5F01F01825; Wed, 28 Oct 2026 17:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793208220; bh=/52aDS0CDVH7NLcae28xrYYNEU/Eqqg608YBj29X+k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b+jmV1PyiZ/YNrYV9DWeVcQQDWCd40gBifiCVVcyyqZuzKaClQCt/Q2NioiVCfkI1 lIKjGprhOuexChgMndugMcT+l/Ff6tnAq4+zDYu+DTToeYEjlgq86lDVR51o9SfFx6 be+Z8W+qtEGmjAr29ap/2YQF1OWwnOSngdvHt/Hc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Breno Leitao , Mathias Nyman , Sasha Levin Subject: [PATCH 5.10 042/516] usb: xhci: bail out of setup if the controller is inaccessible Date: Wed, 28 Oct 2026 17:53:14 +0100 Message-ID: <20261028170004.529049724@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170003.522232767@linuxfoundation.org> References: <20261028170003.522232767@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Breno Leitao [ Upstream commit 78203d5b54a40f0e36196ebf31c9c7a380fc8811 ] xhci_gen_setup() locates the operational registers using the capability length read from the very first register: xhci->op_regs = hcd->regs + HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)); If the controller is dead or has dropped off the bus, that read returns ~0, HC_LENGTH() truncates it to 0xff, and op_regs ends up 0xff bytes past the page-aligned MMIO base, i.e. unaligned. The first access through it, xhci_halt() -> xhci_handshake() reading op_regs->status, is then an unaligned readl() on device memory. arm64 faults on unaligned device accesses, so instead of xhci_handshake() catching the all-ones value and returning -ENODEV, setup oopses: xhci-pci-renesas 0005:08:00.0: Unable to change power state from D3cold to D0, device inaccessible xhci-pci-renesas 0005:08:00.0: xHCI Host Controller xhci-pci-renesas 0005:08:00.0: new USB bus registered, assigned bus number 1 Unable to handle kernel paging request at virtual address ffff80030a770103 ESR = 0x0000000096000021 FSC = 0x21: alignment fault Internal error: Oops: 0000000096000021 [#1] SMP pc : xhci_halt [xhci_hcd] Call trace: xhci_halt xhci_gen_setup xhci_pci_setup usb_add_hcd usb_hcd_pci_probe xhci_pci_common_probe xhci_pci_renesas_probe This was hit with a Renesas uPD720201 that failed to power up ("Unable to change power state from D3cold to D0, device inaccessible") yet still reached the HCD probe path. Read the capability register once, and if it reads back the all-ones value (as xhci_handshake() and xhci_reset() already test for), abort setup with -ENODEV before op_regs is derived from it. Reading it once also avoids re-reading a register that may change under a concurrent hot-removal. Fixes: 66d4eadd8d06 ("USB: xhci: BIOS handoff and HW initialization.") Cc: stable@vger.kernel.org Signed-off-by: Breno Leitao Signed-off-by: Mathias Nyman Link: https://patch.msgid.link/20260806142113.2436238-11-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman [ adapted the double hc_capbase register read via hcc_params/hci_version to use a single new local hc_capbase variable ] Signed-off-by: Sasha Levin --- drivers/usb/host/xhci.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 4d33130f1378a..4d3f13bd0313b 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5247,6 +5247,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) struct device *dev = hcd->self.sysdev; unsigned int minor_rev; int retval; + u32 hc_capbase; /* Accept arbitrarily long scatter-gather lists */ hcd->self.sg_tablesize = ~0; @@ -5313,16 +5314,19 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) mutex_init(&xhci->mutex); xhci->cap_regs = hcd->regs; - xhci->op_regs = hcd->regs + - HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)); + hc_capbase = readl(&xhci->cap_regs->hc_capbase); + if (hc_capbase == U32_MAX) { + xhci_warn(xhci, "Host controller not accessible, removed?\n"); + return -ENODEV; + } + xhci->op_regs = hcd->regs + HC_LENGTH(hc_capbase); xhci->run_regs = hcd->regs + (readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK); /* Cache read-only capability registers */ xhci->hcs_params1 = readl(&xhci->cap_regs->hcs_params1); xhci->hcs_params2 = readl(&xhci->cap_regs->hcs_params2); xhci->hcs_params3 = readl(&xhci->cap_regs->hcs_params3); - xhci->hcc_params = readl(&xhci->cap_regs->hc_capbase); - xhci->hci_version = HC_VERSION(xhci->hcc_params); + xhci->hci_version = HC_VERSION(hc_capbase); xhci->hcc_params = readl(&xhci->cap_regs->hcc_params); if (xhci->hci_version > 0x100) xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2); -- 2.53.0