[PATCH] ARM: KVM: Don't BUG when p[um]d_none() in stage2_clear_pte()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When evincting pages from the host, we may end up in a situation
where a single page is getting evicted on multiple CPUs at the
same time.

Because we serialize the evictions by holding pgd_lock, we make
sure that all CPUs but the first one will see the page as already
gone. If that page was the last in a section, the section is removed
as well. And all other CPUs will hit the BUG_ON condition, like this:

[  312.189234] ------------[ cut here ]------------
[  312.203056] kernel BUG at arch/arm/kvm/mmu.c:382!
[  312.217134] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP THUMB2
[  312.235376] Modules linked in:
[  312.244515] CPU: 0    Not tainted  (3.6.0-rc3+ #40)
[  312.259118] PC is at stage2_clear_pte+0x128/0x134
[  312.273193] LR is at kvm_unmap_hva+0x97/0xa0
[  312.285967] pc : [<c001e10c>]    lr : [<c001ee0f>]    psr: 60000133
[  312.285967] sp : caa25998  ip : df97a028  fp : 00800000
[  312.320355] r10: 873b5b5f  r9 : c8654000  r8 : 01c55000
[  312.335990] r7 : 00000000  r6 : df249c00  r5 : c688fb80  r4 : df249ccc
[  312.355532] r3 : 00000000  r2 : 2e001000  r1 : 00000000  r0 : 00000000
[  312.375076] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment user
[  312.396962] Control: 70c5387d  Table: 8a9bbb00  DAC: fffffffd
[  312.414161] Process hackbench (pid: 7207, stack limit = 0xcaa242f8)

It is actually safe to remove the BUG_ONs and just return from the function
earlier.

Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
---
 arch/arm/kvm/mmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index e76c6a0..3610472 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -376,10 +376,12 @@ static void stage2_clear_pte(struct kvm *kvm, phys_addr_t addr)
 
 	pgd = kvm->arch.pgd + pgd_index(addr);
 	pud = pud_offset(pgd, addr);
-	BUG_ON(pud_none(*pud));
+	if (pud_none(*pud))
+		return;	 /* Probably evicted already by another CPU */
 
 	pmd = pmd_offset(pud, addr);
-	BUG_ON(pmd_none(*pmd));
+	if (pmd_none(*pmd))
+		return;	 /* Probably evicted already by another CPU */
 
 	pte = pte_offset_kernel(pmd, addr);
 	set_pte_ext(pte, __pte(0), 0);
-- 
1.7.12



_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux