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=-10.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, 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 D6AF3C4740C for ; Sat, 21 Sep 2019 15:31:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACDD82073F for ; Sat, 21 Sep 2019 15:31:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JgVAv2oW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438277AbfIUPbz (ORCPT ); Sat, 21 Sep 2019 11:31:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52862 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389131AbfIUPbz (ORCPT ); Sat, 21 Sep 2019 11:31:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8PmFm3Ly74x23hP2R9ri85RFIU5A1cox0jMPByyW+Tc=; b=JgVAv2oWNL8JcdncfAzhmr88E BRxgEuBJGO3RXO0xxKlmXuEInWJgSQwauiaQPyx5j+oUqASWzL0aUPWyOP6kQOwEONpCGvwjTU3Pp FjsRzovkmaYCOcnLXeNLYkx6yhcIXulqGn2IqCXh7v8bu31kcDiCMLI1SD3Oqno4AucxKsynJWbSO /6T827HLMcWDa8sazxmyeq6CdgsNLe2yPvnEZTNRk9r3swRYcapwt7NryzliPoRCDuyqII/KR5l0g Tv+hyzGxFCjD+WCg2zD5LGbonL+v1f4FSkXPcRsw4GxWN+Iy6FTdr0iEPTFwtf/hxlJrVoFE5Vjtz uzLV+ynHw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBhMV-0008Rg-KL; Sat, 21 Sep 2019 15:31:51 +0000 Date: Sat, 21 Sep 2019 08:31:51 -0700 From: Matthew Wilcox To: Jia He Cc: Catalin Marinas , Will Deacon , Mark Rutland , James Morse , Marc Zyngier , "Kirill A. Shutemov" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Suzuki Poulose , Punit Agrawal , Anshuman Khandual , Alex Van Brunt , Robin Murphy , Thomas Gleixner , Andrew Morton , =?iso-8859-1?B?Suly9G1l?= Glisse , Ralph Campbell , hejianet@gmail.com, Kaly Xin , nd@arm.com Subject: Re: [PATCH v8 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared Message-ID: <20190921153151.GE15392@bombadil.infradead.org> References: <20190921135054.142360-1-justin.he@arm.com> <20190921135054.142360-4-justin.he@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190921135054.142360-4-justin.he@arm.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 21, 2019 at 09:50:54PM +0800, Jia He wrote: > When we tested pmdk unit test [1] vmmalloc_fork TEST1 in arm64 guest, there > will be a double page fault in __copy_from_user_inatomic of cow_user_page. > > Below call trace is from arm64 do_page_fault for debugging purpose > [ 110.016195] Call trace: > [ 110.016826] do_page_fault+0x5a4/0x690 > [ 110.017812] do_mem_abort+0x50/0xb0 > [ 110.018726] el1_da+0x20/0xc4 > [ 110.019492] __arch_copy_from_user+0x180/0x280 > [ 110.020646] do_wp_page+0xb0/0x860 > [ 110.021517] __handle_mm_fault+0x994/0x1338 > [ 110.022606] handle_mm_fault+0xe8/0x180 > [ 110.023584] do_page_fault+0x240/0x690 > [ 110.024535] do_mem_abort+0x50/0xb0 > [ 110.025423] el0_da+0x20/0x24 > > The pte info before __copy_from_user_inatomic is (PTE_AF is cleared): > [ffff9b007000] pgd=000000023d4f8003, pud=000000023da9b003, pmd=000000023d4b3003, pte=360000298607bd3 > > As told by Catalin: "On arm64 without hardware Access Flag, copying from > user will fail because the pte is old and cannot be marked young. So we > always end up with zeroed page after fork() + CoW for pfn mappings. we > don't always have a hardware-managed access flag on arm64." > > This patch fix it by calling pte_mkyoung. Also, the parameter is > changed because vmf should be passed to cow_user_page() > > Add a WARN_ON_ONCE when __copy_from_user_inatomic() returns error > in case there can be some obscure use-case.(by Kirill) > > [1] https://github.com/pmem/pmdk/tree/master/src/test/vmmalloc_fork > > Reported-by: Yibo Cai > Signed-off-by: Jia He Reviewed-by: Matthew Wilcox (Oracle)