Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5670306pxv; Wed, 21 Jul 2021 10:53:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp83V6QpxFULtBZZoOzzaiJHIjN6YDyBucd7vRUEuHCLzrOYl4B/cezSw8ASX4GWkSry3U X-Received: by 2002:a02:aa8b:: with SMTP id u11mr31402635jai.43.1626890031378; Wed, 21 Jul 2021 10:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626890031; cv=none; d=google.com; s=arc-20160816; b=MlrgFTwMlIEKiDvf0kLmIGsAannrla4EZQiIQqgwqUpoqfPmCh/UgPS7drqyq+aihW phq2iSQJFKPlc9NCREdZ3X94e+sWkN5cljFgyMDju1BSSxFW7vlvEOCrbM3WW/m4Sz8T 8Xq13xZqfmhs3okfEWi2Tq1/0vCVKahqIE7yii2TrENWZubmOQgIkGNYdbE6F+Ku3N86 isPJCjc1vwYkXXDWJ1hWaTGp1zjL+AbfFiqqdFa7lrycIi5iIiXj+OWP83ETHY/ZEB2N qJ+Bt+m/d79IgYhyth8OK9MjPqk25b0kMFBeX9AwM8LRfdS4Fgc2LlfHz3N3ESdZtyJW cA0g== 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=6yFvLCK83EARCEJW2USL66XPk2Snwg9rOn4V8eQnKq4=; b=DQLuh04yWYkB9519bGtZPL58c6RxT+FzypOt5aa/416u9MHkJyK1A2najPWRAEpjpr vUlFWmIfPUSn+FqJbIiNUnLuYR+IUrVqowCthOEHu00O/pQIRcgjOJAgiNGZpE6HiSVU e8OzjRbzYclFSbvVS4//jezKDx/FlV0v7WTDiwzqEZ5w5RxVxmxWt6wv4LwIe9hHQQyI XF1LCEGlPiNwEtWFAj9w7BBcg0aIaFyCUD1+O+sJ1tiQgtB/6eIeVM+bE5tjyB129/qj sU/SfwdW4VSni0T9r+sC+qtop2J3iegwe00TYUcz/RZWkJaB37IyvYLknjORIn6qWbrj 97ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LmYH4vBp; 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 i3si16485575ilu.3.2021.07.21.10.53.37; Wed, 21 Jul 2021 10:53:51 -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=LmYH4vBp; 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 S231224AbhGURM6 (ORCPT + 99 others); Wed, 21 Jul 2021 13:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbhGURM6 (ORCPT ); Wed, 21 Jul 2021 13:12:58 -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 B27EEC0613CF for ; Wed, 21 Jul 2021 10:53:34 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id c68so2850690qkf.9 for ; Wed, 21 Jul 2021 10:53:34 -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=6yFvLCK83EARCEJW2USL66XPk2Snwg9rOn4V8eQnKq4=; b=LmYH4vBpP8tsrP/2QQX/a4c4LvuM1+b4/24JikG+Eg3ffRRWq1sLdvVWqmdZSpffFs zYMHn1k1Y7JSxueTKglktRFPafjcur+BGgT8Ux3LXzZB1CNjBqPF55WMoTS3UHR/naUy 5HN4fHlgHkJlsYXgo1YafStP4kmIs1l/2txFBajcHQd5DgvTLQTHypzSg1u2dEsyWtNa 1Gnt5R/qqXAZ4zGACvt2zRiwgMwtDzYJEII9SZ5Ev6ztWv9+tg0z29/yQFcibOFahdej SPDfQhV5wiSgG/WdTlqfqtvyXLh0cVDvfnKvx7ZZJF7FSQsGy43aezRKof8MJZkcTPGM o0VQ== 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=6yFvLCK83EARCEJW2USL66XPk2Snwg9rOn4V8eQnKq4=; b=LaRIokKicXCHfUtx7C4ezuq/w8PW8/2y/Et2u36CNXqmVmfDqZWxn0SVolvpD8PG78 JpVKyF0D1UTcxsk6llBCDt9RNS6IBaXuA2ww7cIf3y1GzYR9gPLCk+rgEPDU3iXXGpIG lkGwZndC8K9eF7BdQxhdqE6AdSVR6BpLyVg3kcbjQcP42py426uPqFOBdQ3pyZyw1GYM WtRzgVAYYzLe48P8qxtB0AIQq3gHzHtTdZ/cKxNG6yDNr6Fiv5NcDk/HDEWphoTeG09P MhO2fO6eHRNoREZU3Ooj6biN985jRALT+fG7EhKi6+q/pys8tygyggwDSTWAxF9edWmT 3W/w== X-Gm-Message-State: AOAM532WQxThdgeJpClY2nKfzrlAdTcA+iBjWugydLu/qTIE32E9gwhu g1rNyuno4wA/BXw2GkQ9JknqD4Mjvdg5ASGWhKKOwg== X-Received: by 2002:a37:8044:: with SMTP id b65mr22312539qkd.150.1626890013396; Wed, 21 Jul 2021 10:53:33 -0700 (PDT) MIME-Version: 1.0 References: <20210707183616.5620-1-brijesh.singh@amd.com> <20210707183616.5620-27-brijesh.singh@amd.com> <9ee5a991-3e43-3489-5ee1-ff8c66cfabc1@amd.com> In-Reply-To: From: Marc Orr Date: Wed, 21 Jul 2021 10:53:22 -0700 Message-ID: Subject: Re: [PATCH Part2 RFC v4 26/40] KVM: SVM: Add KVM_SEV_SNP_LAUNCH_FINISH command To: Sean Christopherson Cc: Brijesh Singh , x86@kernel.org, linux-kernel@vger.kernel.org, kvm list , linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Jul 19, 2021 at 9:54 AM Sean Christopherson wrote: > > On Fri, Jul 16, 2021, Brijesh Singh wrote: > > > > On 7/16/21 3:18 PM, Sean Christopherson wrote: > > > On Wed, Jul 07, 2021, Brijesh Singh wrote: > > >> + data->gctx_paddr = __psp_pa(sev->snp_context); > > >> + ret = sev_issue_cmd(kvm, SEV_CMD_SNP_LAUNCH_FINISH, data, &argp->error); > > > Shouldn't KVM unwind everything it did if LAUNCH_FINISH fails? And if that's > > > not possible, take steps to make the VM unusable? > > > > Well, I am not sure if VM need to unwind. If the command fail but VMM decide > > to ignore the error then VMRUN will probably fail and user will get the KVM > > shutdown event. The LAUNCH_FINISH command finalizes the VM launch process, > > the firmware will probably not load the memory encryption keys until it moves > > to the running state. > > Within reason, KVM needs to provide consistent, deterministic behavior. Yes, more > than likely failure at this point will be fatal to the VM, but that doesn't justify > leaving the VM in a random/bogus state. In addition to being a poor ABI, it also > makes it more difficult to reason about what is/isn't possible in KVM. +1 to Sean's feedback to unwind everything here properly here. Comments of the nature of "XYZ should happen" -- without a test (e.g., selftest or kvm-unit-test) to ensure the XYZ _does_ happen -- are a time bomb waiting to happen. Also, I wonder if we leave pages, RMPUPDATE'd to immutable in previous loop iterations, is it possible for them to remain as immutable and be reused later on (after this guest is destroyed)? And if this happens, will we get an RMP violation? Even if the answer is no -- go read this code 2,000 lines away -- it handles this case. That's still not a very satisfying answer. I'd rather see things cleaned up ASAP as soon as the code starts to go off the rails.