From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACEAF47DD59 for ; Tue, 1 Sep 2026 11:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788261007; cv=none; b=Zkeg9zsXqiWj7NtJPwxb1VsvJbSiKyo5bILH3g1oG5gze66ZZ5D2LsPCpVEPZGYNfloAPHKhlgBJqVPGAx5bYWFpFbncXzeyRhIhG32omgUHCput6Et5XXoXaxsq/xtjjAqhyowY6ujDSi7FFoFzR44YCv1c82V9QdZ6V/R6Bqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788261007; c=relaxed/simple; bh=bkxMfoxlcJ/R4NL/DybS9horQ7zppnT9F1tNnkQNLrw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P+47gBA553QZNG4X3YoNgQvqecR955iPjdp/j7XQoog8M2OYF4fkFduhBzwGVJeCvFm4m2BJrR++FqXtQmiX/STDqBL82nN9/e0dNjacJEcNMXPbtihoTDq4gQj5GY04U/cCDEWyn8zHCbcHt/bhp3e91fNXkEJHyBsVkpULWi0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=od3A6UV5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="od3A6UV5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B0651F000E9; Tue, 1 Sep 2026 11:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788261006; bh=tKle8V9eN1oceC+NsL3dZjGOEscnEpbvlnV2UCrC9bM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=od3A6UV55TbSW2+S3uR6MmIyHi2ptgCXBN8/cJ43p7Dpy0x/EPfJnURXo1e5zdbDY 3kMjxA2SrZ02CJPrMy8htG+cPlvItYx4/lofkqL6J3K1l+sFZmmscUAFjPaU2HKITL A4QB1+8RM8VypCeZA0OAGf5/YA+Gc11lh0mCwXXIF1iUX6ciMAPkJZmUe2DXJiTKJi YOgmCBh1Utvw9KX/G0k96d22gGY7VNJpvWtmQ50s3ocSZGNibQ1oFwMblnI8LOd8qi BkgfV20il5XaCiNyk2H9TdCHN1GuoC1+KwOQCyHLfmRkLVlVRuCPalOcvP36T/0270 TBOXd7nY91Bdg== From: Sasha Levin To: stable@vger.kernel.org Cc: Breno Leitao , Mathias Nyman , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15.y] usb: xhci: bail out of setup if the controller is inaccessible Date: Tue, 1 Sep 2026 07:10:03 -0400 Message-ID: <20260901111003.4170946-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026083122-defog-carnival-2925@gregkh> References: <2026083122-defog-carnival-2925@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 823fe397bfb10..7394484f3e1f6 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5316,6 +5316,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; @@ -5384,16 +5385,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