Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3343309yba; Mon, 6 May 2019 22:53:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzboBfyFjIX88VzehtgrSAo/EEUvXxtx/2ONrc3KAafOTbjlfFJXmlU5UPO6PRgnOW9lHdc X-Received: by 2002:a63:2c4c:: with SMTP id s73mr37339477pgs.42.1557208417262; Mon, 06 May 2019 22:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557208417; cv=none; d=google.com; s=arc-20160816; b=d/o/FdvgPwzmbAYeSUwNtjrr8uw2lvIEOTqkAC8bQgBrWQOUXHje2Cmdn2mHuEtqJU cbWbK5j02hVpBdqlz7ESoQOBD1St7qToPA4lG0y/ABy8FDSHtTu5csIIVid7yG/qRbk4 zjqpPTtmkSZcdPaBXA+iEgKUfQc5fbBHyu4TFFskItj5gk1UckO9FD4GB3tDTKRcb0P8 gRKuIjP+hKquYnR/maLh6w5NezopBdN/HyAmFHXsCNEYAFy/ooH5QZP1zD/lBeUVHdPo J7G7aZu7JJsW0wQ6yDOnLc4Lf2bNkjRW5G5F0qpFygPtn3KTcOG2ZYjNz9qYchKt363M rquw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7JoQnsBYb56eGkfiG9tgcR9JwE0uIVsk5lOqia94zLc=; b=AWpRHWhG8Sn29oUEkIjgAcW0xU087wpoBZUF2tJy6dPIReRe08ZZlwCjy4cN1gsuql EHGbqNhbjljgq2aqryPGbwceMzjU92CpcbttnJIzA/jFBjNepCnuvGrvm/i1TwcDAoeA ifBNQf9wjbCfLIC1yxCRppSAYkc+usz3yvb846LcLpibhOr46qC2+UGwG9aBWOPt8CTG jzT7mxk0LyK0lsGXYX/WZABrCxH4g/dEzI47J4+tXeAws4pmbGhE+SqHj6Ux9Ltt7mmq U9MsUy/2DUhcFUkF8Kdn7O9+QfHoveXiIwvz9iVFCYo3SG5SztXChtmx66ZGsf9PtBDb TSgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZKw/35Px"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si19482959pgm.264.2019.05.06.22.53.22; Mon, 06 May 2019 22:53:37 -0700 (PDT) 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="ZKw/35Px"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727598AbfEGFj4 (ORCPT + 99 others); Tue, 7 May 2019 01:39:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:59400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728955AbfEGFjx (ORCPT ); Tue, 7 May 2019 01:39:53 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E365C20675; Tue, 7 May 2019 05:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557207592; bh=vKWZ4BWnbyXlrZc2cSKReqfH0T75dQxJ0StJrorzd2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZKw/35PxTMlp7PORDasrUhGGCvWyGfqOsQGR6YlTSySwsLocBizbr/r4qBazLPTS6 NFfMfDDwlaRGQJGR1zIXGeCBb6y+gXBrRrCLG9TEsWsb1IT7TBvqqeRu1k9Doer1w4 kq0YtvbSesdA1plu5QT+WSDd5Z9LCBnwvoDfk5n8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Punit Agrawal , Suzuki Poulose , Christoffer Dall , Marc Zyngier , Sasha Levin , kvmarm@lists.cs.columbia.edu Subject: [PATCH AUTOSEL 4.14 42/95] KVM: arm/arm64: Ensure only THP is candidate for adjustment Date: Tue, 7 May 2019 01:37:31 -0400 Message-Id: <20190507053826.31622-42-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190507053826.31622-1-sashal@kernel.org> References: <20190507053826.31622-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Punit Agrawal [ Upstream commit fd2ef358282c849c193aa36dadbf4f07f7dcd29b ] 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: Sasha Levin --- virt/kvm/arm/mmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 225dc671ae31..1f4cac53b923 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1068,8 +1068,14 @@ static bool transparent_hugepage_adjust(kvm_pfn_t *pfnp, phys_addr_t *ipap) { 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 -- 2.20.1