svm: Add mutex_lock to protect apic_access_page_done on AMD systems
authorWei Wang <wawei@amazon.de>
Mon, 12 Nov 2018 12:23:14 +0000 (12:23 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Dec 2018 12:05:07 +0000 (13:05 +0100)
commit8e9de89fedfce75f2f8f5f7d9aa81a707c29de2a
tree6929e9001186018713f9f13026bb86457b7d462b
parentc0d75dacffb9cf3c0e3812ba0c7607c063cd7e9d
svm: Add mutex_lock to protect apic_access_page_done on AMD systems

commit 30510387a5e45bfcf8190e03ec7aa15b295828e2 upstream.

There is a race condition when accessing kvm->arch.apic_access_page_done.
Due to it, x86_set_memory_region will fail when creating the second vcpu
for a svm guest.

Add a mutex_lock to serialize the accesses to apic_access_page_done.
This lock is also used by vmx for the same purpose.

Signed-off-by: Wei Wang <wawei@amazon.de>
Signed-off-by: Amadeusz Juskowiak <ajusk@amazon.de>
Signed-off-by: Julian Stecklina <jsteckli@amazon.de>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/svm.c