From: Will Deacon <will@kernel.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Sergei Antonov <saproj@gmail.com>,
linux-mm@kvack.org, akpm@linux-foundation.org,
linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH] mm: bring back update_mmu_cache() to finish_fault()
Date: Fri, 9 Sep 2022 11:10:34 +0100 [thread overview]
Message-ID: <20220909101032.GA32507@willie-the-truck> (raw)
In-Reply-To: <20220908222410.yg2sqqdezzwfi5mj@box.shutemov.name>
On Fri, Sep 09, 2022 at 01:24:10AM +0300, Kirill A. Shutemov wrote:
> On Thu, Sep 08, 2022 at 11:48:09PM +0300, Sergei Antonov wrote:
> > Running this test program on ARMv4 a few times (sometimes just once)
> > reproduces the bug.
> >
> > int main()
> > {
> > unsigned i;
> > char paragon[SIZE];
> > void* ptr;
> >
> > memset(paragon, 0xAA, SIZE);
> > ptr = mmap(NULL, SIZE, PROT_READ | PROT_WRITE,
> > MAP_ANON | MAP_SHARED, -1, 0);
> > if (ptr == MAP_FAILED) return 1;
> > printf("ptr = %p\n", ptr);
> > for (i=0;i<10000;i++){
> > memset(ptr, 0xAA, SIZE);
> > if (memcmp(ptr, paragon, SIZE)) {
> > printf("Unexpected bytes on iteration %u!!!\n", i);
> > break;
> > }
> > }
> > munmap(ptr, SIZE);
> > }
> >
> > In the "ptr" buffer there appear runs of zero bytes which are aligned
> > by 16 and their lengths are multiple of 16.
> >
> > Linux v5.11 does not have the bug, "git bisect" finds the first bad commit:
> > f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths")
> >
> > Before the commit update_mmu_cache() was called during a call to
> > filemap_map_pages() as well as finish_fault(). After the commit
> > finish_fault() lacks it.
> >
> > Bring back update_mmu_cache() to finish_fault() to fix the bug.
> > Also call update_mmu_tlb() only when returning VM_FAULT_NOPAGE to more
> > closely reproduce the code of alloc_set_pte() function that existed before
> > the commit.
> >
> > On many platforms update_mmu_cache() is nop:
> > x86, see arch/x86/include/asm/pgtable
> > ARMv6+, see arch/arm/include/asm/tlbflush.h
> > So, it seems, few users ran into this bug.
> >
> > Fixes: f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths")
> > Signed-off-by: Sergei Antonov <saproj@gmail.com>
> > Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>
> +Will.
>
> Seems I confused update_mmu_tlb() with update_mmu_cache() :/
Urgh, that thing is pretty horrible! But anyway, I agree that this change
looks correct based on the other callers in the file.
> Looks good to me:
>
> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
I'm assuming Andrew will pick this up. Otherwise, please let me know if
I should route it via the arm64 tree.
Will
next prev parent reply other threads:[~2022-09-09 10:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 20:48 [PATCH] mm: bring back update_mmu_cache() to finish_fault() Sergei Antonov
2022-09-08 22:24 ` Kirill A. Shutemov
2022-09-09 10:10 ` Will Deacon [this message]
2022-09-09 5:34 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220909101032.GA32507@willie-the-truck \
--to=will@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=kirill@shutemov.name \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=saproj@gmail.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).