Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp76127pxb; Fri, 20 Aug 2021 19:15:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjniUKFMH9KA8fvEyeCJMTA4Pyf1Ev9X1Q4h6dQ0kARXKU9aTJuEX0XZHOGIigPBqKzBn1 X-Received: by 2002:a02:c502:: with SMTP id s2mr20522947jam.135.1629512144127; Fri, 20 Aug 2021 19:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629512144; cv=none; d=google.com; s=arc-20160816; b=HtKUhoqbtVVCfL8boKIh4+8MZ5tZPs/GapyuRmCMhYr0QLV/SKLrSKp25FLumvY8ft ip+xSk/LzYEg3cqa6LdvoTjN4KYDHOsXY5SuTkt6uiiYIJ1rQWO4GVF6rbySGfRXmncW q/WsE0uywLE71fhLPR7oAMvPOZhgD8nPFwiLs+zwLigRG9Bb/q9RCkYcNYiEN+BCkZrp ensZZBVIWF6wOe7XlJbMqjHzX92VNsS3ly1alxohLNugW0TJuO0lTGwr3DAnfZkoLtcK f6T+nVIstkry1sev65xzsmk58K1UzlWcYjswcoWswjnBCK04J4LmvGwYmdl3B4T7rfSV lYvA== 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=2gOO2S7Mv0HOYYeN5193uyMUGfsmPjSlzi2OFU8Y+fo=; b=eoLG1wqg7+vp0FsL81/4vTKRFHcEg94TKr2vpzZcl6ttGQfuKyWeZqtZMtPYko+h3T JKhzQlLcseAEkDEWZoxaoHOGrTfSmEEG2qx6AxQQ0HVaqAzBH5M6tvF0E4ljeMef/7ZH EY2H/ZzmS/7T+xUeO3bQcPc17fTy0I4rbCBz8lkH9e1u2tpsFK416NbHY1yrYdct/GWA HcvSl8o76VfVxyhL/dse3znRutRwO1R/PSnYH+XcGJ3vdBDLJhlAVKlVX6+NFUiK/ks4 6N1v+/BpuazkjzyY8rMKRdr/84+pnahjl0UcN+jkAbpzsViZ49pbCxwkPLtScrsWzIY8 J33w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L8bsYCZr; 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 u15si9121369iot.89.2021.08.20.19.15.15; Fri, 20 Aug 2021 19:15:44 -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=L8bsYCZr; 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 S240967AbhHUCMh (ORCPT + 99 others); Fri, 20 Aug 2021 22:12:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240957AbhHUCMh (ORCPT ); Fri, 20 Aug 2021 22:12:37 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A50ACC061757 for ; Fri, 20 Aug 2021 19:11:58 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id b1so9069443qtx.0 for ; Fri, 20 Aug 2021 19:11: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=2gOO2S7Mv0HOYYeN5193uyMUGfsmPjSlzi2OFU8Y+fo=; b=L8bsYCZr6W6WOVgqBP0nhp9qabhe3vp0nXQEfWFvEEp2V3ftXg/ZVGt48988QCyJSN g25s9q0q+k+UI5gdlyy9fDtxUQoosqOy3QODvoWrq8d0AnMZhf1sxLSuZPst5G6XO6xG 2hwDr+08s5ajJotnhZDie1AgvEX74LQd6O7wpL3SXiNZ44td+ePm+EA7aFhW04nhLXm7 uXG5PwIm36yZVEfQh3e28iJymNdJctSE/4a3tpCFmkjnzZ3fpIulLnS+f1cVjo0KlD1s Jizp09BdIWghNYDyA/mEQ/CDqEyNTeKUZdu8AFvQ7PyKOUsUIjvlHXPIXPdetrTN/ykm 5nEA== 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=2gOO2S7Mv0HOYYeN5193uyMUGfsmPjSlzi2OFU8Y+fo=; b=lIOhD7qoAy/k8UP87ywVNq7iJ/jPuXVipc1D/fKsxmxXcdEg8y1hKjwVToPTK7/E3n Jzn7xn2a6GODBxd+DFP+8CtQ2X97kigYwGjOtvkAb96IyaS28Uh0zStHxlP6ji8g1Ffo 1pI5YjJ9ujD6QScku9bTPlZLFDnS73sbZy4pHCDCe7SxxiHJzJa0Z5XSvmkLRRTr/uCO nUWA5ibbOTlj+j4zYyPSJBgKiQLjQwZaHgTXHA+iUhBjFWZxtZQAGeZEY9MAcQw/T2HO lhcRNa0rjHzol2wa6w++933W523Z3I89jGU5SU7ygj9r0Dp/l3I9SWg+iiFRh6G+0jdJ efNg== X-Gm-Message-State: AOAM532V6odVUzvP/4QGY7TRgA5A6yL9uWKvnz0DhSVf/wKvnciAepN0 +NMx5+Eg5BUaxsi6Lxw6EUK60XM3k6KZmUt1NU0OrA== X-Received: by 2002:a05:622a:488:: with SMTP id p8mr20558647qtx.159.1629511917617; Fri, 20 Aug 2021 19:11:57 -0700 (PDT) MIME-Version: 1.0 References: <20210818053908.1907051-1-mizhang@google.com> <20210818053908.1907051-2-mizhang@google.com> In-Reply-To: <20210818053908.1907051-2-mizhang@google.com> From: Marc Orr Date: Fri, 20 Aug 2021 19:11: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 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") Reviewed-by: Marc Orr