Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp219702imm; Mon, 1 Oct 2018 08:55:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV63NBbe4Wpc2+FICHETwjfGOKcCJEbZt2gJFframrncAakKJUMKNS1ZlgiqbajuMGVF4EKb0 X-Received: by 2002:a62:21d1:: with SMTP id o78-v6mr12045494pfj.235.1538409351786; Mon, 01 Oct 2018 08:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538409351; cv=none; d=google.com; s=arc-20160816; b=G6MJXQMQiGZkhUtrI8kDu/h35l15lTh1hYXfUHZYLf0UlHNjmfmpfubsraV90qQt+9 wsM+CM7iVmk5LpH3VljEsPCWueEm9Rv00lldatw89rmaLDi3jxnsxg+STkyc+tRMGDSa GZ1R8+KkO+k+3PxJ9ORqtMP5rZ5XhIWnhx8GwhzsswDVfSo56vjgR0TqLzIxNAsmp41h 5nnmFEr4BtASUaocZiO3ixeP89bLyJ140h8dmV/+HkXDbs8ythB6tmSc6c92nO/fRl04 RpQRSv0mCvQ2EvJ2pAHCEuam3LCfrb7y9Qg3iGlK5cDuMrXk+xmhfSLGQ/L3mcvS+qbq 1wPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=xxy7im4qG0h13Hk1EL4SOOEQczX6EWNBkRFUe942GJM=; b=KtEWefM/3GfseHXhfQhjAczCPv8V8t9agRjnTfD7xOkQW6bJSKlkU9MVEjCz/af0tM h4V4ImErk52t59aJcCsdE4NQl+56Qp6nvrfwyjg3XlUyEj8pAEO6OZ7C8wVP6QWUvx6Y OgBvNRwOTH9VP6IWCznQPengJGXWNY5NIHqVsdh+8FUqT/ooSCRoGbSRjV4dUFv+oLdQ Y3Pw8tetNN5jAsUFxgLzPEdnP425tJPKCkhn9rU1/A1vySHBfGlyfORboEH6pZXXKiHP 3gTkgCgxzr+n5HjBF9DfJ76Gu3Px9JaONOQ51pqKcLJ0WrUW3wRSVjdz67V6d7tJb3Kv 9IBQ== ARC-Authentication-Results: i=1; mx.google.com; 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 p1-v6si12926516pfe.150.2018.10.01.08.55.36; Mon, 01 Oct 2018 08:55:51 -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; 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 S1726367AbeJAWdm (ORCPT + 99 others); Mon, 1 Oct 2018 18:33:42 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51788 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbeJAWdm (ORCPT ); Mon, 1 Oct 2018 18:33:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3ABB918A; Mon, 1 Oct 2018 08:55:15 -0700 (PDT) Received: from localhost (e105922-lin.emea.arm.com [10.4.13.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AC16B3F5D3; Mon, 1 Oct 2018 08:55:14 -0700 (PDT) From: Punit Agrawal To: kvmarm@lists.cs.columbia.edu Cc: Punit Agrawal , marc.zyngier@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com, Christoffer Dall , stable@vger.kernel.org Subject: [PATCH v8 1/9] KVM: arm/arm64: Ensure only THP is candidate for adjustment Date: Mon, 1 Oct 2018 16:54:35 +0100 Message-Id: <20181001155443.23032-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181001155443.23032-1-punit.agrawal@arm.com> References: <20181001155443.23032-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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+ --- 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 7e477b3cae5b..c23a1b323aad 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1231,8 +1231,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.18.0