[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181206143013.086132381@linuxfoundation.org>
Date: Thu, 6 Dec 2018 15:38:25 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Wei Wang <wawei@...zon.de>,
Amadeusz Juskowiak <ajusk@...zon.de>,
Julian Stecklina <jsteckli@...zon.de>,
Suravee Suthikulpanit <suravee.suthikulpanit@....com>,
Joerg Roedel <jroedel@...e.de>,
Paolo Bonzini <pbonzini@...hat.com>
Subject: [PATCH 4.9 026/101] svm: Add mutex_lock to protect apic_access_page_done on AMD systems
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Wang <wawei@...zon.de>
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@...zon.de>
Signed-off-by: Amadeusz Juskowiak <ajusk@...zon.de>
Signed-off-by: Julian Stecklina <jsteckli@...zon.de>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
Reviewed-by: Joerg Roedel <jroedel@...e.de>
Cc: stable@...r.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
arch/x86/kvm/svm.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1333,20 +1333,23 @@ static u64 *avic_get_physical_id_entry(s
static int avic_init_access_page(struct kvm_vcpu *vcpu)
{
struct kvm *kvm = vcpu->kvm;
- int ret;
+ int ret = 0;
+ mutex_lock(&kvm->slots_lock);
if (kvm->arch.apic_access_page_done)
- return 0;
+ goto out;
- ret = x86_set_memory_region(kvm,
- APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
- APIC_DEFAULT_PHYS_BASE,
- PAGE_SIZE);
+ ret = __x86_set_memory_region(kvm,
+ APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
+ APIC_DEFAULT_PHYS_BASE,
+ PAGE_SIZE);
if (ret)
- return ret;
+ goto out;
kvm->arch.apic_access_page_done = true;
- return 0;
+out:
+ mutex_unlock(&kvm->slots_lock);
+ return ret;
}
static int avic_init_backing_page(struct kvm_vcpu *vcpu)
Powered by blists - more mailing lists