Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2650975pxj; Mon, 14 Jun 2021 04:04:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5CbGVyBWSs8KgS1gshFpzLSZ/drQqDnOBtnztq/lCG3JPNK4DKIDzVZ1A0EMo99abl0Ze X-Received: by 2002:a17:907:9618:: with SMTP id gb24mr15334252ejc.111.1623668650885; Mon, 14 Jun 2021 04:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623668650; cv=none; d=google.com; s=arc-20160816; b=bPXBIoPI4ZVQ860Q4xo/gukULyM5KcmU8sCjZBqoPlL8/m9kWOG83mhMGR3IpOsZwo +5Rq+RcHjq8TIeMFtDQ96OwQGCGsFocnhKbmlCq8WrsEbMEr1sYsMpGUHRjDWDEDLZBo 2U8j9Z1qistftm4aiUDvGRNHdk2cK7IC5SM/1aWk9Okm7KsAKJV5hQOlGrYFyscN8zFr Ghly2Yro7hecCrBO3RNOmNaVcGFbqvC2ZV5i1BRD3b4ViOwp0+H/iXHIB5ttnKtRgVAb ty2JCBr/rAl8XQ8HgjfgCYUUzikn6utf2Kxly2WvBaO7+aNBp2ULVmcMRnFXDKjcNXQn VYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SYW7clEcJZWCOyB/bISVVphg+MXaT1CFPerY1hqPLzw=; b=UD6kchmjqTd7hd3+QgErkFPtjyxM+onbBP2cse13UjoCUXQ1Ro6ydSyErNpArWpIeU Yh6y9J7MgYSpn0vPilSl2pgceTpbKH/5Huh7jKFwhj9M6mQMjpiD/2JXEjL2KQqAQkO4 cpik41oSR+IS7Fgsu/fGjz/hiXrk+3Ta2Vhuzd8znt7wVsU6sPb3MxyiOhI6+vyfOB1x I097gJcbveoSzek01OztW8FqagyxETzjpaH5avM0OTHovHotl9bxxsod9L8nbKB2WR4y KWRR4eaD/j8ZfjGYUCMWtLVvnh2KPeqW023ooAezfh1Z0NMRtg/aWDcG9Y0Dhufw1UKp xmRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=MWGgDm8b; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yc22si11583307ejb.277.2021.06.14.04.03.34; Mon, 14 Jun 2021 04:04:10 -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=@alien8.de header.s=dkim header.b=MWGgDm8b; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234611AbhFNLCb (ORCPT + 99 others); Mon, 14 Jun 2021 07:02:31 -0400 Received: from mail.skyhub.de ([5.9.137.197]:49150 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235206AbhFNLA1 (ORCPT ); Mon, 14 Jun 2021 07:00:27 -0400 Received: from zn.tnic (p200300ec2f09b9002609baded98d03dc.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:b900:2609:bade:d98d:3dc]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id A0E761EC0473; Mon, 14 Jun 2021 12:58:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1623668302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=SYW7clEcJZWCOyB/bISVVphg+MXaT1CFPerY1hqPLzw=; b=MWGgDm8baSNQ8T2XWCwE2vT7V1qzuf/nlGCI2H1oXH+eq9im62KqpOIArNcX+tMX12COYd XG9hBXjEXfyJyXL4o7HopQ7BaOuKofQh7qnu7ySAJix2e+FKOOI/Qq4rsMO4XE2FTtl/UF BzCXdMz28mmTrQXsoHPyEgJ75mtprEc= Date: Mon, 14 Jun 2021 12:58:15 +0200 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, 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 , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , tony.luck@intel.com, npmccallum@redhat.com Subject: Re: [PATCH Part1 RFC v3 16/22] KVM: SVM: Create a separate mapping for the SEV-ES save area Message-ID: References: <20210602140416.23573-1-brijesh.singh@amd.com> <20210602140416.23573-17-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210602140416.23573-17-brijesh.singh@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jun 02, 2021 at 09:04:10AM -0500, Brijesh Singh wrote: > +/* Save area definition for SEV-ES and SEV-SNP guests */ > +struct sev_es_save_area { Can we agree on a convention here to denote SEV-ES and later variants VS earlier ones so that you don't have "SEV-ES" in the name sev_es_save_area but to mean that this applies to SNP and future stuff too? What about SEV-only guests? I'm assuming those use the old variant. Which would mean you can call this struct prot_guest_save_area or so, so that it doesn't have "sev" in the name and so that there's no confusion... Ditto for the size defines. > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 5bc887e9a986..d93a1c368b61 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -542,12 +542,20 @@ static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp) > > static int sev_es_sync_vmsa(struct vcpu_svm *svm) Not SEV-ES only anymore, so I guess sev_snp_sync_vmca() or so. > - struct vmcb_save_area *save = &svm->vmcb->save; > + struct sev_es_save_area *save = svm->vmsa; > > /* Check some debug related fields before encrypting the VMSA */ > - if (svm->vcpu.guest_debug || (save->dr7 & ~DR7_FIXED_1)) > + if (svm->vcpu.guest_debug || (svm->vmcb->save.dr7 & ~DR7_FIXED_1)) > return -EINVAL; > > + /* > + * SEV-ES will use a VMSA that is pointed to by the VMCB, not > + * the traditional VMSA that is part of the VMCB. Copy the > + * traditional VMSA as it has been built so far (in prep > + * for LAUNCH_UPDATE_VMSA) to be the initial SEV-ES state. Ditto - nomenclature. > + */ > + memcpy(save, &svm->vmcb->save, sizeof(svm->vmcb->save)); > + > /* Sync registgers */ ^^^^^^^^^^ typo. Might as well fix while at it. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette