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=1793210490; b=NimXMe4S9eIuJwtBpN7gshQy3cL65lU+99NDj072Gx3/Q5rLB4P+PM//e0+b7qXvGCrA rud3Xzg0mbZmSY5qXNZdySce8P+hUoblemnV3BRMCB/fZ7Qn1HNjwrsPln7MWUxPACNLr u03q3uzGfn/B67jYFWaDq3JMEbQndHMsnZfnPuhBcaAo32nidBe/VlDiybqz5nnYyZXUC L0RcLsDeY7UIolGzB19zGKT37mMNP4gtsPpOxrNV/abm9wxmy5SMwcq4CEUbsSAURIonU uiPR6/BqPsDGszgYCTbIcFfaS6RDJ9b97+CqFEGzB9KMm28/5pk/dzOzg+3BOwE7tEQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793210490; 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=OeA7B/J9SPiBMx6scAL8JyfX5Jh525OsZ25optLjmck=; b=Qy7eozvOAhJDLz7llXs3aKm4RnDAAA8WcEpJ9IWgcC7teDx7CZeQZtJxoajh0ZS6d88M av1DBXE1nZJNQMMCxHcuRWVU/2EDnYioQLMfuRs+PmSlZmbqUbhkv3S6aUy8y2lN/LKJ/ gmJikJtYOjmZlKP2suwpgSnREkePWM1dPqZwNOjP3X0hd1zXVvlZooRvKr8/VBzFSVmjP PEUCpguFr7lU59IERBT53kUjbYsx+Bhy+RsSbB2P2iQctnoApk6fv5sB8W8RJAoeRCryz Aq8LojyVy4P4Z/+bSkGXYmfraJUdN0iaCTkH5dn4YlYAFDEkEj6a83DnDCNPKR7I50A== 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=1ybPucv1; 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 C6AF3606A326; Wed, 28 Oct 2026 18:01:29 +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=1ybPucv1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB93B1F01825; Wed, 28 Oct 2026 18:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793210489; bh=OeA7B/J9SPiBMx6scAL8JyfX5Jh525OsZ25optLjmck=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1ybPucv1/Dcld9R0xk1nZI8OR5AP5SLz0V67BVkDpdkJDZ/ETDsub0VyONtwNFdn/ uB3PCxum4ChgiZnIU6QrnVkb3ufvn0FBpSGukgz+DA7NvDPbXk2D2OCV27nGdaG4cY pDiP2FPgxj4VUvRwMbxDLgAj2ccvnk27IoFhAQ3g= 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.15 045/571] usb: xhci: bail out of setup if the controller is inaccessible Date: Wed, 28 Oct 2026 17:53:12 +0100 Message-ID: <20261028170009.097072384@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170008.009143722@linuxfoundation.org> References: <20261028170008.009143722@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.15-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 fee939389a30b..36b6dc304e79e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5320,6 +5320,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; @@ -5388,16 +5389,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