From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39A33C433EF for ; Fri, 15 Oct 2021 18:58:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B617A61090 for ; Fri, 15 Oct 2021 18:58:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B617A61090 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 36E1B6B006C; Fri, 15 Oct 2021 14:58:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F4A36B0072; Fri, 15 Oct 2021 14:58:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 195BF900002; Fri, 15 Oct 2021 14:58:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 07D8C6B006C for ; Fri, 15 Oct 2021 14:58:45 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A91A42D4BF for ; Fri, 15 Oct 2021 18:58:44 +0000 (UTC) X-FDA: 78699583368.17.C714B8D Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf16.hostedemail.com (Postfix) with ESMTP id 3265BF000092 for ; Fri, 15 Oct 2021 18:58:43 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id q5so9369760pgr.7 for ; Fri, 15 Oct 2021 11:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TQM6iseqNr527XMaI35HFwel5PilmxiFDRjsypqPjJY=; b=OWTVpv7FF2Ibi9JFu8PskmJJXobmWCskKm13NYVXbiD1hh6KL51VFSmJ6MbJbWtQA2 L3y+YLr3YYr5u1dNm/ZbLKZIYjxIuDeGnTF4yR2kPBwTo98FZNh9lN0vRR6mf4YSGdYg OjKQn7XkYoD1m1UZ1fk8JA2Nvl709DHiWTxtZpbGclYN5l0Lq5XDMVN3rFndlv3X4zdJ Znat97o7ahqtZ3IFR8Znsqs7FR9dYuKbAtSZa9rM4UoKyN7N/HcFoQtLEL6TobpdavVO 30UwYM/ReX1Nrybgj4EzVstae47oOfiIo678d3bZiHDwtKtfkklUcguMl56tPWgGAxo9 CbBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TQM6iseqNr527XMaI35HFwel5PilmxiFDRjsypqPjJY=; b=IdidKdFwBGr96cxI1mfBpAZQX4MPp5peCsQDbkKV3a+eXnagLRyGQ2FDiG6s/PbMCD UIg+VDDn5RqvxlqjfHykWikOSVxiftB7fyPXo43Yz7aRVtfcvRDOjg8zmc/9BRMoUuga gglquRi9ebf3IKCQ53XZnQ9/Q/wwpb3a+XuLwN3oeG/ONnL3pzK9fIcG0V7lgOFUPhsS tBsPq9Y0hfU/5pmV0DhvYlV+PggDwqTy4sgw2xddS5IHWg2vNvodD0EHMysrD0MCckWJ ZvkrMg1anhQEGcxNIYqkNms9xCNi8MRJ1pdZywFFVsL6kJ74DWLmSCRCD6cB91nj54Tr tUug== X-Gm-Message-State: AOAM533/T3EyuM2UdR7C/b0FKXYtZ09yWjJbs3eLXSBrnave7A848J2o xPFuCY3o+u2mnwCPwGOXv3Qk+A== X-Google-Smtp-Source: ABdhPJz11NQ8k8O3sx0w8Jmw/mT7h0gCT45pHlT7hh3N0P78+0UiDdOgcHDso4OmHjjXvEL1tZbORQ== X-Received: by 2002:a63:3714:: with SMTP id e20mr10506241pga.50.1634324322967; Fri, 15 Oct 2021 11:58:42 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id 66sm5517324pfu.185.2021.10.15.11.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 11:58:42 -0700 (PDT) Date: Fri, 15 Oct 2021 18:58:38 +0000 From: Sean Christopherson To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@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 , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH Part2 v5 43/45] KVM: SVM: Use a VMSA physical address variable for populating VMCB Message-ID: References: <20210820155918.7518-1-brijesh.singh@amd.com> <20210820155918.7518-44-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210820155918.7518-44-brijesh.singh@amd.com> Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=OWTVpv7F; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of seanjc@google.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=seanjc@google.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 3265BF000092 X-Stat-Signature: foaxg7a8jnq1epxx1sps9qxkofkjx36u X-HE-Tag: 1634324323-658387 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Aug 20, 2021, Brijesh Singh wrote: > From: Tom Lendacky > > In preparation to support SEV-SNP AP Creation, use a variable that holds > the VMSA physical address rather than converting the virtual address. > This will allow SEV-SNP AP Creation to set the new physical address that > will be used should the vCPU reset path be taken. The use of "variable" in the changelog and shortlog is really confusing. I read them multiple times and still didn't fully understand the change until I sussed out that the change is to track the PA in vcpu_svm separately from vcpu_svm.vmsa. It's somewhat of a moot point though, because I think this can and should be simplified. In the SEV-ES case, svm->vmcb->control.vmsa_pa is always __pa(svm->vmsa). And in the SNP case, svm->vmcb->control.vmsa_pa defaults to __pa(svm->vmsa), but is not changed on INIT. Rather than do this crazy 3-way dance, simply don't write svm->vmcb->control.vmsa_pa on INIT. Then SNP can change it at will without having an unnecessary and confusing field. diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 1e8b26b93b4f..0bec0b71577e 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2593,13 +2593,6 @@ void sev_es_init_vmcb(struct vcpu_svm *svm) svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_SEV_ES_ENABLE; svm->vmcb->control.virt_ext |= LBR_CTL_ENABLE_MASK; - /* - * An SEV-ES guest requires a VMSA area that is a separate from the - * VMCB page. Do not include the encryption mask on the VMSA physical - * address since hardware will access it using the guest key. - */ - svm->vmcb->control.vmsa_pa = __pa(svm->vmsa); - /* Can't intercept CR register access, HV can't modify CR registers */ svm_clr_intercept(svm, INTERCEPT_CR0_READ); svm_clr_intercept(svm, INTERCEPT_CR4_READ); @@ -2633,6 +2626,13 @@ void sev_es_init_vmcb(struct vcpu_svm *svm) void sev_es_vcpu_reset(struct vcpu_svm *svm) { + /* + * An SEV-ES guest requires a VMSA area that is a separate from the + * VMCB page. Do not include the encryption mask on the VMSA physical + * address since hardware will access it using the guest key. + */ + svm->vmcb->control.vmsa_pa = __pa(svm->vmsa); + /* * Set the GHCB MSR value as per the GHCB specification when emulating * vCPU RESET for an SEV-ES guest. > Signed-off-by: Tom Lendacky This needs your SoB.