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 95654C4332F for ; Fri, 21 Jan 2022 14:04:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC9A16B007E; Fri, 21 Jan 2022 09:04:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A789C6B0080; Fri, 21 Jan 2022 09:04:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98F026B0081; Fri, 21 Jan 2022 09:04:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay032.a.hostedemail.com [64.99.140.32]) by kanga.kvack.org (Postfix) with ESMTP id 863356B007E for ; Fri, 21 Jan 2022 09:04:26 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 420BDC55 for ; Fri, 21 Jan 2022 14:04:26 +0000 (UTC) X-FDA: 79054464132.02.9377928 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf01.hostedemail.com (Postfix) with ESMTP id E377340016 for ; Fri, 21 Jan 2022 14:04:24 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id n10so27468505edv.2 for ; Fri, 21 Jan 2022 06:04:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oZlpT6bzEx+qiA4VrfBHEX+BsLOoUB2LaTYuoQqCfn0=; b=okG8OHX4PTHLv68X8Pq6F87DoY05RbdGKJSzY+LhnQnJMJ1hVuAxcTomJb/z+kSSXz axX0eNt0JufAlwkTzml6kplHNCGOhVn0+oIAj1tTxJUqSh2VLGkqMt9+23/U6qDbtFW+ M5+yYhUHJaORcmHcn4HxiYPHe94cyrtzq7GRSVgrY/ITXV91Ck1Xy900eSraHZ7I5GDo UQrmcw4klm6C+pg7pAV4CnfQ739O5YJKcljiXJHL1P9UyW4CgyEq3KxCIU9DdyQITmdM I6KNMur1he8AsOx+fPupvCxpn9wAgv78qmTXqVbGZTueAU5fnzDa8yy00sL5rKe/gMgc WDbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oZlpT6bzEx+qiA4VrfBHEX+BsLOoUB2LaTYuoQqCfn0=; b=V8bXehO7KvTCV2pbUneMVX5p9FIBsz7mm+d4zILzJmcNhaBqJ1vBz000BE24FQyGan W7vHIwU5MXs73Gx7dr3BzA6vL1SfzbdPIiKbRp+3xim5n3DKU3EcWY8TIbLFF9jkHtlT nbZCcwn53rldpcN0KQ+phdRvIhTgl+jHWFjcyWW6535O3PdJyDpGRz0GJtonkCekORmA 81FvqVPJKXccHta8QkcCZrfFES9YiG4XCq0pN1maOgtDcX3rGM33fsU1aGyAaQsB9hMJ pPoXBntQkXHMHJtHZdf+MI5+YJ+kZb7cqDve93519p32IZ1r1exDS7hLV12/WeJSD+ft h1dg== X-Gm-Message-State: AOAM531+hpCPkgYRNRk2LI+S/4GRsDVI2w9NfTNtvXpEM/9OZpP/aLaz SyU58U/nccHNS19qT2Cvw95ElGQ0XLaWuamW+gEKgg== X-Google-Smtp-Source: ABdhPJxH4OQbNOq8+RE1qEL1KLot110tAQUNbO3ApDksEs7j9hUkSbQKR+kqEnp6RCxbzo32rJV5t0JS0dyfi1TcD0o= X-Received: by 2002:a05:6402:405:: with SMTP id q5mr4440010edv.372.1642773863492; Fri, 21 Jan 2022 06:04:23 -0800 (PST) MIME-Version: 1.0 References: <20220120191250.2671557-1-pasha.tatashin@soleen.com> <20220120191250.2671557-2-pasha.tatashin@soleen.com> <406f41ab-5ed9-7c2e-6bc8-afcae32164c5@arm.com> In-Reply-To: <406f41ab-5ed9-7c2e-6bc8-afcae32164c5@arm.com> From: Pasha Tatashin Date: Fri, 21 Jan 2022 09:03:45 -0500 Message-ID: Subject: Re: [PATCH v2 1/3] mm/debug_vm_pgtable: remove pte entry from the page table To: Anshuman Khandual Cc: LKML , linux-mm , Andrew Morton , David Rientjes , Paul Turner , Wei Xu , Greg Thelen , Ingo Molnar , Will Deacon , Mike Rapoport , Dave Hansen , "H. Peter Anvin" , "Aneesh Kumar K.V" , Jiri Slaby , Muchun Song , Fusion Future , Hugh Dickins , Zi Yan Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: E377340016 X-Stat-Signature: gz6h1tchcdm5niocrrnme7jp16brdm14 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=okG8OHX4; dmarc=none; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-Rspamd-Server: rspam02 X-HE-Tag: 1642773864-106388 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: Hi Anshuman, Thanks for looking into this. See my replies below. > > 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 ? This is not x86 specific problem, but page_table_check does not have support for other arches yet. The arm64 support is on my todo list. The patch for arm64 would look something like this: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d283d422c6c4f0264fe8ecf5ae80036bf73f4594 > > > > > 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) <---- It turns out I pasted the backtrace from the modified kernel. Here the snippet of backtrace from the mainline: [ 2.276826] ------------[ cut here ]------------ [ 2.280426] kernel BUG at mm/page_table_check.c:162! [ 2.284118] invalid opcode: 0000 [#1] PREEMPT SMP PTI ... Which corresponds to: 152 void __page_table_check_zero(struct page *page, unsigned int order) 153 { 154 struct page_ext *page_ext = lookup_page_ext(page); 155 int i; 156 157 BUG_ON(!page_ext); 158 for (i = 0; i < (1 << order); i++) { 159 struct page_table_check *ptc = get_page_table_check(page_ext); 160 161 BUG_ON(atomic_read(&ptc->anon_map_count)); 162 BUG_ON(atomic_read(&ptc->file_map_count)); I will update the bug log with the mainline backtrace. > > > [ 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. What is detected is that a page that potentially has a PTE entry in a user page table was put on a free list. It is not an issue for this test, but would be an issue if it happened elsewhere. > > > > > 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. This is because page_table_check does not have support for anything beside x86 at the moment. > > > > > static void __init pte_savedwrite_tests(struct pgtable_debug_args *args) > > Pasha