Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp971862pxb; Tue, 14 Sep 2021 12:57:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6vDHmzgRb5KvFLVOGm9Jy+eCtFCtenA5R0pRmGlt3jSBt9N5eQ8d/QS9Vs3kPE25ORWtg X-Received: by 2002:a6b:5c17:: with SMTP id z23mr15001934ioh.3.1631649458348; Tue, 14 Sep 2021 12:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631649458; cv=none; d=google.com; s=arc-20160816; b=qa+8VycQqp5xtngScyoNaBiDe6mTcRMUS4gWKtdqRtNixVCpkgQIP55NXldYakXs4C Nui/42lYFvIKlvhS1KzqRZEyg0ywbtkSXyhDLBkm1makHbDGbCVHyK95C1s2UiUUAa1M crNJ/8AvNNa+RC6DBsN9W/2Sdn69cQAeO6U64xHeEBuppcriQ4hL1rSXjW2cx62fZWbC IGH7Q2O7KX8rPQ37xdAunyt2xgWCSxAxUDnCnNW7C9IYmgmE2FzrIdK/Z0c7axVadvdx 9S0yl2uUey5JsFi6sXfFtu4b9myslZzTyZ9qFsxW8AQZDMRa4j+kM+mNB1GSzXcj20ld YRNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xtR27z6ArnQBxxqRuhMNgUKk5tpQO0X2C1F4R+xD3JM=; b=BcknJwEntCUkeU/k2C8SLxcHOD3RCkaZhR6TaEgW+drh8eN5QdEg9X7n6VFTav4/dE YXjz38ZPuFuSGPAhHa7FIvYLrpMZVtLVvPHiriIjfGCj7I06A+JghYXnGK5lN3kRPLZU 7nmIHZC97QOLixDzNwjXvkxqtEQR8EK6UfaQG+lnsfE7t+iEFzfl1v3MKFP7AzHqCQLR 7oAYxTzukELC71k/Gs5oZL/OLETrN5afXjz4tPRK7k3aSwvKMqTZiUyHx2AX5+9tIYc4 p8L+nDZmBkF5LHcYrwHTUCMTu48fXzJvK6v6XJ5FIEdx3Pk4DUAbgET6yscELv+fEAD6 kthw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SCLn97FK; 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 187si10523938jaj.27.2021.09.14.12.57.25; Tue, 14 Sep 2021 12:57:38 -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=SCLn97FK; 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 S233095AbhINT4F (ORCPT + 99 others); Tue, 14 Sep 2021 15:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232050AbhINT4E (ORCPT ); Tue, 14 Sep 2021 15:56:04 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2D23C061574 for ; Tue, 14 Sep 2021 12:54:46 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id c79so778769oib.11 for ; Tue, 14 Sep 2021 12:54:46 -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; bh=xtR27z6ArnQBxxqRuhMNgUKk5tpQO0X2C1F4R+xD3JM=; b=SCLn97FK+hXMMlHmbUSLfHw7x68WBqS0hKDXIZGicXin4gluDW3vfgrkP2Ca4RSOpc XibbKhQs8gUw+nb8qarCB2xb87HrBOpLTbs25sC+4CrzbceexThTsvsv9Cdpo2QZahKQ 982mpMQRpEm/DlBtrRGoR2UVPQ9sd4kxxT00lfVsz1O9mPAVEzVAllr2p8tcS8MhweBs hOBITNlddkzMFCO6Spq57aTaCKRcmnK69vaaUSgFoBOb+8q59JHvx5eA/Fz67P65/ZN0 V3OhgYKPezO1iVjRd4iDkrNYZHd6MPS2W5rDJhUCjW7uq20J0SdaP/6dp4e+JEqOiLbz cIow== 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; bh=xtR27z6ArnQBxxqRuhMNgUKk5tpQO0X2C1F4R+xD3JM=; b=aZzsBNYaT51bj4kptjxUvDpT3KhzhBEEzESg2ciGY4E6xamXWHNMn3KwnNJihc1J0J lOE7OoRXGCIicKgT9TykOghS2Dt6c+wCrXbpMIvbEdP7gTe3oyewkitcXwa42DGuoEFk 1D3cMKz1/PPoJiZo5Gj5WRMvjX4JTQM7/kPGXRxd6oListrNL0czjxyeMuqksEKLoUX+ 3F9GTqrPKfKx5UNswiYKAmA21+djZJjfGh90+43Ekpq7n7MeCRiQ/GO+JhOvKfVNVr7E 2W2jTspecvLut0ovcv92nO24OSerd2x1tm5YqDtSYdza+2YBQ9AVEae+DUdLpcu5hyhY ciiA== X-Gm-Message-State: AOAM530WvRukX3+YBcCGQkgfuxXo7Be0o92NEIh/KgYbOGh1+EQ5C07P 877AfqszWz4vgfQOSnO+c3Qb7DJxUU5RjN0F+fAP2Q== X-Received: by 2002:a05:6808:909:: with SMTP id w9mr2742252oih.164.1631649286048; Tue, 14 Sep 2021 12:54:46 -0700 (PDT) MIME-Version: 1.0 References: <20210914190125.3289256-1-pgonda@google.com> In-Reply-To: <20210914190125.3289256-1-pgonda@google.com> From: Marc Orr Date: Tue, 14 Sep 2021 12:54:35 -0700 Message-ID: Subject: Re: [PATCH V2] KVM: SEV: Disable KVM_CAP_VM_COPY_ENC_CONTEXT_FROM for SEV-ES To: Peter Gonda Cc: kvm list , Paolo Bonzini , Sean Christopherson , Nathan Tempelman , Brijesh Singh , stable@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14, 2021 at 12:01 PM Peter Gonda wrote: > > Copying an ASID into new vCPUs will not work for SEV-ES since the vCPUs > VMSAs need to be setup and measured before SEV_LAUNCH_FINISH. Return an > error if a users tries to KVM_CAP_VM_COPY_ENC_CONTEXT_FROM from an > SEV-ES guest. The destination VM is already checked for SEV and SEV-ES > with sev_guest(), so this ioctl already fails if the destination is SEV > enabled. > > Enabling mirroring a VM or copying its encryption context with an SEV-ES > VM is more involved and should happen in its own feature patch if that's > needed. This is because the vCPUs of SEV-ES VMs need to be updated with > LAUNCH_UPDATE_VMSA before LAUNCH_FINISH. This needs KVM changes because > the mirror VM has all its SEV ioctls blocked and the original VM doesn't > know about the mirrors vCPUs. > > Fixes: 54526d1fd593 ("KVM: x86: Support KVM VMs sharing SEV context") > > V2: > * Updated changelog with more information and added stable CC. > > Signed-off-by: Peter Gonda > Cc: Marc Orr > Cc: Paolo Bonzini > Cc: Sean Christopherson > Cc: Nathan Tempelman > Cc: Brijesh Singh > Cc: kvm@vger.kernel.org > Cc: stable@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > arch/x86/kvm/svm/sev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 75e0b21ad07c..8a279027425f 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -1728,7 +1728,7 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) > source_kvm = source_kvm_file->private_data; > mutex_lock(&source_kvm->lock); > > - if (!sev_guest(source_kvm)) { > + if (!sev_guest(source_kvm) || sev_es_guest(source_kvm)) { > ret = -EINVAL; > goto e_source_unlock; > } > -- > 2.33.0.309.g3052b89438-goog > Reviewed-by: Marc Orr