Skip to content

Commit 2e4d880

Browse files
Janosch FrankMartin Schwidefsky
authored andcommitted
KVM: s390: Fix guest migration for huge guests resulting in panic
While we can technically not run huge page guests right now, we can setup a guest with huge pages. Trying to migrate it will trigger a VM_BUG_ON and, if the kernel is not configured to panic on a BUG, it will happily try to work on non-existing page table entries. With this patch, we always return "dirty" if we encounter a large page when migrating. This at least fixes the immediate problem until we have proper handling for both kind of pages. Fixes: 15f36eb ("KVM: s390: Add proper dirty bitmap support to S390 kvm.") Cc: <[email protected]> # 3.16+ Signed-off-by: Janosch Frank <[email protected]> Acked-by: Christian Borntraeger <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 7afbeb6 commit 2e4d880

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

arch/s390/mm/pgtable.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,29 @@ void ptep_zap_key(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
608608
bool test_and_clear_guest_dirty(struct mm_struct *mm, unsigned long addr)
609609
{
610610
spinlock_t *ptl;
611+
pgd_t *pgd;
612+
pud_t *pud;
613+
pmd_t *pmd;
611614
pgste_t pgste;
612615
pte_t *ptep;
613616
pte_t pte;
614617
bool dirty;
615618

616-
ptep = get_locked_pte(mm, addr, &ptl);
619+
pgd = pgd_offset(mm, addr);
620+
pud = pud_alloc(mm, pgd, addr);
621+
if (!pud)
622+
return false;
623+
pmd = pmd_alloc(mm, pud, addr);
624+
if (!pmd)
625+
return false;
626+
/* We can't run guests backed by huge pages, but userspace can
627+
* still set them up and then try to migrate them without any
628+
* migration support.
629+
*/
630+
if (pmd_large(*pmd))
631+
return true;
632+
633+
ptep = pte_alloc_map_lock(mm, pmd, addr, &ptl);
617634
if (unlikely(!ptep))
618635
return false;
619636

0 commit comments

Comments
 (0)