Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2840686imm; Mon, 24 Sep 2018 10:46:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV60zJpgybNAr23kPq4r9Xb3Li1IX1K+sZ+d6bSyfgjcLjfEbMmQuVYQDyktF1B0pZjx8vQDO X-Received: by 2002:a17:902:4081:: with SMTP id c1-v6mr11685978pld.169.1537811199758; Mon, 24 Sep 2018 10:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537811199; cv=none; d=google.com; s=arc-20160816; b=Y8k7uDstvXnl71GA7Nue1bAIl8eoxjKTAdWBLAP1dRvsx8vb/zWBEVhZZjOyDYLnGd F/yUpBDfvN1ofyBTSppRz4QnKuG7+EVQSjuQl+nWo7cVnAmq1bB2B/UvpzQfHl4wTGda +jWnj4Pk9pSl9LxznTArT2kmB9T/wymwAoRTAlQ9ISZ993McuIuORLL9ZX1pJHCUrLGL fbwZVX39pwelAFykD8sQebOJawsAvV/ZYZHJ7sYVwhfHYO4msOV9XmNlwGv9G/1Qligh feQ5h8aBpKBN2mjHzgHCVGumyoU4ayK173YFfdSAK2OIzBIsEwyEdo6ZEx6VeOmNVrBN YQVA== 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=whTy1orvVIdRGgh7ELlBopUN2PG/jjVz8LuYU9WIsq4=; b=O981p/slTmuIL7uWXXBRYMbFu/ueKX81t/bLIIX+j6Zz8dMNnUnE1ccJxKqaV0shSh TdJB9ESoFrnxnOt1unaKlVhxhI/4qWHQbGtakvxvAMHc+qNQOCmg+SsKLUwQApKhrT10 VAPgpnrjB39yRm6s6L/qrDHhWvBaaYNQMtvsqj1+v0fvmEwwatS9zbGa+FZsJFlQU64Z ox1fr3O2VjkF9ahd5WAvcOHKTDf2htHQ81beBYiVdswumuh1ZkXm8qf1u+P+k09GvXZi Q8g7q/Uo7whfBR+8lDntxLe4lrVRG68SkkhWFj1ADSRGkcQ1KveV1z+PDWziyicMxlIV ifwg== 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 d185-v6si20054909pfg.102.2018.09.24.10.46.24; Mon, 24 Sep 2018 10:46:39 -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 S1728999AbeIXXt2 (ORCPT + 99 others); Mon, 24 Sep 2018 19:49:28 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39682 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbeIXXt2 (ORCPT ); Mon, 24 Sep 2018 19:49:28 -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 B552A1596; Mon, 24 Sep 2018 10:46:11 -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 3672E3F5BD; Mon, 24 Sep 2018 10:46:11 -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, Christoffer Dall , Suzuki Poulose , stable@vger.kernel.org Subject: [PATCH v7 1/9] KVM: arm/arm64: Ensure only THP is candidate for adjustment Date: Mon, 24 Sep 2018 18:45:44 +0100 Message-Id: <20180924174552.8387-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180924174552.8387-1-punit.agrawal@arm.com> References: <20180924174552.8387-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 Cc: Christoffer Dall Cc: Marc Zyngier Cc: Suzuki Poulose 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