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 87B3F22A81D; Tue, 29 Apr 2025 17:45:58 +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=1745948758; cv=none; b=E/MB3sHfDVmahut0mU8f0xuYuyFWAj8PV/udKEGf7qxza/PAdwmLBeTGZDq6Ms+k1vLIayMjgFBvLvkhk2fINNh2+LOUxJqxuz5fbSUCNHPqpu2w/7f/fblaN+TowYYR3ixQ08F+kuI4hT+Lq+CK/SOgoeAR+qoGsd0JMhy3oXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745948758; c=relaxed/simple; bh=f0LlR/xsFjsKcWXhlzB6OkER3l3GaNU1x6h9zgqDjJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eLYGZzXTYPIuferpkO/Lg8zTPMxnMyeRF5Vrm5Y5q6yHEdF4tzXH8UFcCq2pZ1mHaCy9wBhWaeYwpJiXwGegXef8SnRye5cOT5Nf7Vq0MQT45j4R80j+4bzKa/m0lUa5rL/K8sVrh3qwe1vzskHqr5wvcGWgNmoIW/hBazUKCXo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zwpjAF4x; 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="zwpjAF4x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C901C4CEE3; Tue, 29 Apr 2025 17:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745948758; bh=f0LlR/xsFjsKcWXhlzB6OkER3l3GaNU1x6h9zgqDjJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwpjAF4xE+5/SRX4DeC6IRWPbZXcWJyBOdYH5ZxMSRYsoCfl+ssq0qCiowYjZCvru jcIRxeaMFYSxQQGQxyuLbFcNTqZARccOdOMLOHm1b86PppNrjRx5N4c8dhrTXXwHQ+ hEoS7iGQjgjg72r/VGgFhlM3H6pf7oijF6XjNsFI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tom Lendacky , Herbert Xu Subject: [PATCH 5.15 104/373] crypto: ccp - Fix check for the primary ASP device Date: Tue, 29 Apr 2025 18:39:41 +0200 Message-ID: <20250429161127.434171508@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161123.119104857@linuxfoundation.org> References: <20250429161123.119104857@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.15-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; }