* [PATCH V2] KVM: SEV: Disable KVM_CAP_VM_COPY_ENC_CONTEXT_FROM for SEV-ES
@ 2021-09-14 19:01 Peter Gonda
2021-09-14 19:12 ` Sean Christopherson
2021-09-14 19:54 ` Marc Orr
0 siblings, 2 replies; 3+ messages in thread
From: Peter Gonda @ 2021-09-14 19:01 UTC (permalink / raw)
To: kvm
Cc: Peter Gonda, Marc Orr, Paolo Bonzini, Sean Christopherson,
Nathan Tempelman, Brijesh Singh, stable, linux-kernel
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 <pgonda@google.com>
Cc: Marc Orr <marcorr@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Nathan Tempelman <natet@google.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] KVM: SEV: Disable KVM_CAP_VM_COPY_ENC_CONTEXT_FROM for SEV-ES
2021-09-14 19:01 [PATCH V2] KVM: SEV: Disable KVM_CAP_VM_COPY_ENC_CONTEXT_FROM for SEV-ES Peter Gonda
@ 2021-09-14 19:12 ` Sean Christopherson
2021-09-14 19:54 ` Marc Orr
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2021-09-14 19:12 UTC (permalink / raw)
To: Peter Gonda
Cc: kvm, Marc Orr, Paolo Bonzini, Nathan Tempelman, Brijesh Singh,
stable, linux-kernel
On Tue, Sep 14, 2021, 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.
mirror's, or I guess mirrors'? :-)
> Fixes: 54526d1fd593 ("KVM: x86: Support KVM VMs sharing SEV context")
>
> V2:
> * Updated changelog with more information and added stable CC.
Nit, but this in the section ignored by git (below the ---) so that omitted from
the committed changelog.
> Signed-off-by: Peter Gonda <pgonda@google.com>
> Cc: Marc Orr <marcorr@google.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Sean Christopherson <seanjc@google.com>
> Cc: Nathan Tempelman <natet@google.com>
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Cc: kvm@vger.kernel.org
> Cc: stable@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
Reviewed-by: Sean Christopherson <seanjc@google.com>
> ---
Git ignores stuff in this section.
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2] KVM: SEV: Disable KVM_CAP_VM_COPY_ENC_CONTEXT_FROM for SEV-ES
2021-09-14 19:01 [PATCH V2] KVM: SEV: Disable KVM_CAP_VM_COPY_ENC_CONTEXT_FROM for SEV-ES Peter Gonda
2021-09-14 19:12 ` Sean Christopherson
@ 2021-09-14 19:54 ` Marc Orr
1 sibling, 0 replies; 3+ messages in thread
From: Marc Orr @ 2021-09-14 19:54 UTC (permalink / raw)
To: Peter Gonda
Cc: kvm list, Paolo Bonzini, Sean Christopherson, Nathan Tempelman,
Brijesh Singh, stable, LKML
On Tue, Sep 14, 2021 at 12:01 PM Peter Gonda <pgonda@google.com> 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 <pgonda@google.com>
> Cc: Marc Orr <marcorr@google.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Sean Christopherson <seanjc@google.com>
> Cc: Nathan Tempelman <natet@google.com>
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> 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 <marcorr@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-14 19:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 19:01 [PATCH V2] KVM: SEV: Disable KVM_CAP_VM_COPY_ENC_CONTEXT_FROM for SEV-ES Peter Gonda
2021-09-14 19:12 ` Sean Christopherson
2021-09-14 19:54 ` Marc Orr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).