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=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 93EAEC352AA for ; Tue, 1 Oct 2019 12:50:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 59C0021A4A for ; Tue, 1 Oct 2019 12:50:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="vFqF2QRX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59C0021A4A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 273638E0005; Tue, 1 Oct 2019 08:50:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2227B8E0001; Tue, 1 Oct 2019 08:50:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 139298E0005; Tue, 1 Oct 2019 08:50:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id E6B878E0001 for ; Tue, 1 Oct 2019 08:50:39 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 604AC180AD7C3 for ; Tue, 1 Oct 2019 12:50:39 +0000 (UTC) X-FDA: 75995199798.29.plate69_22c38ce4e6c21 X-HE-Tag: plate69_22c38ce4e6c21 X-Filterd-Recvd-Size: 3497 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Oct 2019 12:50:38 +0000 (UTC) Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5197E21872; Tue, 1 Oct 2019 12:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569934237; bh=/gPSJI6zO7uojDFJ0+HevJuNlGn4NzxfqGO+ldy/Pn4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vFqF2QRXYBnbbTCXivGapO2pDUlAUngoCGoIkS3oh9r2HpKbLT3eU+AP+VjIjEGOP e0YoAtuKKCTtzfQqfIIEfGceqRKTf6Shy79nxMHUx3NY9Geoci6VSH2Zt3rzLCmPVM 6yvRfrdXfiDaiQgqPTt64jLelAubqy/Uw24e8b/I= Date: Tue, 1 Oct 2019 13:50:32 +0100 From: Will Deacon To: Jia He Cc: Catalin Marinas , Mark Rutland , James Morse , Marc Zyngier , Matthew Wilcox , "Kirill A. Shutemov" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Punit Agrawal , Thomas Gleixner , Andrew Morton , hejianet@gmail.com, Kaly Xin Subject: Re: [PATCH v10 2/3] arm64: mm: implement arch_faults_on_old_pte() on arm64 Message-ID: <20191001125031.7ddm5dlwss6m3dth@willie-the-truck> References: <20190930015740.84362-1-justin.he@arm.com> <20190930015740.84362-3-justin.he@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190930015740.84362-3-justin.he@arm.com> User-Agent: NeoMutt/20170113 (1.7.2) 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 Mon, Sep 30, 2019 at 09:57:39AM +0800, Jia He wrote: > On arm64 without hardware Access Flag, copying fromuser 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. > > Hence implement arch_faults_on_old_pte on arm64 to indicate that it might > cause page fault when accessing old pte. > > Signed-off-by: Jia He > Reviewed-by: Catalin Marinas > --- > arch/arm64/include/asm/pgtable.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 7576df00eb50..e96fb82f62de 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -885,6 +885,20 @@ static inline void update_mmu_cache(struct vm_area_struct *vma, > #define phys_to_ttbr(addr) (addr) > #endif > > +/* > + * 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. > + */ > +static inline bool arch_faults_on_old_pte(void) > +{ > + WARN_ON(preemptible()); > + > + return !cpu_has_hw_af(); > +} Does this work correctly in a KVM guest? (i.e. is the MMFR sanitised in that case, despite not being the case on the host?) Will