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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8CE5ECAAD3 for ; Fri, 9 Sep 2022 10:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Iaf4Nh4U59H8aRuEqpQ8kkArkosAa+dWfUsDXqPdGD4=; b=uZBl0hy9a44t2a PUgfiV57kzpgWG4mI8jDJ4EZaK73Y97nsF/Auun1Il21wEFcbdC2fk9GFb+r9k5fTLCrPAh3NR83F TFPs82zwVORm1buCq45knAesxtPHQ9ovCSsX8Dhy/4jIoUdUQgCwF2zK9wWD6XPK8y+wmz7wFPmuN G6Rk4OHVe5Uh8DmLHzdfWkH3nlaEjhAnT+eJPPg41T2FsH9Dk2NQYNmeVsOfegatXHl6PnvAkDISh 9Zc85vGCWtb+4JO6Dq9PBh62WPbFuIAZA25enQ9hHHLMM+ZPPSfzdtWq+p3upJG2/mV1a6ZKruHUN ZOQGDLKmTD1dgp0mDRPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWayE-00FGbN-EY; Fri, 09 Sep 2022 10:10:46 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWayB-00FGaG-1t for linux-arm-kernel@lists.infradead.org; Fri, 09 Sep 2022 10:10:44 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D25EAB82485; Fri, 9 Sep 2022 10:10:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFBBAC433C1; Fri, 9 Sep 2022 10:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662718239; bh=ThKc/LNks2uiEwibtZIMonrODWHgA8V6ISnUWceg9VI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JmgQnTSyduTWZtYc6DODkU0So3JcJ218EbkSzoY/dgU3Zm56uGjgw02ef25ftWUbW ft/mVHJRUfvEr8L3IpZK28TBYphWGB2loiVTm9EOSQ1REIu+kTHPiyGH1ttTMNKv1O OH8lklSHvtWxgwDalvI/0oszE8XSNNjneTsZOcXo55Rq97+gmAP5+GHre3WS5yXxiT x4h0JsVjQjfZaKbh3T0wVdny69SN2QiTP1wN+qpBJboyanMv2V/pAc5cQ9woB70o6b VYhQqS03VVlenck24B+QAUKBx1lum28864MwmcZYhxN8hrnSihqQLTF0YnXXBLRv5o hgh08i87IptXg== Date: Fri, 9 Sep 2022 11:10:34 +0100 From: Will Deacon To: "Kirill A. Shutemov" Cc: Sergei Antonov , 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" Subject: Re: [PATCH] mm: bring back update_mmu_cache() to finish_fault() Message-ID: <20220909101032.GA32507@willie-the-truck> References: <20220908204809.2012451-1-saproj@gmail.com> <20220908222410.yg2sqqdezzwfi5mj@box.shutemov.name> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220908222410.yg2sqqdezzwfi5mj@box.shutemov.name> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220909_031043_408746_2B872821 X-CRM114-Status: GOOD ( 22.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > > Cc: Kirill A. Shutemov > > +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 I'm assuming Andrew will pick this up. Otherwise, please let me know if I should route it via the arm64 tree. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel