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 X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06CB7C433F5 for ; Fri, 10 Sep 2021 01:23:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFF0060F02 for ; Fri, 10 Sep 2021 01:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231131AbhIJBYc (ORCPT ); Thu, 9 Sep 2021 21:24:32 -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-Google-Smtp-Source: ABdhPJzHzyqGH27s4iQz3a74J/nl5ISKqP8M0YqLRj+/BKN0zmR4qpUN/S5JSa+y73tnLcrpAgSpTg== 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().