Skip to content

Commit b0e8570

Browse files
Janosch Frankgregkh
authored andcommitted
KVM: s390: Fix guest migration for huge guests resulting in panic
commit 2e4d88009f57057df7672fa69a32b5224af54d37 upstream. 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: <stable@vger.kernel.org> # 3.16+ Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 61fbad6 commit b0e8570

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

arch/s390/mm/pgtable.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,11 +1237,28 @@ EXPORT_SYMBOL_GPL(s390_reset_cmma);
12371237
*/
12381238
bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *gmap)
12391239
{
1240+
pgd_t *pgd;
1241+
pud_t *pud;
1242+
pmd_t *pmd;
12401243
pte_t *pte;
12411244
spinlock_t *ptl;
12421245
bool dirty = false;
12431246

1244-
pte = get_locked_pte(gmap->mm, address, &ptl);
1247+
pgd = pgd_offset(gmap->mm, address);
1248+
pud = pud_alloc(gmap->mm, pgd, address);
1249+
if (!pud)
1250+
return false;
1251+
pmd = pmd_alloc(gmap->mm, pud, address);
1252+
if (!pmd)
1253+
return false;
1254+
/* We can't run guests backed by huge pages, but userspace can
1255+
* still set them up and then try to migrate them without any
1256+
* migration support.
1257+
*/
1258+
if (pmd_large(*pmd))
1259+
return true;
1260+
1261+
pte = pte_alloc_map_lock(gmap->mm, pmd, address, &ptl);
12451262
if (unlikely(!pte))
12461263
return false;
12471264

0 commit comments

Comments
 (0)