Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4505485imw; Tue, 12 Jul 2022 09:05:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v0N7FHZMRJBBle+JrAHlp+Dw3sM4h6sMLSKPwqDq8HXAv5HEANHX9KBsO8gD3oUn8I055C X-Received: by 2002:a17:902:7c0d:b0:16b:7dd2:626c with SMTP id x13-20020a1709027c0d00b0016b7dd2626cmr24128230pll.152.1657641935584; Tue, 12 Jul 2022 09:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657641935; cv=none; d=google.com; s=arc-20160816; b=dpWgAK6X4JP2L5EG1ObKBGaugx0XWoiauu5HvnUOwiFBBIoDRY1tfuYm0r2mbI2Tky 8UCgD9G/eNMOaZT4wzVWqyc+BRL7c/ullrjnk9oz5cUlZ0gRM+qH5cm1ja/lENZne+MF ktLZLQUxErtl/IbbhyG14Zc3qcxAKbO9q7OKdoacjbMbZogAGyuM8jSgJ+KuXaZmyAQK +wv4rxlu8Zs6n0lDX9CLAh2FCvM080L4CmTdQ3LuZZo/cqPUep81IWCLBtz41LSBmtF6 pl2TatAcCCSM0H4A6sZDTr6Jc0G5eojmm4s0p0AlAWaSXocyVZ3k5vOWAbIAjaD13P5n V0YA== 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=c0RcQSLjeYCnLvxH8el7ACbuvLKqs4ymAPhMSssf3fo=; b=Jb169LqIN1NLxoG6pmW21VW57m4t+VkWORCTSayAmw4uGkipH+MIvGJyI2/l091lSr jxG7TxEkHZD/sTvIfPIVP0jjJBEVAx0qqftp9x5ixVE6B2UJbQrQH3L9IhzJ+1khx1da 8RFsH0SgkdZPMwYuhrK3MN6gvd7s38/9fuZISusIteupvXJUQPzH0mqHE1BSM/QVe2AK qHXeag1yIbkC5jn4zVXOaE3+pQvTxYwrYjo7RTdXqlUcTdKQfBz7dshvK4j+GHE8QQyt aoJtqonp6RT0tuez5iWBegXWHuaw134hRYfMnz8xDTSQR1tYbJH8WHUfsIwTifVZ5jvL sgyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rgy8GpGj; 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 28-20020a630c5c000000b0041980058985si872204pgm.194.2022.07.12.09.04.59; Tue, 12 Jul 2022 09:05:35 -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=rgy8GpGj; 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 S233706AbiGLQE3 (ORCPT + 99 others); Tue, 12 Jul 2022 12:04:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbiGLQEX (ORCPT ); Tue, 12 Jul 2022 12:04:23 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2466F13 for ; Tue, 12 Jul 2022 09:04:19 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id bu42so14784022lfb.0 for ; Tue, 12 Jul 2022 09:04:19 -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=c0RcQSLjeYCnLvxH8el7ACbuvLKqs4ymAPhMSssf3fo=; b=rgy8GpGjigNewPkDfawGIyJhs5SthypU/zUHIYssEnhqMMiqNAKc4ezJ19mpUkfSMy nHlnPMccqvaAAhX/ySaXKSzNEJ+RUL0TBhSHaW0HqHGvmgX2wxKuTd+jA0VHIQPZ9QFF a6LEAvMbeWy1+vmRd8d6u+JJ7f13B0rTgQTdohwT7+APFsOdcZJnmvacai86xywgvwxZ kEZYabnYpVeCuAKxSwQRmTLVQyoTaFQAZoagdzVEMYGEcN4G14TusnppOWvHU3N4UMpc t6xNmt5QTEm/TElgI+kc11twOzYFn1L/5P2tE2Iy6Q0EvlpQEc4560MbpDvwkPfROLHC yEdQ== 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=c0RcQSLjeYCnLvxH8el7ACbuvLKqs4ymAPhMSssf3fo=; b=DHv1WQB4w5TNdUD8gSiK7u4FW6W8tCjtghiwU9RcC0oVSHUAgYzxe3WMmmim9w/RYB 0MOD+rx/+5VvC+Ia2wY/WCeZoG7XMIApmOFFW/MjLGENusOZEIBmjp9PYde0H79xtLur 6vloUiFaiecLtBoXCaMSne3BkNcdePvWhj5kAr8p4c4ZkPG9jC1RLJeHbWA/TS8LxP+x 0Hi27jOS1mKfd0lhWSYnlUtZSxgdI+dVrlVyPVHEc6ZP/1vGeBqu3bFMpue8dCsG2Wgx M9T32POy3C8kTCAqBzu+HllXLi2eX98yEiRbGYuSbNzDsKpext08QPOv8PGoQkazPVSw XpXw== X-Gm-Message-State: AJIora+QnZxZ+cFtt1RVEwLkR+ccxjT9E1aleU85qPIh1jabygbwoaUu vFNiCeAQLJt/wMDfALPnckvzNRQMg4bk29g0dyU8uw== X-Received: by 2002:a05:6512:32c5:b0:481:1822:c41f with SMTP id f5-20020a05651232c500b004811822c41fmr16158485lfg.373.1657641857910; Tue, 12 Jul 2022 09:04:17 -0700 (PDT) MIME-Version: 1.0 References: <6a513cf79bf71c479dbd72165faf1d804d77b3af.1655761627.git.ashish.kalra@amd.com> In-Reply-To: From: Peter Gonda Date: Tue, 12 Jul 2022 10:04:05 -0600 Message-ID: Subject: Re: [PATCH Part2 v6 28/49] KVM: SVM: Add KVM_SEV_SNP_LAUNCH_FINISH command To: "Kalra, Ashish" Cc: "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 , "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 , "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 9:22 AM Kalra, Ashish wrote: > > [AMD Official Use Only - General] > > Hello Peter, > > >> >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 LAUNC= H_UPDATE_VMSA'd. LAUNCH_UPDATEing all the VMSAs causes VMs with different n= umbers 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 c= an: create new VMSAs from guest pages, RMPADJUST them into the RMP state VM= SA, then use the SNP AP Creation NAE to get the hypervisor to mark them run= nable. I believe this is all >setup in the UEFI patch: > >https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fwww.= mail-archive.com%2Fdevel%40edk2.groups.io%2Fmsg38460.html&data=3D05%7C0= 1%7CAshish.Kalra%40amd.com%7Ca40178ac6f284a9e33aa08da64152baa%>7C3dd8961fe4= 884e608e11a82d994e183d%7C0%7C0%7C637932339382401133%7CUnknown%7CTWFpbGZsb3d= 8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%= 7C%7C%7C&sdata=3DZaiHHo9S24f9BB6E%>2FjexOt5TdKJQXxQDJI5QoYdDDHc%3D&= reserved=3D0. > > Yes, I discussed the same with Tom, and this will be supported going forw= ard, only the BSP will need to go through the LAUNCH_UPDATE_VMSA and at run= time the guest can dynamically create more APs using the SNP AP Creation NA= E event. > > Now, coming back to the original question, why do we need a separate vCPU= count argument for SNP_LAUNCH_FINISH, won't the statically created vCPUs i= n kvm->created_vcpus/online_vcpus be sufficient for that, any dynamically c= reated > vCPU's won't be part of the initial measurement or LaunchDigest of the VM= , right ? Are you suggesting that QEMU will KVM_CREATE_VCPU the BSP, then LAUNCH_FINISH, then KVM_CREATE_VCPU all the APs to their VMSAs were not LAUNCH_UPDATED? If so, it seems annoying to have to create vCPUs at different times to get their VMSAs into different states. That's why I was suggesting some other mechanism so we can continue to KVM_CREATE_VCPU all the vCPUs at the same time. > > Thanks, > Ashish