From patchwork Tue Mar 21 15:28:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 72918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:1828:b0:ab:1fc6:e12a with SMTP id l40csp2415383dyk; Tue, 21 Mar 2023 08:42:21 -0700 (PDT) X-Google-Smtp-Source: AK7set/jen8Jqi9D8T9rkB3zDnR21MlzkcYOMZ75RbH1f5497WJlGZXzXjMjBf+w1B2qKgD9hGEo X-Received: by 2002:a05:6a20:dc:b0:d8:ad79:e517 with SMTP id 28-20020a056a2000dc00b000d8ad79e517mr2116554pzh.30.1679413340805; Tue, 21 Mar 2023 08:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679413340; cv=none; d=google.com; s=arc-20160816; b=ROaVp1lGccRnAigb43G6WmQLnZKo0qaUUCLwsjJFlWasOnlczY8YTb8id5nfdiXNx9 eiK5kCDpeRYz6r29lEoajXFTWKfpfK9LDb3WlP9OJkEwrE58aAXJgKRSyK5ZAQY5uM2R nLygKOmdNRoqCNVXIsjFkZXbpuJkeyv4HyslQBCTvfMoaZ0HbZk0WZGWFU4w5f7qYF4d dMjIszTurjJuQT3XmxizhMAhezPLVFCR/+jlNGn97scYPFlALlM+bREGn5jy2Gf7psNf K+CwuNJp3ZgpEfv+DPaUE1ZUpD72q8TpvjGI1x85aEVApQUXI/LamdFKVL7LnmFf0ndY hLFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=irVXUrexhjwqxjsn3+Qqg46NzZR3tUhU2ORep83Lm4c=; b=VVaF7oKVRqwF3suFMSwWDfAqg3e5jQurTwNf2Js03/r3UWxfHkKIaT1RaN8MpRAR8z 2jEGIwGouY4N7shUhyBy5mxFAZ2mUzaLmvPa/ZATcHhHRu0zX55t033MKrbBakR8pIqp 2tXXvhdWdKxM5Td5ccawtbUZevMld/LilSbob9piHrNIpNOGvL9nSE5H7NeLiHo+6Ufc Nqi3wzVP6nSlZn+4l/y/KmzHMdNps/ClE4cqxKtl0eJV23vRMjX9t9CdDo7qw4OjSyUr iksoUPxR1XKbG93QFGHwQeLW0zAzZr8yxVtm77cqhNP414OQj07p5TaLcywdpBDU0xlW 34MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SfGMJxfQ; dkim=neutral (no key) header.i=@linutronix.de header.b=ID+O38O0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i71-20020a63874a000000b0050c10cfd6f8si13556501pge.198.2023.03.21.08.42.07; Tue, 21 Mar 2023 08:42:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SfGMJxfQ; dkim=neutral (no key) header.i=@linutronix.de header.b=ID+O38O0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231660AbjCUP3A (ORCPT + 99 others); Tue, 21 Mar 2023 11:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbjCUP2l (ORCPT ); Tue, 21 Mar 2023 11:28:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCDF9113C4; Tue, 21 Mar 2023 08:28:28 -0700 (PDT) Date: Tue, 21 Mar 2023 15:28:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679412507; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=irVXUrexhjwqxjsn3+Qqg46NzZR3tUhU2ORep83Lm4c=; b=SfGMJxfQKHYhrOVdxHg6wmpcX+M0y3AiHngHrmkIVuBcaLIP3p55fzKzzKP/EDOrdXMlKC qXXJC/cGaxH8XsRAlq1LoQu+YAa4qR/bBHxF9eVBZv8FtBIBkLaeHsAILxPszxKDYn3Z2F fORN1bBFilg1EkqeZXTG3mok0v7Gxo9iReP/5n/pL2HDkp3OaVK9HhNkCBEIhZvjjWzoIb +dKUFt5/9OuFlfkAxOvVnZyYAieDxAg5c5U7Yu5RE+Cl0/xqgqtzvixy4u6DfUTnLiIsh2 et78CL8jaC/xjZ/R/EYOIpTTm52xBl0d62V8Bmibz4zUczqvJLdeAevKjViA6Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679412507; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=irVXUrexhjwqxjsn3+Qqg46NzZR3tUhU2ORep83Lm4c=; b=ID+O38O07tAUDxidRPxV2+NGSDPjKHh1VcTUMeQ7AZzpMHYxXL7uGVN89M3Ie19P6b6YDe gLkoqjcPW3jPgXCQ== From: "tip-bot2 for Peter Gonda" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] crypto: ccp - Name -1 return value as SEV_RET_NO_FW_CALL Cc: Peter Gonda , Dionna Glaze , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221207010210.2563293-2-dionnaglaze@google.com> References: <20221207010210.2563293-2-dionnaglaze@google.com> MIME-Version: 1.0 Message-ID: <167941250712.5837.17612643714782256267.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751515222118704023?= X-GMAIL-MSGID: =?utf-8?q?1760992523293548705?= The following commit has been merged into the x86/sev branch of tip: Commit-ID: efb339a83368ab25de1a18c0fdff85e01c13a1ea Gitweb: https://git.kernel.org/tip/efb339a83368ab25de1a18c0fdff85e01c13a1ea Author: Peter Gonda AuthorDate: Tue, 07 Mar 2023 20:24:39 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 21 Mar 2023 11:37:32 +01:00 crypto: ccp - Name -1 return value as SEV_RET_NO_FW_CALL The PSP can return a "firmware error" code of -1 in circumstances where the PSP has not actually been called. To make this protocol unambiguous, name the value SEV_RET_NO_FW_CALL. [ bp: Massage a bit. ] Signed-off-by: Peter Gonda Signed-off-by: Dionna Glaze Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20221207010210.2563293-2-dionnaglaze@google.com --- Documentation/virt/coco/sev-guest.rst | 4 ++-- drivers/crypto/ccp/sev-dev.c | 8 +++++--- include/uapi/linux/psp-sev.h | 7 +++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Documentation/virt/coco/sev-guest.rst b/Documentation/virt/coco/sev-guest.rst index bf593e8..aa3e4c6 100644 --- a/Documentation/virt/coco/sev-guest.rst +++ b/Documentation/virt/coco/sev-guest.rst @@ -40,8 +40,8 @@ along with a description: The guest ioctl should be issued on a file descriptor of the /dev/sev-guest device. The ioctl accepts struct snp_user_guest_request. The input and output structure is specified through the req_data and resp_data field respectively. If the ioctl fails -to execute due to a firmware error, then fw_err code will be set otherwise the -fw_err will be set to 0x00000000000000ff. +to execute due to a firmware error, then fw_err code will be set. Otherwise, fw_err +will be set to 0x00000000ffffffff, i.e., the lower 32-bits are -1. The firmware checks that the message sequence counter is one greater than the guests message sequence counter. If guest driver fails to increment message diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index e2f2592..823c67a 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -444,10 +444,10 @@ static int __sev_init_ex_locked(int *error) static int __sev_platform_init_locked(int *error) { + int rc = 0, psp_ret = SEV_RET_NO_FW_CALL; struct psp_device *psp = psp_master; - struct sev_device *sev; - int rc = 0, psp_ret = -1; int (*init_function)(int *error); + struct sev_device *sev; if (!psp || !psp->sev_data) return -ENODEV; @@ -475,9 +475,11 @@ static int __sev_platform_init_locked(int *error) * initialization function should succeed by replacing the state * with a reset state. */ - dev_err(sev->dev, "SEV: retrying INIT command because of SECURE_DATA_INVALID error. Retrying once to reset PSP SEV state."); + dev_err(sev->dev, +"SEV: retrying INIT command because of SECURE_DATA_INVALID error. Retrying once to reset PSP SEV state."); rc = init_function(&psp_ret); } + if (error) *error = psp_ret; diff --git a/include/uapi/linux/psp-sev.h b/include/uapi/linux/psp-sev.h index 91b4c63..1c9da48 100644 --- a/include/uapi/linux/psp-sev.h +++ b/include/uapi/linux/psp-sev.h @@ -36,6 +36,13 @@ enum { * SEV Firmware status code */ typedef enum { + /* + * This error code is not in the SEV spec. Its purpose is to convey that + * there was an error that prevented the SEV firmware from being called. + * The SEV API error codes are 16 bits, so the -1 value will not overlap + * with possible values from the specification. + */ + SEV_RET_NO_FW_CALL = -1, SEV_RET_SUCCESS = 0, SEV_RET_INVALID_PLATFORM_STATE, SEV_RET_INVALID_GUEST_STATE,