Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3474338imu; Sun, 11 Nov 2018 15:56:56 -0800 (PST) X-Google-Smtp-Source: AJdET5d02h5Rs/HQ7jMjnphcKRA9NKKb6I9cx77Qd5EmNmLLaFMFpHE4Z7q8Mh5u3vj8L57/Kgml X-Received: by 2002:a17:902:7088:: with SMTP id z8-v6mr345328plk.329.1541980616103; Sun, 11 Nov 2018 15:56:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980616; cv=none; d=google.com; s=arc-20160816; b=SHfZoQumJD8+dDDJnTDdG+KoQRe8cKkw5cyiJA9QW9YeSHvOiDDo2c4VS+f+GPuCHk Sis3BYneQDNAWmf8AZh4IPnCAguT9PFcpmI07EXbj8G573PYiCfKDnKkOm02sGoPdscc NHZ5D+B5S+Vc6kx2m3+l+ias53kLgSkby6zX5gm24BDRyQ173ZjtPlrmcaLOMhykIVOS 720klANO0C941fAZ85gR81D3YKfZ5sLVbUAfF7a5DWJxQD4POuZ58F9Gb9VPHhQujt8l WofYqUQjtt67Vd4wXmnQhoYw5HAxSJ0mC+DByNWUIZWqqom5ZwH6+WqKb1q7ufWEWlPF 6TwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wpTSGrZIPssMWv0m186aoT8iS/Lnb5/3QBelO4lSBWA=; b=qEyaFXL9ZLcxrlcSYaM1s1JLEcTulqBj7VGqmBDz244YENwgXEm4ar7F4cChuMlQvN ZKoliCtXHZ9QsyenYij3zuDOAkNNmVbQeJcDvX+i7HS6RZGZXXwHfAiDEzHM9qH30mOt KIR4TIcxY7OlveHn9r0tElR3UUygqlAUuHIG9g1XNcEUqzA51L6iK0tWzXUGJ0N33ek7 Y/FtNlbDq8eUHeyfZjVxBUnusE6E7iBLli1CVNDPPRC0CHsS+id+2qf2UaJGiQIIhJ0F IiEw5tONKClrJktpijQkXxM1evjsE/ZJG4RPxnf8OCeb7UIwm7yXmHjD6rGHz5VfjKCG i5QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IfdiU+2D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si16498006plr.72.2018.11.11.15.56.41; Sun, 11 Nov 2018 15:56:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IfdiU+2D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732586AbeKLISP (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:35336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732500AbeKLISO (ORCPT ); Mon, 12 Nov 2018 03:18:14 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9A97B2154B; Sun, 11 Nov 2018 22:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975298; bh=h7KTtak/Qzq2PAW+79XirJLRO6wq8aZBds/9KFE+jdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfdiU+2D+EqAAKxEmJSp7gupaoX83ecyQQ4ahIKKMGyff4siKOYvkPz5buMO62sAU 001K/6cLSM2LlAlVFa8BFGtRZVcKCe87rYLm53jQWB858x0hqVpoSx7kYK8FGJPcoJ FC/lngJu1BwfrYsJUsuTvcTIOJCP3rSlhQx/u7jo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Punit Agrawal , Suzuki Poulose , Christoffer Dall , Marc Zyngier Subject: [PATCH 4.19 255/361] KVM: arm/arm64: Ensure only THP is candidate for adjustment Date: Sun, 11 Nov 2018 14:20:02 -0800 Message-Id: <20181111221653.516206078@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Punit Agrawal commit fd2ef358282c849c193aa36dadbf4f07f7dcd29b upstream. PageTransCompoundMap() returns true for hugetlbfs and THP hugepages. This behaviour incorrectly leads to stage 2 faults for unsupported hugepage sizes (e.g., 64K hugepage with 4K pages) to be treated as THP faults. Tighten the check to filter out hugetlbfs pages. This also leads to consistently mapping all unsupported hugepage sizes as PTE level entries at stage 2. Signed-off-by: Punit Agrawal Reviewed-by: Suzuki Poulose Cc: Christoffer Dall Cc: Marc Zyngier Cc: stable@vger.kernel.org # v4.13+ Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/mmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1230,8 +1230,14 @@ static bool transparent_hugepage_adjust( { kvm_pfn_t pfn = *pfnp; gfn_t gfn = *ipap >> PAGE_SHIFT; + struct page *page = pfn_to_page(pfn); - if (PageTransCompoundMap(pfn_to_page(pfn))) { + /* + * PageTransCompoungMap() returns true for THP and + * hugetlbfs. Make sure the adjustment is done only for THP + * pages. + */ + if (!PageHuge(page) && PageTransCompoundMap(page)) { unsigned long mask; /* * The address we faulted on is backed by a transparent huge