From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7FC2E24113A; Tue, 29 Apr 2025 16:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745945309; cv=none; b=lxXCig9+EkJE5RsOK8caB0SIcBZDxjMsnHCeurwhu0daMZtyoeHFebaV1JIECmbcdoKXfIlOtFTHI3WXWKVKv2AL9UIcuzoOAiG2wN27QFbWsd1KwijWkBt0IcLKBi+9QAUL2xsqp/T/R9gQgEVK2cr5AaqntXBPZlnPQ/ZTrkg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745945309; c=relaxed/simple; bh=N92rpo51WZ/QI1B0mtfQ93SAxvSYGFQSVqja7vuPC/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A9XCBqZ93NyAJChry5Nc84xadb3OvxWBZatbbGNTzQKjO5t8KO+Yayh1qSM3iOEqnhyOlEZumLs7mzBq8T6tjKFX/7/PheNK/T5C5bvQyZEwDB3ehPc1wztvR/uSSRggUtkjeQxR33lmcGlL933wE63hcHBFxfjszCg6+5GVKxg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=h/X6W2kY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="h/X6W2kY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06E4BC4CEE3; Tue, 29 Apr 2025 16:48:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745945309; bh=N92rpo51WZ/QI1B0mtfQ93SAxvSYGFQSVqja7vuPC/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/X6W2kYZu0GxPIAeFg0QL+1N6CMuP+TIQZZ+wsJOQ3iG8OIXRCOyizJAQOzpbdaF s8ZhU2bpO2XW7zTdg8pqU304j8aDx4e7sp4/86uy5CyDNDaSL36ZIXbKbsNFYpa+mQ aRyDZluvDeYjcgbmeVa7+WKzoCZTSILUW+QDyoMM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tom Lendacky , Herbert Xu Subject: [PATCH 5.4 070/179] crypto: ccp - Fix check for the primary ASP device Date: Tue, 29 Apr 2025 18:40:11 +0200 Message-ID: <20250429161052.250437115@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161049.383278312@linuxfoundation.org> References: <20250429161049.383278312@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tom Lendacky commit 07bb097b92b987db518e72525b515d77904e966e upstream. Currently, the ASP primary device check does not have support for PCI domains, and, as a result, when the system is configured with PCI domains (PCI segments) the wrong device can be selected as primary. This results in commands submitted to the device timing out and failing. The device check also relies on specific device and function assignments that may not hold in the future. Fix the primary ASP device check to include support for PCI domains and to perform proper checking of the Bus/Device/Function positions. Fixes: 2a6170dfe755 ("crypto: ccp: Add Platform Security Processor (PSP) device support") Cc: stable@vger.kernel.org Signed-off-by: Tom Lendacky Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccp/sp-pci.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -118,14 +118,17 @@ static bool sp_pci_is_master(struct sp_d pdev_new = to_pci_dev(dev_new); pdev_cur = to_pci_dev(dev_cur); - if (pdev_new->bus->number < pdev_cur->bus->number) - return true; + if (pci_domain_nr(pdev_new->bus) != pci_domain_nr(pdev_cur->bus)) + return pci_domain_nr(pdev_new->bus) < pci_domain_nr(pdev_cur->bus); - if (PCI_SLOT(pdev_new->devfn) < PCI_SLOT(pdev_cur->devfn)) - return true; + if (pdev_new->bus->number != pdev_cur->bus->number) + return pdev_new->bus->number < pdev_cur->bus->number; - if (PCI_FUNC(pdev_new->devfn) < PCI_FUNC(pdev_cur->devfn)) - return true; + if (PCI_SLOT(pdev_new->devfn) != PCI_SLOT(pdev_cur->devfn)) + return PCI_SLOT(pdev_new->devfn) < PCI_SLOT(pdev_cur->devfn); + + if (PCI_FUNC(pdev_new->devfn) != PCI_FUNC(pdev_cur->devfn)) + return PCI_FUNC(pdev_new->devfn) < PCI_FUNC(pdev_cur->devfn); return false; }