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 ED335185920; Thu, 17 Apr 2025 18:54:09 +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=1744916050; cv=none; b=BGmy3gLK9n1ZnV4Y3qwmWkygt0huxAfaa1+9do6DSKJFDQXMP6mNetVieoy+urwIJwD/4CcEPRFc0QVKZoBfpWRPktpOJNS9WZXxXXas5OiN7kN1dY740IfssEEcYkGDd5BtLntKAcRy7wGbTKEq7HQGIaKya11MQSQKPatkXOI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744916050; c=relaxed/simple; bh=xL+uAQC/PphQLNqixM0W5FjxPiZQUUkUMHiX02JzsrQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T2H/R5QK4kS11dAcEXV2B7byJQ+ftcLLar7AT2TuLAd65gAv3jvDn+aMwr5wiGsOGLzjzRj+relY+B3bZv/1EDAVwg0HUd97V20the0EqeScNnnoxNzw3UOLgmxt2CcIgBh/A1dgXdUPxy41tW3Pr5vJ/9WN8VbP93guyz0G+CA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=khy2uCK0; 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="khy2uCK0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6089AC4CEE4; Thu, 17 Apr 2025 18:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744916049; bh=xL+uAQC/PphQLNqixM0W5FjxPiZQUUkUMHiX02JzsrQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=khy2uCK0diUyZI0sAXqKXqXkkbT/EhI1XxRdC0tG2VtrPQef/Ykd4a6XvBven2boP LaZdaWqmHnvVoydXKuHoSElAJSEb17Niljf6gz/1E1WQWPWH54zwwruV/dy+eoSgsL d3v5dG5uBcRb7hR55Jkp/+3Qtvne9ZtGByKxWkwo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tom Lendacky , Herbert Xu Subject: [PATCH 6.12 327/393] crypto: ccp - Fix check for the primary ASP device Date: Thu, 17 Apr 2025 19:52:16 +0200 Message-ID: <20250417175120.763515726@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175107.546547190@linuxfoundation.org> References: <20250417175107.546547190@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-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 @@ -189,14 +189,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; }