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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC213C433F5 for ; Fri, 21 Jan 2022 03:37:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C69C6B007D; Thu, 20 Jan 2022 22:37:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 375DF6B007E; Thu, 20 Jan 2022 22:37:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 264D86B0080; Thu, 20 Jan 2022 22:37:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 199226B007D for ; Thu, 20 Jan 2022 22:37:32 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BBB07181FE069 for ; Fri, 21 Jan 2022 03:37:31 +0000 (UTC) X-FDA: 79052884302.06.62FEF91 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 2E6091A0015 for ; Fri, 21 Jan 2022 03:37:31 +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 0FEC1101E; Thu, 20 Jan 2022 19:37:30 -0800 (PST) Received: from [10.163.74.170] (unknown [10.163.74.170]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2BE793F766; Thu, 20 Jan 2022 19:37:21 -0800 (PST) Subject: Re: [PATCH v2 1/3] mm/debug_vm_pgtable: remove pte entry from the page table To: Pasha Tatashin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, rientjes@google.com, pjt@google.com, weixugc@google.com, gthelen@google.com, mingo@redhat.com, will@kernel.org, rppt@kernel.org, dave.hansen@linux.intel.com, hpa@zytor.com, aneesh.kumar@linux.ibm.com, jirislaby@kernel.org, songmuchun@bytedance.com, qydwhotmail@gmail.com, hughd@google.com, ziy@nvidia.com References: <20220120191250.2671557-1-pasha.tatashin@soleen.com> <20220120191250.2671557-2-pasha.tatashin@soleen.com> From: Anshuman Khandual Message-ID: <406f41ab-5ed9-7c2e-6bc8-afcae32164c5@arm.com> Date: Fri, 21 Jan 2022 09:07:25 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20220120191250.2671557-2-pasha.tatashin@soleen.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2E6091A0015 X-Stat-Signature: za4oxfdwix16d9z3nso9ukjbacbo6eou Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-HE-Tag: 1642736251-943230 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 1/21/22 12:42 AM, Pasha Tatashin wrote: > The pte entry that is used in pte_advanced_tests() is never removed from > the page table at the end of the test. > > The issue is detected by page_table_check, to repro compile kernel with > the following configs: > > CONFIG_DEBUG_VM_PGTABLE=y > CONFIG_PAGE_TABLE_CHECK=y > CONFIG_PAGE_TABLE_CHECK_ENFORCED=y Assuming this is on latest mainline. I could enable PAGE_TABLE_CHECK on arm64 after some hacks. It did not build on the platform otherwise. But enabling DEBUG_VM_PGTABLE afterwards did not create below mentioned problems. Is the problem x86 specific ? > > During the boot the following BUG is printed: > > [ 7.483050][ T1] debug_vm_pgtable: [debug_vm_pgtable ]: > Validating architecture page tabs > [ 7.490930][ T1] ------------[ cut here ]------------ > [ 7.494926][ T1] kernel BUG at mm/page_table_check.c:194! Which BUG() is this ? mm/page_table_check.c:194 on latest mainline .. void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr, pud_t pud) <---- > [ 7.499172][ T1] invalid opcode: 0000 [#1] PREEMPT SMP KASAN > [ 7.503610][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.16.0+ > [ 7.508600][ T1] Hardware name: QEMU Standard PC (i440FX + PIIX, > ... > > The entry should be properly removed from the page table before the page > is released to the free list. > > Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers") I am not sure whether this really fixes an existing problem. > > Signed-off-by: Pasha Tatashin > Reviewed-by: Zi Yan > Tested-by: Zi Yan > --- > mm/debug_vm_pgtable.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c > index a7ac97c76762..db2abd9e415b 100644 > --- a/mm/debug_vm_pgtable.c > +++ b/mm/debug_vm_pgtable.c > @@ -171,6 +171,8 @@ static void __init pte_advanced_tests(struct pgtable_debug_args *args) > ptep_test_and_clear_young(args->vma, args->vaddr, args->ptep); > pte = ptep_get(args->ptep); > WARN_ON(pte_young(pte)); > + > + ptep_get_and_clear_full(args->mm, args->vaddr, args->ptep, 1); > } Although I dont see any problem on arm64 after this change. > > static void __init pte_savedwrite_tests(struct pgtable_debug_args *args) >