Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2389617lqp; Sun, 24 Mar 2024 17:17:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUY8c6ztzRPMC2ww8iYsrt6ELUhgRJvYhNJEwNwc3FSij1a5NeTOHBE7IVejMesHOKuQGfNiQaod1CLg5B7NiadZMzF9zMNMZU5U3Y1Xw== X-Google-Smtp-Source: AGHT+IFtkfhtjmjFD4KRP+at/WlBDBPLTdCsg7wGnUJTe6NcNJywDjc69lPRnP7I/Z3AaRzvgOzW X-Received: by 2002:a37:ef13:0:b0:788:7299:e79a with SMTP id j19-20020a37ef13000000b007887299e79amr6314732qkk.28.1711325833461; Sun, 24 Mar 2024 17:17:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711325833; cv=pass; d=google.com; s=arc-20160816; b=WTK1Re1FVQ3f+APY9RmvPhqchgh/axEi5avzScaOx5notE/Xcaw//mmkZ7D/3LMlEf eG2UEghdDPQCQYwG7JcQLEwP5/iWucyGzkb1NNlYXD9tNvl37Eod6MHQxsRyenAtMpNU DhNqT+4QcBKxj8Dv6MU4lQLsglmJpmkYQMTiOPI5S+FMpoIU60KgI6AX+yQts69aAsCz V3KhvTQnGZmFihOWhFG428T4LM0KcvYyiv4Fcc4Ng8uRVCzrZcfToWHVP3w4Bshf0Lr6 5uGe4cjzPVZuy3Vm/I0YXHGsxAnSdgc3ztwr81dw8J4CNcqzZK0ToR3K9fXgZraRlP9S CqPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WOP6YCdHsl2ZX4hu3vo06LNARH299CrxGeXU1350Bhs=; fh=ig7dwuFvsxTtxoZearlLnzILMMeSYI8RQIBx93W9hkY=; b=bFRJd4/1rSXPGEab0hw1tqKiPfCNtBEVJ0h7L+AOKTzDzA9HHfh3zYua73MI4GurZV xFvkLSyuL5nYIq1B4bjqDFZ1et0wgt0iBREn5vu1tCpHAYpSowKb6vdhrWKXi0nQsj94 Yt9r1S42CnZxMQN72n+0yIKhsLRkZa4ZcfqcSpnrau4LdwH8o6y75LLygMrtO6tlhhN4 f4Gf5F4/slO8annvbpEK2ZK4+i8Uat5kbyWpGSuxk/PNJn4+jpkMZ7bbFBcjG/Jbl+6T zMq211EBgLnT5wdWlPog0R2sdNxEPHjCKQlF/oSPR31iDFxdqa8Gkr6vkVH5PwBPQWeP GriQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BC7nr8ZZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113357-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113357-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pi21-20020a05620a379500b0078a33ccec17si4434959qkn.577.2024.03.24.17.17.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:17:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113357-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BC7nr8ZZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113357-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113357-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 341CA1C224A6 for ; Mon, 25 Mar 2024 00:17:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DEFD6E612; Sun, 24 Mar 2024 22:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BC7nr8ZZ" 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 9427319B2AC; Sun, 24 Mar 2024 22:42:38 +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=1711320158; cv=none; b=alFbSIx31ExWqMrNu+t8inilRQyLrMY6sqYmRcBetgGETKVGSpSLagQQWtz3nHMk1bGgvxJ/akYLICI6LqxkGd36ph5CEm2ZIYm1PQpMzXOd8jUNTu761j0ywJhNj6vrKqT7JxXwrfXy+Z5n4eyrq6/8cluzZTCL+fjfgeIoq3g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320158; c=relaxed/simple; bh=tkufBR9raGvxU8c3aH3i6ldwN0hrm/x4DjtThUr85q8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WDsuHTSmuTkglf8Rf0A5wGCwdKBd5qWfNHRp3hwA4/fVObEEaMmdxuOistsuL7RGENKhuptccuE+I6UFHmv78jOhc5q3B0uzaOwf0U+PbxFoXomuglKqWHIyNVucovKJ7CPXR+WrP93YZhT7b8HP1jISZecx9Ocg7rHcDK5XFjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BC7nr8ZZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B61C7C433F1; Sun, 24 Mar 2024 22:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320158; bh=tkufBR9raGvxU8c3aH3i6ldwN0hrm/x4DjtThUr85q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BC7nr8ZZLZZF1OENkF7GCoQz5NSFIjVV5D0BIFhq0lyTwgotqaw/vUSk0Ou7Mv+UE wW/F2UMW75MaGBs/LwrnwQddr6TI9AMY4YMKDf5hfW9t3F1jHtOg1QRhry0lr4/ltq 8pDFdKaD72UhzU032P+Q1knJcfXQlZVReyWviXjYRIUd7tYJmkkh+vu5TvJJm8HY9u v+eZRYreWkVhOOe3VLPb6Zx/fxxo/p8vRH8RLbMxgMAiN0eOJq8Nr/3AGWQYwORufI SnPGAaNfgu1Kvkcb1hU/L54IKpaQhQ0zlY12N39wzd/0D4s8Dd9VDGAFvMsv/LmoxJ 5ppB2Ct9114ew== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mario Limonciello , Tim Van Patten , Herbert Xu , Sasha Levin Subject: [PATCH 6.8 466/715] crypto: ccp - Avoid discarding errors in psp_send_platform_access_msg() Date: Sun, 24 Mar 2024 18:30:45 -0400 Message-ID: <20240324223455.1342824-467-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Mario Limonciello [ Upstream commit 0e8fca2f12ceb77c3a6b6f210135031f264aa612 ] Errors can potentially occur in the "processing" of PSP commands or commands can be processed successfully but still return an error code in the header. This second case was being discarded because PSP communication worked but the command returned an error code in the payload header. Capture both cases and return them to the caller as -EIO for the caller to investigate. The caller can detect the latter by looking at `req->header->status`. Reported-and-tested-by: Tim Van Patten Fixes: 7ccc4f4e2e50 ("crypto: ccp - Add support for an interface for platform features") Signed-off-by: Mario Limonciello Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/ccp/platform-access.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c index 94367bc49e35b..1b8ed33897332 100644 --- a/drivers/crypto/ccp/platform-access.c +++ b/drivers/crypto/ccp/platform-access.c @@ -118,9 +118,16 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg, goto unlock; } - /* Store the status in request header for caller to investigate */ + /* + * Read status from PSP. If status is non-zero, it indicates an error + * occurred during "processing" of the command. + * If status is zero, it indicates the command was "processed" + * successfully, but the result of the command is in the payload. + * Return both cases to the caller as -EIO to investigate. + */ cmd_reg = ioread32(cmd); - req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); + if (FIELD_GET(PSP_CMDRESP_STS, cmd_reg)) + req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); if (req->header.status) { ret = -EIO; goto unlock; -- 2.43.0