Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1028084pxb; Thu, 9 Sep 2021 18:25:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMXxObjtICIX2vkFChtIy5YmMKVembt0NV395rMcMi7Qix1Fwrf3xRRTaPLtgfGUeyRZTI X-Received: by 2002:a17:907:4ce:: with SMTP id vz14mr6763633ejb.552.1631237109691; Thu, 09 Sep 2021 18:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631237109; cv=none; d=google.com; s=arc-20160816; b=MvKLFwnrZgyu6kML2SNAoLzE97EnIiaIDDbhK7lfrdAftHG0844DLqDj2tKwBibYx2 XbuAW3Fp8Ea4DtedbteTchVcWSoYejTUIWxBpLVjkHoIPudI6ulcSKqBfHPQ6uw7fmVh +zthgzJLRBzI4vz3FrL/eYp+wphgarpwPpRWsKTiGIXZz7t+o2e66fl2ql3Y6QCeHJUl /Gdzjx0wjkEtgza4NtKxffuozjhWHo5Pqo9u8XMo95dTwVKyIja1RRbBCaIvHDj14zMs F3YFCSzfHuKIa/AJa2ZecBDCEsxVm2o7TvBkg52skLzxgmND+twY8/RYS4VgZ+0Fh4fr msgw== 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=l1BaiJ0gkfVc+LassnfOFyf+t5gSZ1M94cRU4Np2S3E=; b=JisBAIusclY7Qg49PLzvqWrThf78Oe6llA+xLU4KVWnT8IzJjE0dQERvrGnjChdz3e PD1cq7Y+41Am2pwpKeFP6S7CAPBsYYg8POI34B4wBOlJlt20FBOu/7Fxd8J+IBqApviY 4WtAJ7ugmkD4xjl+DRYcNKC83W9j0r2Wqehz2WAcJ5IeghTUL1hbppqBNQc0aSfgqfZC Wq4J4DLdTK8GtiYdbETl5Hzzs8k2muEQoCiIGYeYR4wW7jaFg2xafdPLyDB97d5HMk99 j1cFWsUbcXlX7R0i0NlEM4kILUHN566o50x63+a6xexBnfgsdz+ZXqjDXzo0LGroAj6/ V2nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=lRZULPzq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 ze16si3627459ejb.96.2021.09.09.18.24.45; Thu, 09 Sep 2021 18:25:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=20210112 header.b=lRZULPzq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S229609AbhIJBYb (ORCPT + 99 others); Thu, 9 Sep 2021 21:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239042AbhIJBXx (ORCPT ); Thu, 9 Sep 2021 21:23:53 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6689C0613A8 for ; Thu, 9 Sep 2021 18:20:12 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id n18so317545pgm.12 for ; Thu, 09 Sep 2021 18:20:12 -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=l1BaiJ0gkfVc+LassnfOFyf+t5gSZ1M94cRU4Np2S3E=; b=lRZULPzquMYXgjWpDLxvVy0w2xSJmX+cTY5Vo1mT7JVv4iOOIHpuhallgZBWM3UV8Y g5zvaF+AXZmGPXoF994p9zbyTSrNg8eVjDoMXkbVaEsLKkQCyiKxoRk/O64LYQHWIoRX mLEMDAFihI3lvz0+x1U5zk/YbBx7jug7JGvgdOoUSm2BCSQT/gxzv3Cya28Z00vjvrxs NJFh8f7d2Hkk4j4eVYdvR47Z2FK8lHFIkp6oS+ZkEhFLzlhwYHMPgiiac2Q2vWK8KOcF BGRnQZc6E3IkALkdxl6TZ3cPslOydT7LcxHiZBq/0v4cW4nWvV5or2vXVLTwbyPd7NyD qGlQ== 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=l1BaiJ0gkfVc+LassnfOFyf+t5gSZ1M94cRU4Np2S3E=; b=ot4+HFh9NMHlMhSNgGqe+YavHa3RIHwxaRrf2c0jI7m/Jpuz31wyzsHE07ifFKOTnd Zr60+TBdgRZmjNUpQRy0ZwvLxA3IL7tYPLZ1CeQTHIhVZ+llZBcTPxWEVgZH2O1/FCsr WOU3B1Gwt92NC5UtXZsxa6JAxNZHBxG54s41uInhziGM9/JAYGicGPgg0FgvXKrVmune deZjjr2Apa+Ep8Kq2idA0QH10YsS3Ug51rbWewKExOB0Z7srrSerxAaN0wByUXLredVx HahutAWHUtzVxLG2YE7f94XBO/fssYxWtiwLTodm/mim+EaxtUA7YKeS7/MwSHui0QQV 5+/g== X-Gm-Message-State: AOAM53007Mmhg6H/zVzUZB0z9r0oTRPUkoSjfBYxLOf9SaO2q3sHorRX 2lSPeZwNY6atv+VLFWDf2RC6LQ== X-Received: by 2002:a05:6a00:1789:b0:3f9:5ce1:9677 with SMTP id s9-20020a056a00178900b003f95ce19677mr5738445pfg.50.1631236812187; Thu, 09 Sep 2021 18:20:12 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id w24sm3381673pjh.30.2021.09.09.18.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 18:20:11 -0700 (PDT) Date: Fri, 10 Sep 2021 01:20:07 +0000 From: Sean Christopherson To: Peter Gonda Cc: kvm@vger.kernel.org, Marc Orr , Paolo Bonzini , David Rientjes , "Dr . David Alan Gilbert" , Brijesh Singh , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3 V7] KVM, SEV: Add support for SEV-ES intra host migration Message-ID: References: <20210902181751.252227-1-pgonda@google.com> <20210902181751.252227-3-pgonda@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 10, 2021, Sean Christopherson wrote: > On Thu, Sep 02, 2021, Peter Gonda wrote: > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > > index 8db666a362d4..fac21a82e4de 100644 > > --- a/arch/x86/kvm/svm/sev.c > > +++ b/arch/x86/kvm/svm/sev.c > > @@ -1545,6 +1545,59 @@ static void migrate_info_from(struct kvm_sev_info *dst, > > list_replace_init(&src->regions_list, &dst->regions_list); > > } > > > > +static int migrate_vmsa_from(struct kvm *dst, struct kvm *src) Better to call this sev_es_migrate_from()... > > +{ > > + int i, num_vcpus; > > + struct kvm_vcpu *dst_vcpu, *src_vcpu; > > + struct vcpu_svm *dst_svm, *src_svm; > > + ...because this should also clear kvm->es_active. KVM_SEV_INIT isn't problematic (as currently written) because the common sev_guest_init() explicitly writes es_active, but I think a clever userspace could get an SEV ASID into an "ES" guest via KVM_CAP_VM_COPY_ENC_CONTEXT_FROM, which requires its dst to be !SEV and thus doesn't touch es_active. Huh, that's a bug, svm_vm_copy_asid_from() should explicitly disallow copying the ASID from an SEV-ES guest. I'll send a patch for that. Last thought, it's probably worth renaming migrate_info_from() to sev_migrate_from() to pair with sev_es_migrate_from().