]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: SEV: Do COPY_ENC_CONTEXT_FROM with both VMs locked
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Nov 2021 00:50:33 +0000 (19:50 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 30 Nov 2021 08:54:13 +0000 (03:54 -0500)
commit834e4aa9bfff4a366645729ded2c133729c8bd92
treed4cd3058da9309530a5cf6136eafee73f48321d5
parentfa1ec4a08573b147b5686cf4d6d1a033a72a660b
KVM: SEV: Do COPY_ENC_CONTEXT_FROM with both VMs locked

Now that we have a facility to lock two VMs with deadlock
protection, use it for the creation of mirror VMs as well.  One of
COPY_ENC_CONTEXT_FROM(dst, src) and COPY_ENC_CONTEXT_FROM(src, dst)
would always fail, so the combination is nonsensical and it is okay to
return -EBUSY if it is attempted.

This sidesteps the question of what happens if a VM is
MOVE_ENC_CONTEXT_FROM'd at the same time as it is
COPY_ENC_CONTEXT_FROM'd: the locking prevents that from
happening.

Cc: Peter Gonda <pgonda@google.com>
Cc: Sean Christopherson <seanjc@google.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211123005036.2954379-10-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/sev.c