Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3983419pxb; Mon, 4 Oct 2021 14:24:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa3j7SI3hz32ZdsziEOD+fuOMAl8CdTXO3cjIUHXC8dgJypwokPH0jQXnZ7CDEVv7tk0cw X-Received: by 2002:a62:64d3:0:b0:43d:ba3:1e2c with SMTP id y202-20020a6264d3000000b0043d0ba31e2cmr26770396pfb.5.1633382657013; Mon, 04 Oct 2021 14:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633382657; cv=none; d=google.com; s=arc-20160816; b=Sb+jFTM/luOVrWaTRQ+XaUYcISs0e/EQiq5Acj8fR1WVTqv0+4CYdi+HTYZO9jweTJ kqOPGE04+skiPau+t1Xh+o6GvLXo2HPS8lEC9ML1MJCCDfPViUm5loY8RJgimNWRw7VR 63xpFaMRdwbdkQ1iVuhhiu+HBm2ipi/Mr8cYZx3WrIudNA7KP+FqpNfSCe4l4m0mYIJW 9dHIyBUa42I49WL54DOWvJBFQU1VQK1vYSj0dYse6iwgMq1jkvZugbmcl3oZel38QIgW VdvOfbM0mahMQiv/YrKEY/20HzKWijwmVXXdTaabzC3TnxALCHNfGhtvqNOxe/6l5SHZ haQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bF3EuxBdKb/k5RjK3vaaf4Qfpb+mQime+yvBHKGzYvU=; b=06T7z+3SzM5PtjVknH4oUIbjU99QBzL1OsZ5VBjaJiX5L9Kev4feLi3zsB6y2vBCLg 8RWJTEgHvQdiBCAUJSUoIUeUIUu/y1JZ2WYNFkQY1Y4GpyjOrvf67nvNjI5NH/WA8E+i 6CuVVU+SXXM81xAaw3SbqHzNB/yvTYSjyaXu+94vG/No9Ej018nhmk0yplUp+g8rHdcK ciHpTSM4LddkxY9aVI+jzNi6qfV+mgPoTVxwwagsVeKSIURefLCC6VJgurRdfvWJN2pU t2PxEqrUz79lIOL6sA34Iw85FfcnsrYVz8Cj5CyYGPXYdWptC71P7to7a3ASXKe1j++V KUCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AWeRcMqV; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si8468051plb.118.2021.10.04.14.24.02; Mon, 04 Oct 2021 14:24:16 -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=@linuxfoundation.org header.s=korg header.b=AWeRcMqV; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235167AbhJDNd6 (ORCPT + 99 others); Mon, 4 Oct 2021 09:33:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:47302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236873AbhJDNbo (ORCPT ); Mon, 4 Oct 2021 09:31:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 67BA4619E9; Mon, 4 Oct 2021 13:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353256; bh=NC8HZAlr1M0y90qa5JDrm8ws99TMSgsm6w3N1CJm7HY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AWeRcMqV1S4YXl7P0b24wKycC4hXtoHBX71SP5OTgYwH+PVVr+NXS4fBO9yG/aaCC TKlQtxH4XoouLWVqNDZI8GCw87jFV8qrRw8D/l6ffIoI+NQrGIuBcVECVaEMDN7298 MQBxOnbKa3jtxt8DFzyy4mQmG1YzTMXke/Uhc7zM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Gonda , Marc Orr , Nathan Tempelman , Paolo Bonzini , Sean Christopherson , Steve Rutherford , Brijesh Singh , kvm@vger.kernel.org Subject: [PATCH 5.14 055/172] KVM: SEV: Update svm_vm_copy_asid_from for SEV-ES Date: Mon, 4 Oct 2021 14:51:45 +0200 Message-Id: <20211004125046.774748468@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Gonda commit f43c887cb7cb5b66c4167d40a4209027f5fdb5ce upstream. For mirroring SEV-ES the mirror VM will need more then just the ASID. The FD and the handle are required to all the mirror to call psp commands. The mirror VM will need to call KVM_SEV_LAUNCH_UPDATE_VMSA to setup its vCPUs' VMSAs for SEV-ES. Signed-off-by: Peter Gonda Cc: Marc Orr Cc: Nathan Tempelman Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Steve Rutherford Cc: Brijesh Singh Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Fixes: 54526d1fd593 ("KVM: x86: Support KVM VMs sharing SEV context", 2021-04-21) Message-Id: <20210921150345.2221634-2-pgonda@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/sev.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1716,8 +1716,7 @@ int svm_vm_copy_asid_from(struct kvm *kv { struct file *source_kvm_file; struct kvm *source_kvm; - struct kvm_sev_info *mirror_sev; - unsigned int asid; + struct kvm_sev_info source_sev, *mirror_sev; int ret; source_kvm_file = fget(source_fd); @@ -1740,7 +1739,8 @@ int svm_vm_copy_asid_from(struct kvm *kv goto e_source_unlock; } - asid = to_kvm_svm(source_kvm)->sev_info.asid; + memcpy(&source_sev, &to_kvm_svm(source_kvm)->sev_info, + sizeof(source_sev)); /* * The mirror kvm holds an enc_context_owner ref so its asid can't @@ -1760,8 +1760,16 @@ int svm_vm_copy_asid_from(struct kvm *kv /* Set enc_context_owner and copy its encryption context over */ mirror_sev = &to_kvm_svm(kvm)->sev_info; mirror_sev->enc_context_owner = source_kvm; - mirror_sev->asid = asid; mirror_sev->active = true; + mirror_sev->asid = source_sev.asid; + mirror_sev->fd = source_sev.fd; + mirror_sev->es_active = source_sev.es_active; + mirror_sev->handle = source_sev.handle; + /* + * Do not copy ap_jump_table. Since the mirror does not share the same + * KVM contexts as the original, and they may have different + * memory-views. + */ mutex_unlock(&kvm->lock); return 0;