Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp88391pxb; Fri, 20 Aug 2021 19:41:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWrxqBbd5jjeRBwPATOccSAVvsIHLvlARZ9LC+LkYC+oMPLArtP9G5kWt5q4WiH5mm5MgQ X-Received: by 2002:a05:6638:191c:: with SMTP id p28mr20236171jal.41.1629513672396; Fri, 20 Aug 2021 19:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629513672; cv=none; d=google.com; s=arc-20160816; b=hjVsWuc6Z5b91raJ0VpjdK+vCmxzq4TALv8I3v5BF2LTnpvCl48X3nfqxrtgOrM4NH 7cC5WvthffPMAEXw2+Lagj7Q/k4tgWwcf+o26H94IzHXxMAHlXDeI+xN3KlPXMcxj6Lm +fLU0FpacX3RDA9ti1RuneC13uMDlPoY5UhTvfl56LKmXxl5jVCwqtqEmdlJa4EUKoeL qj8Lg3wR34Q1bniykBsSlwmGQMGNw34ug3BR4h0zlYtcVyFdsju75WijHflo4+AC3uLK EP0ryiwD8E7nl0IIqeVUG0Er17c/LpWDL03tUtq+Xww+xDDrDokx0ujtkaBSZDjId68O 0IzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ooK0DyFfmJ4kDNoGRhTDLo5fbQ6yVEecKkqRgMQgWQQ=; b=ESwVXN5FZrbNgRTjRkfr5glnjhj8swtcsqRLWwE0T2ugBqai+BlKKBJv/FKk6u5j3u tNIJ6IGBVXYK9N8y14QDqaa+IwH0LxNORy0g7louFxZsEjLHRxIIj4fJF/eLW3RDyxtY Z1v0RsymUrwL7/Ts4CQEGJsNTEy2kCwq5EhM1daDTK6NhxM201IjXmZIrnZowC1v8MlH A4nSv84O6nZx3FWuovBBkJYCH2vmUXsBGT9jhoHzJO55CTMOmEZqCCQd2HJIB0uVBpkp j6gZPWxK6Jz1TzdUK66y420gaXZfhpyqibX974ejOwphGx4wEJOwjoaFS09bwxYfEcOq ZpDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ITmJh1ii; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si8315844iow.102.2021.08.20.19.40.48; Fri, 20 Aug 2021 19:41:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ITmJh1ii; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231268AbhHUCbi (ORCPT + 99 others); Fri, 20 Aug 2021 22:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231804AbhHUCbh (ORCPT ); Fri, 20 Aug 2021 22:31:37 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B9B8C061575 for ; Fri, 20 Aug 2021 19:30:58 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id a10so4025167qka.12 for ; Fri, 20 Aug 2021 19:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ooK0DyFfmJ4kDNoGRhTDLo5fbQ6yVEecKkqRgMQgWQQ=; b=ITmJh1iiIU25AZkkFiZ5AE7BFomVpuseXmmGmKgpouePfNV5ggDB6cjrFuu4TLD9lC 5+ZO+FOVYnmxA1fSDV2SCW24GaQKPhgEIgMUYAU+0RYOlY/dzN2EglyhdXlfkjtxZnMW zuSuoS146oCPgzF0wDQErFxcWP2FoBFOVojWvmPvgRoo8FUxNkBaOfPqn10Vj/+e0xRl bxU6yvs25fr48KK6gFeCup+KgI8uT+Si4t22ntUzVFdKaLBDM04odzk2f4WOFyfkzAqW 0RGCG5fMfZQzGOIyCozL/ERUFuu2D3TYN1LTJtpT1LcwsP/08TC8ReaVLCtbOkMEdhUJ yZ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ooK0DyFfmJ4kDNoGRhTDLo5fbQ6yVEecKkqRgMQgWQQ=; b=eWXEB0T9LFpzRyvRi3rjXOTBn31msQsQOxyqVS48+fW8Sbiu2RFbFG4TlQQAX7xlqU EzONy06F4bZ7IRpemf47XDdpsWdpEu2aqjsrw+MLmE/u+Ot13nMvlDJVq2hmOEouIyle /h5eApsYevLsfKqnC+8FLcmGbPJMizbqGWcwsm7FyuVK8NP9eKqDf2e0fQQAMQdkJ3Bc E7PPuSvzJFnZdWdl/ewDGJUmSC5NPnEf03qPySd2qM7ZylAW+fTsCjYNeQmY1217NYNN bCyxgkaWdpFcWc60qrY64PAfyhYuKgnFCLmsH6Sm7c7WWl4Ml6YvnQVP34kUfLwkcbPW OHYg== X-Gm-Message-State: AOAM531fIbUFD1d9rX+TAhrvk+Ee4rOBUeOsgDeL6uIRwNHvqExyaihU fWaiiiAeyhjsa50IoZUUXhv87RrwZiKRyBooMHmxjA== X-Received: by 2002:a37:45c9:: with SMTP id s192mr12038137qka.21.1629513057515; Fri, 20 Aug 2021 19:30:57 -0700 (PDT) MIME-Version: 1.0 References: <20210818053908.1907051-1-mizhang@google.com> <20210818053908.1907051-2-mizhang@google.com> In-Reply-To: From: Marc Orr Date: Fri, 20 Aug 2021 19:30:46 -0700 Message-ID: Subject: Re: [PATCH v2 1/4] KVM: SVM: fix missing sev_decommission in sev_receive_start To: Mingwei Zhang Cc: Paolo Bonzini , Brijesh Singh , Tom Lendacky , John Allen , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm list , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Alper Gun , Borislav Petkov , David Rienjes , Peter Gonda , Vipin Sharma Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Aug 20, 2021 at 7:11 PM Marc Orr wrote: > > On Tue, Aug 17, 2021 at 10:39 PM Mingwei Zhang wrote: > > > > sev_decommission is needed in the error path of sev_bind_asid. The purpose > > of this function is to clear the firmware context. Missing this step may > > cause subsequent SEV launch failures. > > > > Although missing sev_decommission issue has previously been found and was > > fixed in sev_launch_start function. It is supposed to be fixed on all > > scenarios where a firmware context needs to be freed. According to the AMD > > SEV API v0.24 Section 1.3.3: > > > > "The RECEIVE_START command is the only command other than the LAUNCH_START > > command that generates a new guest context and guest handle." > > > > The above indicates that RECEIVE_START command also requires calling > > sev_decommission if ASID binding fails after RECEIVE_START succeeds. > > > > So add the sev_decommission function in sev_receive_start. > > > > Cc: Alper Gun > > Cc: Borislav Petkov > > Cc: Brijesh Singh > > Cc: David Rienjes > > Cc: Marc Orr > > Cc: John Allen > > Cc: Peter Gonda > > Cc: Sean Christopherson > > Cc: Tom Lendacky > > Cc: Vipin Sharma > > > > Fixes: af43cbbf954b ("KVM: SVM: Add support for KVM_SEV_RECEIVE_START command") > > Signed-off-by: Mingwei Zhang > > --- > > arch/x86/kvm/svm/sev.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > > index 75e0b21ad07c..55d8b9c933c3 100644 > > --- a/arch/x86/kvm/svm/sev.c > > +++ b/arch/x86/kvm/svm/sev.c > > @@ -1397,8 +1397,10 @@ static int sev_receive_start(struct kvm *kvm, struct kvm_sev_cmd *argp) > > > > /* Bind ASID to this guest */ > > ret = sev_bind_asid(kvm, start.handle, error); > > - if (ret) > > + if (ret) { > > + sev_decommission(start.handle); > > goto e_free_session; > > + } > > > > params.handle = start.handle; > > if (copy_to_user((void __user *)(uintptr_t)argp->data, > > -- > > 2.33.0.rc1.237.g0d66db33f3-goog > > Should this patch have the following Fixes tag? > > Fixes: af43cbbf954b ("KVM: SVM: Add support for KVM_SEV_RECEIVE_START command") Oops. I missed that it already has the Fixes tag. Please ignore this comment.