Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3122293pxb; Tue, 21 Sep 2021 15:15:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5JrMQDwkB87lGgqldt7eazBRfsG+C+aemYj30mg+enEC/TynNOMctv/Ly0ZaMtkj2syuC X-Received: by 2002:a17:906:e01:: with SMTP id l1mr38658609eji.456.1632262526673; Tue, 21 Sep 2021 15:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632262526; cv=none; d=google.com; s=arc-20160816; b=xcmgF+kWQtrnXjAjsYDh4QCIJdXQBHKmdO+BykmmS/zwm82z32p0NEVvwo8NSs0JSh kKHQeqrGsD7VX9eG+8FEJmkOXeszyaFQAWT7xaIhaa7U/cyE3tNTLEY5FQC54z84Zztu ylkRwVvV6TMciJU5Mik7NIaryVAamSKy7JNdEjNHZA3JKLnz+NpfJSiQdtIWma/e4xwe dM7D1hBO1wSOIcnqCGNIYFTlifkrrReuDtd0X2CDBvyse9kdDGVi/V5qLH3D13oThPug ZJmWGHCGT7wNPMhGYlw25qgjOFyLDqhS2qDhTiFbDWVuadQJ10C/Kp53fTMAZ4dZXGWa 4yzg== 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=B/sF6vDBPQtENY4PnJ/8XwK3HbUXNlrJIJQBSSE9vbI=; b=Wrwoxdl8KqkWXOxqpbh3xruC/Hc+4b/vXwboTKoN4+Mzu8wLlWarloja1Nu0QqJeMA +Y40Asa+qVQ/SIN5aYWbqHThQchCTVLVgpSB1LSDC6RIRuC54vMBzotl9KQaLm5iWhHD XKC4RHUBS+7Iu5aiyZVBLTNkqycpDJ2VZRBM6ICBsplOt9KHL7qplirfBD8RrKKyzZDU y0/Hj8iGvxL3caPdfwJApMZ2NYBpXRMyJm2SZm0bYK9TmKtefJDjj4R17ndCoeWmI782 nXNw5y2yRcDo6gK8sF/hFDtE3G+NoLAJSVXmiUy1KqaZN78nFpOePeRZLaweg+z6zkAj Ww+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fWbX0xDo; 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 og14si300989ejc.176.2021.09.21.15.15.01; Tue, 21 Sep 2021 15:15:26 -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=fWbX0xDo; 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 S234457AbhIUT0j (ORCPT + 99 others); Tue, 21 Sep 2021 15:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbhIUT0i (ORCPT ); Tue, 21 Sep 2021 15:26:38 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14866C061574 for ; Tue, 21 Sep 2021 12:25:10 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id k23-20020a17090a591700b001976d2db364so396585pji.2 for ; Tue, 21 Sep 2021 12:25:10 -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=B/sF6vDBPQtENY4PnJ/8XwK3HbUXNlrJIJQBSSE9vbI=; b=fWbX0xDo8U2ZnatPjBX47UgYg0iqOdULfaRNfdpJXUzsFOqbQPBZ5ulMrwJn54SyKw 2Ens85w8fQYitomjl4iqqi4CFhLAL1jdYyn70mbZqZmmGFB0sJZyrMDrtioTEtAg27iB ITkv3xNUTLfyvrkKZhPXpUccMJ9rYy/u9iJfTrabLsop51SSGrgfQ6hYp56r61tdp07s xT+JJCdAG5MeIKSbvQfMURQQPQz0ROVosg4sMZ+Nqy9DxuZitSI4NUVliJYCAFK41vjm DjvpEE2KClktTISKx5zsWcdt7GedXa4QuiHE4dozH6Jol3VKPo0epJHXqiZkOlvzWyYf 0BGw== 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=B/sF6vDBPQtENY4PnJ/8XwK3HbUXNlrJIJQBSSE9vbI=; b=Owzcj+/s15GS5x6MseNp3s1k/hYxWIYNksaL1floO4w+PEDqosFELVxhBwsnlsUvBu jhmVCGwrkU5D6wPKBXp8e88KAoWs9Kj50kzyCuqIqBCBW/whHiVW5EUXYjFsm/9swB/v KxVBiKfcxq6x9o4VYua7eSmKfXooQD/22GtRRoCKvkYuBwun32W2en4T3jUnls1ACSEt tXMOCmwrsXcwvxUKYZ0WqGNZHsbitmxSocuNrG6Kt5dB8CYvFLXYr4zMQKDaZ+CKt9jg iX8SyLcr/LTzezq+CV2ygaM5ad3bTXTHzZnS/NkGRbTRF9yqTBUMmAhfl7zaNsSjlze9 zCiw== X-Gm-Message-State: AOAM530YxmjNauxiuyQzBiybtvookAT4DJFuclZPxOOPX0f15SkFqhHL ydiJ6UFOJml9rhk4kMOJ6IlrcDI6D6hHm2LKoxXuUw== X-Received: by 2002:a17:90b:4b51:: with SMTP id mi17mr7088788pjb.120.1632252309287; Tue, 21 Sep 2021 12:25:09 -0700 (PDT) MIME-Version: 1.0 References: <20210921150345.2221634-1-pgonda@google.com> <20210921150345.2221634-2-pgonda@google.com> In-Reply-To: <20210921150345.2221634-2-pgonda@google.com> From: Nathan Tempelman Date: Tue, 21 Sep 2021 12:24:58 -0700 Message-ID: Subject: Re: [PATCH 1/2] KVM: SEV: Update svm_vm_copy_asid_from for SEV-ES To: Peter Gonda Cc: kvm , Marc Orr , Paolo Bonzini , Sean Christopherson , Steve Rutherford , Brijesh Singh , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 21, 2021 at 8:03 AM Peter Gonda wrote: > > 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 > --- > arch/x86/kvm/svm/sev.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 75e0b21ad07c..08c53a4e060e 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -1715,8 +1715,7 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) > { > 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); > @@ -1739,7 +1738,8 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) > 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 > @@ -1759,8 +1759,16 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) > /* 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; > -- > 2.33.0.464.g1972c5931b-goog > Looks good. Thanks for doing this Peter. Reviewed-by: Nathan Tempelman