Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp67306lqd; Tue, 23 Apr 2024 15:05:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkZVld/KjISlfc5nZw0gw0p/NL+QMg1CmWa+PqT3CyBmM8rMildi4Sfc1rXo83L8jXeqP4WYpUlJfqPBvQRKRVcozhTTYZOLDbDyNYpg== X-Google-Smtp-Source: AGHT+IEKjjkcOyfRR1jw2DOL9joemYr5KRdbTbhFz3nSFqk3KWA7zizRpUGdczfWdif2yv2HleAp X-Received: by 2002:a05:6a20:a09f:b0:1a3:dc61:926a with SMTP id r31-20020a056a20a09f00b001a3dc61926amr546523pzj.54.1713909903674; Tue, 23 Apr 2024 15:05:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713909903; cv=pass; d=google.com; s=arc-20160816; b=nkk+wIuqLO4ICuOjH8cLhY6ONQFVqLPzNXs/aw94lA/0ofv4zfCN4TX8tSQugOFe1u vhWMFjui/2F3BiKNp2ofkqHTPzAWY0I22WFqluElC6L44dSPeTnrpg711W7NbBBTQOJp 49LY+gATAcLtSgP4XXJ15c5CDa2Yg1BNhEQZdssVSUuNGuvYXg3F9C29Nitz4K8F8HTD uE9Oq/Fj4VwsUJN3F/dKLWwmtVFPBlzUBhewfeBnukwgmCJNrswl5tkalzJ+8uGULTRN Y8+0OZn7rNuAEPryBgIazHcy8ACeFKc/2DTTmckcMkSNUDU5dAbEqHZK6OUS9ztteVkx KzZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=27uuS8XnVeMLCUUMTCLWxfCa12Qrf9Y7FaKiKv4socc=; fh=ZrsLvwGit1W+Bgpmm47UXsrWP74hnR5yiEKrvJFAn2I=; b=1FejLNmr8oJ6cL53oDiD9mKWnHIb+/493f6ESVIoPs+sLvUHVPF2pJIPxfJ2GtjTmI bYSPiQyz3xg+UYDMCUZH6XtAzxPaQBFF+YssTLflLc5RIXSA6AyElHbg3zbBPN1SmXuJ IRDN5cQQ+GYjmIO+0g/SR898A2aX7qv1Bo8puAJHQKL8711F3kmZqNYhAPnZyDsXVy+b RfqNghytH9+eMNMND60y/NQrRCI7CGI3poNNs06q25nB0kN7iEd3Jgm2iK7sBMLn/eD8 bWu2/w3nDrB8NodkYUiDDslbL1KoSxN5gU6RcYW6uBtos9DVfmBJJrwXcVE/rK3VzI3D hKng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N64hL5x3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-3810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3810-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s15-20020a632c0f000000b005fd81051902si5529830pgs.464.2024.04.23.15.05.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:05:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N64hL5x3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-3810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3810-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2FBF0B23C39 for ; Tue, 23 Apr 2024 21:36:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E873014388A; Tue, 23 Apr 2024 21:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N64hL5x3" X-Original-To: linux-crypto@vger.kernel.org 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 9559020B3E; Tue, 23 Apr 2024 21:36:28 +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=1713908188; cv=none; b=qRpV4cSreDPUruTIcr+3HXowL2KHmV3O7u3dUpw+Awpc6ZJbR8piFT1vsbmlQeRUGWjUZIZLX8taasuuIdz7t4qH26H4wkMfM+ai/R4SkpsPMuz2K0nQV6kuQrVsKAUG/gYQByfZaB8egkJnRAAE5zRw0BVXJPf0VTxkW1Ckq0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713908188; c=relaxed/simple; bh=kRU/X/dR1S85QfdEA379AVH9Oh6pbj0vz6VEE2p37BI=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=hR6EpbTInubxmtZ3DB+/xUA1x3NWkDhDJKlp6omyqQ4Y6Opn8sGAdHE4ykKsQiCkjimVtvJ/6MPQZxCfAfv5pp0NSbcLHa00MZCIz6tZ0pJGCeQbDDBT3Yvl8n+ZJxD5Y6X+xbdbGY7fMCzpGgnk97bsuC1vyhxnGNa+9cVIkxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N64hL5x3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FA55C116B1; Tue, 23 Apr 2024 21:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713908188; bh=kRU/X/dR1S85QfdEA379AVH9Oh6pbj0vz6VEE2p37BI=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=N64hL5x31SGXexnFBS8oye91xqW8qUmC4XtebvTle1CkwE2vK/QxH5HuvgZAj7qmf mTemwU1pQsIGhRf/RXiaZpSH2CO0ckAqN9UJnW1p/okvqvH9D5+f+iVIIukrx09DK6 EaYnwb8ioGwRK/ewhLyw2d/1wxBNc3DOupbttAw6dJDaAxblnKQIDeDqZPzrRxlid7 3T/jwcpBOYDgbb9S/nCF0rlPn8LyPH39Dgx65fAt0yyFdCY7QS4q6goRSIafjB73HM SrILFGr9P/iu+QHCpBrAuLs08JIOEBf+KTkfWkgm0jYMBca5mzyU2RCpHEj44Qhhtv FZtYXCueW4bSg== Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 24 Apr 2024 00:36:18 +0300 Message-Id: Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v14 28/22] [SQUASH] KVM: SEV: Provide support for SNP_EXTENDED_GUEST_REQUEST NAE event From: "Jarkko Sakkinen" To: "Michael Roth" , X-Mailer: aerc 0.17.0 References: <20240421180122.1650812-1-michael.roth@amd.com> <20240423162144.1780159-1-michael.roth@amd.com> <20240423162144.1780159-6-michael.roth@amd.com> In-Reply-To: <20240423162144.1780159-6-michael.roth@amd.com> On Tue Apr 23, 2024 at 7:21 PM EEST, Michael Roth wrote: > Ensure an error is returned if a non-SNP guest attempts to issue an > Extended Guest Request. Also add input validation for RAX/RBX. > > Signed-off-by: Michael Roth > --- > arch/x86/kvm/svm/sev.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 2b30b3b0eec8..ff64ed8df301 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -3297,6 +3297,11 @@ static int sev_es_validate_vmgexit(struct vcpu_svm= *svm) > goto vmgexit_err; > break; > case SVM_VMGEXIT_EXT_GUEST_REQUEST: > + if (!sev_snp_guest(vcpu->kvm)) > + goto vmgexit_err; > + if (!kvm_ghcb_rax_is_valid(svm) || > + !kvm_ghcb_rbx_is_valid(svm)) > + goto vmgexit_err; Hmm... maybe I'm ignoring something but why this is not just: if (!sev_snp_guest(vcpu->kvm) || !kvm_ghcb_rax_is_valid(svm) || !kvm_ghcb_rbx_is_valid(svm))) since they branch to the same location. BR, Jarkko