From patchwork Mon Mar 13 12:58:09 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: 68823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1168948wrd; Mon, 13 Mar 2023 06:00:06 -0700 (PDT) X-Google-Smtp-Source: AK7set+m1Jv+1SoaI4jbn357HdeBLbjSnk7YEFsZtJPf2YJMXObssmntUWGJDfKe12lVino1ISzU X-Received: by 2002:a05:6a20:729d:b0:cc:a5d4:c334 with SMTP id o29-20020a056a20729d00b000cca5d4c334mr37516406pzk.10.1678712406342; Mon, 13 Mar 2023 06:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678712406; cv=none; d=google.com; s=arc-20160816; b=WCvEFe6b7QLM5If1VG/r3eYczkWr7a3/MLZESGzQAZYCF4hEATycR8HZXRl12DpYfn ryv08+VtKDQKqOLI4Uxz5W8t9Je9lVo5KdBIsNruN2iG/nZWmrodepJ5VSFIWeDmr21k Lhn2z3jVIPcJHfN13DH+eNVIpVorJTlM7pMWhzOclUgratyhtgoydWUd24CI9fkPt4K7 OKuOQ/Aro5vYca9KQOZO/voQHdZ0suh52JdilrNVZdkYezrW4onP+cmwqv5WNq9Jem6J BO+HVc8aqSp11pmcON2ItjWRbTLE6Bjhjj63Nu0CxH5yNm7a881Os/aYa3fTaOwQ72kN Y+5w== 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=aH1/H5EzgBWv6vAtpMFm5z5LgCHFS3c/CqOtnbfEy/A=; b=x4vjNLzdnll+NYcEn2ZhuEgOt2kXRk4fFhZzjzgCrrT84O+7Pf1ZvAzOHIn82ehZej bgA2CaR2Yt2pFL5hpxOpesb2gboKyuTe5C0pp//WxN8XmuVzmWN2j6G0+dX7iBg4lBn3 B33r/KP0TWD2eTDC2O20QcJpy8KqPZZi6UTZFnVNwqzX5ULJj53mNOk9hhfCjHt9mxwd J94+vAC8gXnI5tvQWr2nfen/TXlOSsKcmb9skiySoQgrUfA7AjewbEw2c0x+HOBF0ovr GtV0u9Ma96MZltlxRoOkc9lzXFiiMDt10spjP7guPcf0TIrngEvnV32ab/66MLwkFwp/ O/hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4rBZVdn3; dkim=neutral (no key) header.i=@linutronix.de; 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 4-20020a630304000000b004fbd7827010si6650979pgd.263.2023.03.13.05.59.51; Mon, 13 Mar 2023 06:00:06 -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=4rBZVdn3; dkim=neutral (no key) header.i=@linutronix.de; 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 S230350AbjCMM6X (ORCPT + 99 others); Mon, 13 Mar 2023 08:58:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbjCMM6P (ORCPT ); Mon, 13 Mar 2023 08:58:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D668B455; Mon, 13 Mar 2023 05:58:12 -0700 (PDT) Date: Mon, 13 Mar 2023 12:58:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1678712290; 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=aH1/H5EzgBWv6vAtpMFm5z5LgCHFS3c/CqOtnbfEy/A=; b=4rBZVdn3BcCbOQDw8wyR5GC0RQbNrdeBzLUgG8Rj58onr6fsq/W4D4l21gr5AlIilDAaU4 446wLz9AzxYej8v+n4zjC47ZbxIcTlkqQgu0CZ9Llf4yYN/z2KdAyuhzlNveMTFC3Uvc7y igzdGOM+PetSARCmGL3/FH5twBLPsZOxIQCSRJhPcfwLXGUeapM7WY+kpB6zDOozs9ontx JYqpeHi012IAlfZPGzFcc0iQU5DLzTYcNZsq6MzA0qX+dXORslzm81rRUXbTW3Zg+0COeD m3A4SJAXBK8MTaMuZkRuMJp8KLuSxJN0sN3Czj2Qbq3fZfU0G0mtnH0WJ7q/4Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1678712290; 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=aH1/H5EzgBWv6vAtpMFm5z5LgCHFS3c/CqOtnbfEy/A=; b=E42hB6NQnxLBQlvhbq6qvvRH3m3X1M2Vro0MwoFib0Ev6J+9Yq76OD2zdTciLFVfJRW/Dw 0LpL7zjIgEm8GdBA== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] virt/coco/sev-guest: Convert the sw_exit_info_2 checking to a switch-case Cc: "Borislav Petkov (AMD)" , Tom Lendacky , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230307192449.24732-8-bp@alien8.de> References: <20230307192449.24732-8-bp@alien8.de> MIME-Version: 1.0 Message-ID: <167871228994.5837.5974944076233094676.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 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?1759740303378230388?= X-GMAIL-MSGID: =?utf-8?q?1760257539986970109?= The following commit has been merged into the x86/urgent branch of tip: Commit-ID: fa4ae42cc60a7dea30e8f2db444b808d80862345 Gitweb: https://git.kernel.org/tip/fa4ae42cc60a7dea30e8f2db444b808d80862345 Author: Borislav Petkov (AMD) AuthorDate: Thu, 16 Feb 2023 10:50:11 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 13 Mar 2023 12:55:34 +01:00 virt/coco/sev-guest: Convert the sw_exit_info_2 checking to a switch-case snp_issue_guest_request() checks the value returned by the hypervisor in sw_exit_info_2 and returns a different error depending on it. Convert those checks into a switch-case to make it more readable when more error values are going to be checked in the future. No functional changes. Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky Link: https://lore.kernel.org/r/20230307192449.24732-8-bp@alien8.de --- arch/x86/kernel/sev.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c index 6a3e142..d67884f 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -2210,15 +2210,21 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned goto e_put; *fw_err = ghcb->save.sw_exit_info_2; - if (ghcb->save.sw_exit_info_2) { + switch (*fw_err) { + case 0: + break; + + case SNP_GUEST_REQ_INVALID_LEN: /* Number of expected pages are returned in RBX */ - if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST && - ghcb->save.sw_exit_info_2 == SNP_GUEST_REQ_INVALID_LEN) { + if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST) { input->data_npages = ghcb_get_rbx(ghcb); ret = -ENOSPC; - } else { - ret = -EIO; + break; } + fallthrough; + default: + ret = -EIO; + break; } e_put: