Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:32946 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751130AbdCPMyx (ORCPT ); Thu, 16 Mar 2017 08:54:53 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2GCs2cv110420 for ; Thu, 16 Mar 2017 08:54:51 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 297nkn1c4s-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 16 Mar 2017 08:54:51 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Mar 2017 12:54:49 -0000 From: Janosch Frank To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, borntraeger@de.ibm.com, schwidefsky@de.ibm.com, frankja@de.ibm.com Subject: [PATCH] KVM: s390: Fix guest migration for huge guests resulting in panic Date: Thu, 16 Mar 2017 13:53:44 +0100 In-Reply-To: <1489668824-39473-1-git-send-email-frankja@linux.vnet.ibm.com> References: <148956461915852@kroah.com> <1489668824-39473-1-git-send-email-frankja@linux.vnet.ibm.com> Message-Id: <1489668824-39473-2-git-send-email-frankja@linux.vnet.ibm.com> Sender: stable-owner@vger.kernel.org List-ID: 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.") Upstream-ID: 2e4d88009f57057df7672fa69a32b5224af54d37 Signed-off-by: Janosch Frank --- arch/s390/mm/pgtable.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 80fcdfb..6802530 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -1411,11 +1411,28 @@ EXPORT_SYMBOL_GPL(s390_enable_skey); */ bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *gmap) { + pgd_t *pgd; + pud_t *pud; + pmd_t *pmd; pte_t *pte; spinlock_t *ptl; bool dirty = false; - pte = get_locked_pte(gmap->mm, address, &ptl); + pgd = pgd_offset(gmap->mm, address); + pud = pud_alloc(gmap->mm, pgd, address); + if (!pud) + return false; + pmd = pmd_alloc(gmap->mm, pud, address); + if (!pmd) + return false; + /* We can't run guests backed by huge pages, but userspace can + * still set them up and then try to migrate them without any + * migration support. + */ + if (pmd_large(*pmd)) + return true; + + pte = pte_alloc_map_lock(gmap->mm, pmd, address, &ptl); if (unlikely(!pte)) return false; -- 2.7.4