From patchwork Mon Mar 13 12:58:11 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: 68832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1179590wrd; Mon, 13 Mar 2023 06:16:50 -0700 (PDT) X-Google-Smtp-Source: AK7set9uEhmA+8BFougXIxpFrsqjG8sADgMHrAXwnDiBe2qEoIg2ZmP3ruezacyt3A0EWOlqz1KR X-Received: by 2002:a05:6a20:1bdd:b0:cc:a0fd:67bd with SMTP id cv29-20020a056a201bdd00b000cca0fd67bdmr33021130pzb.14.1678713409787; Mon, 13 Mar 2023 06:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678713409; cv=none; d=google.com; s=arc-20160816; b=ZauRUUpvnpRM7RqN8VFbQsSrFO1GpmVBF5rd3q//5XZjSwSuxNV1gQH9wi9VaVL+wv 3vWwQCZDNKFIvE9NN471gMtdK7d2RNJhPyfbRn+z2z/pX/TlNRZX3gBOq8zECx8noML8 EG8WURPiw4C7neO+RmSuGH/rX+9iMwjTp2wr0R4Jze0+1oVyg3JUJdv7fxAppqERLTcA Lf5cFpz81Pmkldb+vaThe6BvJFzZNmRbPethZ7PGH2YPKZZbwY5J6BHyr9oeJ8Tbpdrw 9n/7/whBKKd6s2eUdCZa4vQU5eOcAcK9PZi79MBmgzVSf/hJuBaqEea85iAhGMlqkX0r 0Haw== 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=lbf4SQk6dTRJEfYxdlPAqQeFRGUttK8k0Iht4g9Hq6M=; b=DVRDNIdBq+fE5xtJuIw5HthrV3WnlWR2BDvvxeJ4AAcU4JWxX1i3xW6wKkeEgcNhHN 3z/vjgwpDLbmmx3UXuDfA6D27oUpT2zuN1AqmzquegQSvNthNVXZpkZroZhzJQszrWUQ sN5wUiUrPyPdgifSnhIjIGFyk3mInhvYXj/UcAHem9vANa1fSBUt9N+biW1qJyl+xuuh dIG7rw8drUSqQmqXLeVD3rOBMBtgvAPLpMvCX+tgs1kUkaj0N/nHKuiTastRQWL8nR7K 5oCCZQeJeuVLtJ2Kri5WBMrZtl+NroIIstdhJVuckyZeuyuGs/XdbLU4bpyIHuWKqDmt naQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gpNF13ER; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8aIzzVqt; 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 s11-20020a65644b000000b005030925d30asi6636130pgv.347.2023.03.13.06.16.11; Mon, 13 Mar 2023 06:16:49 -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=gpNF13ER; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8aIzzVqt; 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 S230388AbjCMM6d (ORCPT + 99 others); Mon, 13 Mar 2023 08:58:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjCMM6V (ORCPT ); Mon, 13 Mar 2023 08:58:21 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96EDC2D7E; Mon, 13 Mar 2023 05:58:16 -0700 (PDT) Date: Mon, 13 Mar 2023 12:58:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1678712291; 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=lbf4SQk6dTRJEfYxdlPAqQeFRGUttK8k0Iht4g9Hq6M=; b=gpNF13ER/GBxxqZpCaBd7xR7e6gR/M33dOjQkmltWTvwkLfk7xGXuh9vtAYsVb/t2ey4rI ywOWFrzi2LHVomkiuH5Khz7wvnSpNi/O87oPkJtSo9WGUyeywsGqvsFTHj4YG9SGGSeBnO euG8ykVe/eyuzXyovjw0eAdDF0SyOvHMW4zwAvZYp0HHa3pHtH2FsXr3hx/4cf30iSeqyE WWn3q3uDiBbdxRNqm6HbQtE3MmMQAFw5Wh5xatIKLQf6m3F4casp3SX5W3+qCCZOvpaHgs EGwzbwf7U80RAyLnZ6ZrMI57ehboOy4phWnfboBdAjVZ7IAa+HoX8Uu5r83FDw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1678712291; 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=lbf4SQk6dTRJEfYxdlPAqQeFRGUttK8k0Iht4g9Hq6M=; b=8aIzzVqtFsUN5zvGBKCH3+w1SjgH6We+H7XwR+IG1S5UkMe8fe1UDIDItl/QZ4FoSdmtI+ O7fMOPawVviZWEAQ== 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: Check SEV_SNP attribute at probe time Cc: "Borislav Petkov (AMD)" , Tom Lendacky , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230307192449.24732-3-bp@alien8.de> References: <20230307192449.24732-3-bp@alien8.de> MIME-Version: 1.0 Message-ID: <167871229135.5837.1913962659795610718.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?1759740272161422714?= X-GMAIL-MSGID: =?utf-8?q?1760258592477365967?= The following commit has been merged into the x86/urgent branch of tip: Commit-ID: d6fd48eff7506bb866a54e40369df8899f2078a9 Gitweb: https://git.kernel.org/tip/d6fd48eff7506bb866a54e40369df8899f2078a9 Author: Borislav Petkov (AMD) AuthorDate: Wed, 15 Feb 2023 11:01:42 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 13 Mar 2023 11:20:20 +01:00 virt/coco/sev-guest: Check SEV_SNP attribute at probe time No need to check it on every ioctl. And yes, this is a common SEV driver but it does only SNP-specific operations currently. This can be revisited later, when more use cases appear. No functional changes. Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky Link: https://lore.kernel.org/r/20230307192449.24732-3-bp@alien8.de --- arch/x86/kernel/sev.c | 3 --- drivers/virt/coco/sev-guest/sev-guest.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c index 679026a..c644c34 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -2183,9 +2183,6 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned struct ghcb *ghcb; int ret; - if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) - return -ENODEV; - if (!fw_err) return -EINVAL; diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c index 7b4e900..ed5d6ae 100644 --- a/drivers/virt/coco/sev-guest/sev-guest.c +++ b/drivers/virt/coco/sev-guest/sev-guest.c @@ -703,6 +703,9 @@ static int __init sev_guest_probe(struct platform_device *pdev) void __iomem *mapping; int ret; + if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) + return -ENODEV; + if (!dev->platform_data) return -ENODEV;