Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp480240iog; Fri, 24 Jun 2022 07:45:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t6JshKLhF5vyaTKOfSp4vRX7Md5JJBgOKQm9CPZAJ9EB268iA/nV9y5DFR9fonbGDSm7hn X-Received: by 2002:a17:903:11cd:b0:167:90e6:5d83 with SMTP id q13-20020a17090311cd00b0016790e65d83mr43881314plh.136.1656081931139; Fri, 24 Jun 2022 07:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656081931; cv=none; d=google.com; s=arc-20160816; b=Zj3Ze5+zxKNdeChzX+o34pKGP6wUpMJ8+hienkhyTYEz0d1Rh4GTngW1DutPeUUckg SD+c2E2RNc2+sPt+ghprQ6H7G3f02C0GQOrX8u3m2qZlHOMcghrA5wQL8bEK44GHeEb0 A8CZ+43mwLymq+/HbrPJ9Bgc7LbiEfvQUSwjJ0A1d0ouowo2HWiaH2sOEisdWM+CBKM5 dDxLBqTrgGX0w4R8hHN9Z7YCV4kpikSWDsuanCa796gnBRvkMG+0S32i8QRaqpIYh6id iPE4sJ60pcs1lOtAQTZwvPTXQe1iDFF3jXAqwf5T5+2jpesVayo2t5DBN0USFYFLLQ+Y XFeg== 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=c74mHiS9ndNQXugtz6cvlyHO4YfoU5Amna4jcCNFMrs=; b=XR2vBTRtYe6rZr0F15MziC6L/VQsvtF9RNbrBSEuYtTr4hypDp/uAbui1v+lFI/grn v1k888V0HDUOvEpK/GpJs+8MBe7Gs4itqnc/DK1KXlEciJSziLDKftrZbCUhYUM1yD1B y2g2GOvJX2Us5RUmiR/T80xxyeMHpSZ1eyNT3gERltZAhWyQsh1/OUNQDhtrKPi09dqt Luff5HLsCD3ml9INkZRkJwa77mmX/geyJx7c9rhwEHXXjN/MRe03WEMLKnRzQVmZKUH7 H5UqWwZ95zuUs9I3UsDka+r51Jy8ltmoth/Yf7f9P9AXldUxTsgg9bezjgCkkef213uK 7qHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="H/ksdZ6l"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x78-20020a627c51000000b005254816b6eesi2147481pfc.342.2022.06.24.07.45.18; Fri, 24 Jun 2022 07:45:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@google.com header.s=20210112 header.b="H/ksdZ6l"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233281AbiFXOn0 (ORCPT + 99 others); Fri, 24 Jun 2022 10:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233451AbiFXOnB (ORCPT ); Fri, 24 Jun 2022 10:43:01 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE6B766F for ; Fri, 24 Jun 2022 07:43:00 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id by38so2993469ljb.10 for ; Fri, 24 Jun 2022 07:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c74mHiS9ndNQXugtz6cvlyHO4YfoU5Amna4jcCNFMrs=; b=H/ksdZ6l5zr/vi1yB0rt5Eri5/yAGDIDhJ+WxLtjolC+ufKy6G6zPlGl+RRyQ8X0yb KHR8ASjiTXJXazdAdIrcuZ2Cs25VbGzQxT++z2kemk7qCE31TwlEGNOFZz1VF98ViVgG DVB/LJous1QnTbkIZZt+g4YbndYf5ChpQiC4rpkQ5ReCIQTQumhdcGb/4pood8k+SwZN paHcsBmYu6mMMyQfqBR3cSwe3jcLr2EN+96eNG+ci+lB+YDn35X5J9KksySor56ctnXt T4lmVaUFlX5DI1QNKrmef517KCnrYSiznbpl/5KssWEh9sSpuWq7z0YsqPsbLgD3MCFS uQtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c74mHiS9ndNQXugtz6cvlyHO4YfoU5Amna4jcCNFMrs=; b=oSaZtSp1jSKWt7v8UnGCl0ssRHnpCIgRf2P5ORzbMwaXUlUddTr+zeKCNTnCh1h7yq GjugfMZKJ1ko2LjSh6xdIYxrjAgXZ2rYHEP22ZVbF7FxrBlv6ASAWCiGdRP/4T+QMYh5 2EmKY8UYHP+LOhmV5ttZtFHadzG/uzfQZlZ1ZJXaBATWHulmqAEpmZOzrxyXQcIRymc8 H/cC1FIlTImo31R2oQdrzE0ZfbtiZUhdJI3p1YX+TE6s+UtMvP+ay1Xiz/l0bHyVQ1x8 SFaIkSTYDG6DJatxmPHXICGg3K8XcYxOzAL8YTxUlZpyJsEtIHgXr3i8wS/fpuEEyYNu ViNg== X-Gm-Message-State: AJIora9KwH9+vz8SxXcisWuGvaLhc88TXlBk4ELiB8zsJnVbhSYegFPK iFlTu9bVt8qxrYAP6TKDv1M6N91ujqGgMYcBEgP2gA== X-Received: by 2002:a05:651c:1549:b0:258:4386:f6a2 with SMTP id y9-20020a05651c154900b002584386f6a2mr7672748ljp.527.1656081778232; Fri, 24 Jun 2022 07:42:58 -0700 (PDT) MIME-Version: 1.0 References: <6d5c899030b113755e6c093e8bb9ad123280edc6.1655761627.git.ashish.kalra@amd.com> In-Reply-To: <6d5c899030b113755e6c093e8bb9ad123280edc6.1655761627.git.ashish.kalra@amd.com> From: Peter Gonda Date: Fri, 24 Jun 2022 08:42:46 -0600 Message-ID: Subject: Re: [PATCH Part2 v6 24/49] KVM: SVM: Add KVM_SEV_SNP_LAUNCH_START command To: Ashish Kalra Cc: "the arch/x86 maintainers" , LKML , kvm list , linux-coco@lists.linux.dev, linux-mm@kvack.org, Linux Crypto Mailing List , Thomas Gleixner , Ingo Molnar , Joerg Roedel , "Lendacky, Thomas" , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , Tony Luck , Marc Orr , Sathyanarayanan Kuppuswamy , Alper Gun , "Dr. David Alan Gilbert" , jarkko@kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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-crypto@vger.kernel.org > > +19. KVM_SNP_LAUNCH_START > +------------------------ > + > +The KVM_SNP_LAUNCH_START command is used for creating the memory encryption > +context for the SEV-SNP guest. To create the encryption context, user must > +provide a guest policy, migration agent (if any) and guest OS visible > +workarounds value as defined SEV-SNP specification. > + > +Parameters (in): struct kvm_snp_launch_start > + > +Returns: 0 on success, -negative on error > + > +:: > + > + struct kvm_sev_snp_launch_start { > + __u64 policy; /* Guest policy to use. */ > + __u64 ma_uaddr; /* userspace address of migration agent */ > + __u8 ma_en; /* 1 if the migtation agent is enabled */ migration > + __u8 imi_en; /* set IMI to 1. */ > + __u8 gosvw[16]; /* guest OS visible workarounds */ > + }; > + > +See the SEV-SNP specification for further detail on the launch input. > + > References > ========== > > > +static int snp_decommission_context(struct kvm *kvm) > +{ > + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; > + struct sev_data_snp_decommission data = {}; > + int ret; > + > + /* If context is not created then do nothing */ > + if (!sev->snp_context) > + return 0; > + > + data.gctx_paddr = __sme_pa(sev->snp_context); > + ret = snp_guest_decommission(&data, NULL); Do we have a similar race like in sev_unbind_asid() with DEACTIVATE and WBINVD/DF_FLUSH? The SNP_DECOMMISSION spec looks quite similar to DEACTIVATE. > + if (WARN_ONCE(ret, "failed to release guest context")) > + return ret; > + > + /* free the context page now */ > + snp_free_firmware_page(sev->snp_context); > + sev->snp_context = NULL; > + > + return 0; > +} > + > void sev_vm_destroy(struct kvm *kvm) > { > struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;