Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp786673imw; Wed, 13 Jul 2022 08:02:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1veK1EwSk9Z8+PkZlf+PByF2hfL3NR9oTf1iWZeZKnt3wpAroVmnU+7Bu/5M/4RnnQQ+7bI X-Received: by 2002:a63:454c:0:b0:415:c98a:d090 with SMTP id u12-20020a63454c000000b00415c98ad090mr3224464pgk.347.1657724526568; Wed, 13 Jul 2022 08:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657724526; cv=none; d=google.com; s=arc-20160816; b=ZhZXzqwp8oumiKXRfr09MUyiUnodak0VlLonoctyhs7aFv0q/aKo5DNVMUyoPRlOcX bf7fi4igHJqKH4Ssoz11ur5hNopSqHaiRvbMjTuy5XWKJ1cdpgxkfi6GkzCT2TxdBZrh 31ek3GhEDe0jUn2CGnpO7LGsK2tNybjvNbuH+aM1FrjWQRKcosjE5bX1UOr16ePJrvAR Grw8sDL662Mu5X6AOWUAXwEgZD4W+YWLV9EfKdsAEvUs4HCmTrfCoWCRjLZbvwZLONA1 niKa/m+16EOM3ZikTe6fAS5ug1VGLHdSRCkEzmFT0FJf/G93JiKbf4ch7ee6eHd6swkJ thtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6Y8GbLmVYsqOjAmk1Y1MFoYDRm1tANijToQSxmqM/Z0=; b=trs37K+3OyPYSWi6wQ54IenCIAjYJ1ouA+WXxMAo/8mAs7hpj3m4SVKHkuJ5oh+bzn ZPFDol/trecNTA4/zBmjW3ZcRKM+uwpNL3gVhWHQHlGFrb3fGR2IWA6KRTu5ULwxmQte hHAdnqiUly//RktGPDuUd69izxkJLd6i/7E8KfxpPfbuzU5dY34FxVc4qj96aFJM6q0q vSC0gNnVnyO+CIAyQgohhgk3e2ARGJ7yikyOXuomU1eO2TRw9HxxVjPxY6yngULaAMow AVQ9BMtdjHyTnkJGCC10/fCHfob+F48Pmr3bjzlw1rYEHLADojvL0r05DK5wKyLBFPob iKUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zy2W9NCe; 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 q19-20020a056a00151300b0052af232ccb9si4905094pfu.151.2022.07.13.08.01.52; Wed, 13 Jul 2022 08:02:06 -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=Zy2W9NCe; 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 S236608AbiGMO7x (ORCPT + 99 others); Wed, 13 Jul 2022 10:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236661AbiGMO7x (ORCPT ); Wed, 13 Jul 2022 10:59:53 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E6313F25 for ; Wed, 13 Jul 2022 07:59:51 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id d12so19483878lfq.12 for ; Wed, 13 Jul 2022 07:59:51 -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:content-transfer-encoding; bh=6Y8GbLmVYsqOjAmk1Y1MFoYDRm1tANijToQSxmqM/Z0=; b=Zy2W9NCe+isY/WHx1n36fgDq35tWZP4AnyK3U5sdhE0Expg9sXawpS8p6vOHWmV/Kp 8QTdb8LrYvSXfxOiA0OYH0n/v4ioxsiAtO98MdBHw1uUuLUS6b39WggfSytIvPzWLCbx nXxQuEi/C/ziDw4cgxp0ryFFbb+OfTmx0iP94pfR4Y8qOhojY+IE/IXIeXFGKoZtXvkz 8KF+XiU0aYlnu3Q67hg8V6jDk7EG5mNQQdaYrFVFdVKrV2O43A3pYJ+afvW7ZMAgX9R/ rQvnY5DLaLEjmCaN3+K2aY1QDY3CvXszw0mOHJKjzXb4ZBbcU29+byDR9nBIT6szJKIy xUrg== 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:content-transfer-encoding; bh=6Y8GbLmVYsqOjAmk1Y1MFoYDRm1tANijToQSxmqM/Z0=; b=wn/aqiFdJ4yRr6ZlqB6gG/JwOy6G4X+MsHOYtP5vPopE+7CTwsI9H89ksklue+sHCz irzZDgxYHccW5oqoqJlppbhqXCDiQursIK85D5H4mGcy108HD0MUNE+2vnv+SmbZW1L8 qMDHgPrJ2l0LOaAhxmLb/P1hzU7oh5awA6muZbEpdTZ7cCPe33g5vU2i2ue0HZH1vKjI 1jLRdgb9GiXA4Z2YtHHbMCKFEFPaO/R4dknsBGegbA5MODLq3vTHusNolVBBXCNrWQkT Uh9wxbJ6tMNRpxzGU9kYRxUZh+xIrbJxjfOSM/PzoggUovCUQy8rEx5dZJE/ShIC5+2k Y9gQ== X-Gm-Message-State: AJIora8oP1S3BEgJHuqWKVXCWXdl/8pn/uC6HG1kNjiY1qOiKBp9BlLB CtZdshmtd1Y9rge/HZb0RpdoqknqCzUGpFHUCGGEmw== X-Received: by 2002:a05:6512:32c5:b0:481:1822:c41f with SMTP id f5-20020a05651232c500b004811822c41fmr2320675lfg.373.1657724389943; Wed, 13 Jul 2022 07:59:49 -0700 (PDT) MIME-Version: 1.0 References: <6a513cf79bf71c479dbd72165faf1d804d77b3af.1655761627.git.ashish.kalra@amd.com> In-Reply-To: From: Peter Gonda Date: Wed, 13 Jul 2022 08:59:37 -0600 Message-ID: Subject: Re: [PATCH Part2 v6 28/49] KVM: SVM: Add KVM_SEV_SNP_LAUNCH_FINISH command To: Tom Lendacky Cc: "Kalra, Ashish" , "the arch/x86 maintainers" , LKML , kvm list , "linux-coco@lists.linux.dev" , Linux Memory Management List , Linux Crypto Mailing List , Thomas Gleixner , Ingo Molnar , Joerg Roedel , "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 , "Roth, Michael" , 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" Content-Transfer-Encoding: quoted-printable 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=unavailable 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 On Tue, Jul 12, 2022 at 11:40 AM Tom Lendacky wro= te: > > On 7/12/22 09:45, Peter Gonda wrote: > > On Mon, Jul 11, 2022 at 4:41 PM Kalra, Ashish wr= ote: > >> > >> [AMD Official Use Only - General] > >> > >> Hello Peter, > >> > >>>> The KVM_SEV_SNP_LAUNCH_FINISH finalize the cryptographic digest and > >>>> stores it as the measurement of the guest at launch. > >>>> > >>>> While finalizing the launch flow, it also issues the LAUNCH_UPDATE > >>>> command to encrypt the VMSA pages. > >> > >>> Given the guest uses the SNP NAE AP boot protocol we were expecting t= hat there would be some option to add vCPUs to the VM but mark them as "pen= ding AP boot creation protocol" state. This would allow the LaunchDigest of= a VM doesn't change >just because its vCPU count changes. Would it be poss= ible to add a new add an argument to KVM_SNP_LAUNCH_FINISH to tell it which= vCPUs to LAUNCH_UPDATE VMSA pages for or similarly a new argument for KVM_= CREATE_VCPU? > >> > >> But don't we want/need to measure all vCPUs using LAUNCH_UPDATE_VMSA b= efore we issue SNP_LAUNCH_FINISH command ? > >> > >> If we are going to add vCPUs and mark them as "pending AP boot creatio= n" state then how are we going to do LAUNCH_UPDATE_VMSAs for them after SNP= _LAUNCH_FINISH ? > > > > If I understand correctly we don't need or even want the APs to be > > LAUNCH_UPDATE_VMSA'd. LAUNCH_UPDATEing all the VMSAs causes VMs with > > different numbers of vCPUs to have different launch digests. Its my > > understanding the SNP AP Creation protocol was to solve this so that > > VMs with different vcpu counts have the same launch digest. > > > > Looking at patch "[Part2,v6,44/49] KVM: SVM: Support SEV-SNP AP > > Creation NAE event" and section "4.1.9 SNP AP Creation" of the GHCB > > spec. There is no need to mark the LAUNCH_UPDATE the AP's VMSA or mark > > the vCPUs runnable. Instead we can do that only for the BSP. Then in > > the guest UEFI the BSP can: create new VMSAs from guest pages, > > RMPADJUST them into the RMP state VMSA, then use the SNP AP Creation > > NAE to get the hypervisor to mark them runnable. I believe this is all > > setup in the UEFI patch: > > https://www.mail-archive.com/devel@edk2.groups.io/msg38460.html. > > Not quite... there isn't a way to (easily) retrieve the APIC IDs for all > of the vCPUs, which are required in order to use the AP Create event. > > For this version of SNP, all of the vCPUs are measured and started by OVM= F > in the same way as SEV-ES. However, once the vCPUs have run, we now have > the APIC ID associated with each vCPU and the AP Create event can be used > going forward. > > The SVSM support will introduce a new NAE event to the GHCB spec to > retrieve all of the APIC IDs from the hypervisor. With that, then you > would be able be required to perform a LAUNCH_UPDATE_VMSA against the BSP= . Thank you Tom I missed that we needed to run the APs to set up their APIC IDs for OVMF. Is there any reason we need to wait for the SVSM to do what you describe? Couldn't the OVMF use an NAE to get all the APIC IDs? > > Thanks, > Tom >