On 03/05/17 13:23, Jiri Slaby wrote:
From: Suzuki K Poulose <suzuki.poulose@xxxxxxx> This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 8b3405e345b5a098101b0c31b264c812bba045d9 upstream. In kvm_free_stage2_pgd() we don't hold the kvm->mmu_lock while calling unmap_stage2_range() on the entire memory range for the guest. This could cause problems with other callers (e.g, munmap on a memslot) trying to unmap a range. And since we have to unmap the entire Guest memory range holding a spinlock, make sure we yield the lock if necessary, after we unmap each PUD range. Fixes: commit d5d8184d35c9 ("KVM: ARM: Memory virtualization setup") Cc: Paolo Bonzini <pbonzin@xxxxxxxxxx> Cc: Marc Zyngier <marc.zyngier@xxxxxxx> Cc: Christoffer Dall <christoffer.dall@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx> [ Avoid vCPU starvation and lockup detector warnings ] Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx> Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx> Signed-off-by: Christoffer Dall <cdall@xxxxxxxxxx> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx> --- arch/arm/kvm/mmu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 683cac91a7f6..65f401ddb2a7 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -240,6 +240,14 @@ static void stage2_flush_memslot(struct kvm *kvm, do { next = kvm_pgd_addr_end(addr, end); stage2_flush_puds(kvm, pgd, addr, next); + /* + * If we are dealing with a large range in + * stage2 table, release the kvm->mmu_lock + * to prevent starvation and lockup detector + * warnings. + */ + if (kvm && (next != end)) + cond_resched_lock(&kvm->mmu_lock); } while (pgd++, addr = next, addr != end); }
This is wrong. Did you get a warning when you applied the original patch ? The hunk should be applied to unmap_range(), something like : diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 683cac9..a10f5f1 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -181,6 +181,13 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp, do { next = kvm_pgd_addr_end(addr, end); unmap_puds(kvm, pgd, addr, next); + /* + * If we are dealing with a large range in stage2 table, + * release the kvm->mmu_lock to prevent starvation and + * lockup detector warnings. + */ + if (kvm && next != end) + cond_resched_lock(&kvm->mmu_lock); } while (pgd++, addr = next, addr != end); } Rest are fine. Do you want me to send the correct patch for 3.12 ? As such, the above hunk is based on 3.12. Suzuki