Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8266637ybn; Tue, 1 Oct 2019 05:51:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1Y67dpyLc64wtvZbJCwvIVN7YlJRGaHRCAwsmB5No3hr/tpcQ7CCCKM+bfVidRdiM1BBD X-Received: by 2002:a05:6402:383:: with SMTP id o3mr25435270edv.205.1569934303476; Tue, 01 Oct 2019 05:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569934303; cv=none; d=google.com; s=arc-20160816; b=VV/2wlHdedGaqwWk4mbWVKgiE88NG4hVXAe52nzdfiVZzo/lmwHuBCdxDtIF3ghVqv eYXwLPTftELKfOUyCwyDgBISHJ1EfejH0S/pUMdTOz4sRklnUdimTUG1WTc41+fFUdRR fu/ltXAEY6DXaapuYkcLOi2cFnHDeWVvsA75vEcIuIS6z/1/OzTuRB/5tWbLjF6KqTUI Asis/q6KKZSBvwOGUim79zNIZADja9tZO1e1xQb5d6G43fWSH6bhjANCHBqJuiGgqgf8 e2nHCoCwE9fl1eEq/Of0tmc4EPjJ7f6s2wJQl+k5Umu+lJK/UGsEBGnFIGVNWLxtZFHv GZKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2bHGvZfKjCJjofAADZQ3bxhySs+fKzSpkTACYHjG2lk=; b=AmmJbLjJFn/LpDKAbAAz8+hB+1lqu4jah9+N6CHDSaNET8X2H4jRsZn952LUQVhpLS sHxdRn5+kLHlz10EG8es9cUzzRhP0axhkzj5iXemykcc0z/apNcyYhKKdClbFKcQDiS5 K2tgN3PnKR1Og36fRSw0j9JiXubJXC8V8n4e1RargJoCVBfj/NUXdiyFXmfMOGnGIIeX HmQbCPekyPA4c5p9KdMN4bnrsmm8R9Soi6RZAsRW/KUPqhbN3GY/BcsitJuFy6XXGNY1 Z+Fj9235rAx12TJwnXD/eNknjeODOikBngwCmHjQDDfW05HXbDFlAYkUDim6m8eQ17/W 73bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vFqF2QRX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f47si9325334ede.263.2019.10.01.05.51.19; Tue, 01 Oct 2019 05:51:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vFqF2QRX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388063AbfJAMui (ORCPT + 99 others); Tue, 1 Oct 2019 08:50:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:42424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfJAMui (ORCPT ); Tue, 1 Oct 2019 08:50:38 -0400 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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