From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DE4FC433E0 for ; Tue, 9 Jun 2020 02:47:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 165BE2078B for ; Tue, 9 Jun 2020 02:47:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 165BE2078B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 968FB6B0002; Mon, 8 Jun 2020 22:47:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 919546B0005; Mon, 8 Jun 2020 22:47:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 808656B0006; Mon, 8 Jun 2020 22:47:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 665536B0002 for ; Mon, 8 Jun 2020 22:47:09 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 22490181ABEA5 for ; Tue, 9 Jun 2020 02:47:09 +0000 (UTC) X-FDA: 76908136578.26.lunch62_0d06fa526dbf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id D88061804B669 for ; Tue, 9 Jun 2020 02:47:08 +0000 (UTC) X-HE-Tag: lunch62_0d06fa526dbf X-Filterd-Recvd-Size: 3530 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Jun 2020 02:47:08 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6F7DE1FB; Mon, 8 Jun 2020 19:47:07 -0700 (PDT) Received: from [10.163.79.104] (unknown [10.163.79.104]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CDD0C3F66F; Mon, 8 Jun 2020 19:47:05 -0700 (PDT) Subject: Re: [PATCH v2] mm/debug_vm_pgtable: Fix kernel crash by checking for THP support To: "Aneesh Kumar K.V" , linux-mm@kvack.org, akpm@linux-foundation.org Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org References: <20200608125252.407659-1-aneesh.kumar@linux.ibm.com> From: Anshuman Khandual Message-ID: <826398c3-9abe-e173-407e-e7a84c772517@arm.com> Date: Tue, 9 Jun 2020 08:17:04 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200608125252.407659-1-aneesh.kumar@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: D88061804B669 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 06/08/2020 06:22 PM, Aneesh Kumar K.V wrote: > Architectures can have CONFIG_TRANSPARENT_HUGEPAGE enabled but > no THP support enabled based on platforms. For ex: with 4K > PAGE_SIZE ppc64 supports THP only with radix translation. > > This results in below crash when running with hash translation and > 4K PAGE_SIZE. > > kernel BUG at arch/powerpc/include/asm/book3s/64/hash-4k.h:140! > cpu 0x61: Vector: 700 (Program Check) at [c000000ff948f860] > pc: c0000000018810f8: debug_vm_pgtable+0x480/0x8b0 > lr: c0000000018810ec: debug_vm_pgtable+0x474/0x8b0 > ... > [c000000ff948faf0] c000000001880fec debug_vm_pgtable+0x374/0x8b0 (unreliable) > [c000000ff948fbf0] c000000000011648 do_one_initcall+0x98/0x4f0 > [c000000ff948fcd0] c000000001843928 kernel_init_freeable+0x330/0x3fc > [c000000ff948fdb0] c0000000000122ac kernel_init+0x24/0x148 > [c000000ff948fe20] c00000000000cc44 ret_from_kernel_thread+0x5c/0x78 > > Check for THP support correctly > > Cc: anshuman.khandual@arm.com > Fixes: 399145f9eb6c ("mm/debug: add tests validating architecture page table helpers") > Signed-off-by: Aneesh Kumar K.V > --- > mm/debug_vm_pgtable.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c > index 188c18908964..df3a3a08f4f8 100644 > --- a/mm/debug_vm_pgtable.c > +++ b/mm/debug_vm_pgtable.c > @@ -61,6 +61,9 @@ static void __init pmd_basic_tests(unsigned long pfn, pgprot_t prot) > { > pmd_t pmd = pfn_pmd(pfn, prot); > > + if (!has_transparent_hugepage()) > + return; > + > WARN_ON(!pmd_same(pmd, pmd)); > WARN_ON(!pmd_young(pmd_mkyoung(pmd_mkold(pmd)))); > WARN_ON(!pmd_dirty(pmd_mkdirty(pmd_mkclean(pmd)))); > @@ -80,6 +83,9 @@ static void __init pud_basic_tests(unsigned long pfn, pgprot_t prot) > { > pud_t pud = pfn_pud(pfn, prot); > > + if (!has_transparent_hugepage()) > + return; > + > WARN_ON(!pud_same(pud, pud)); > WARN_ON(!pud_young(pud_mkyoung(pud_mkold(pud)))); > WARN_ON(!pud_write(pud_mkwrite(pud_wrprotect(pud)))); > Builds with THP on arc, s390 and runs with THP on x86 and arm64 platforms. Reviewed-by: Anshuman Khandual