Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6379582ybn; Sun, 29 Sep 2019 19:00:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH+Evn4PcnXKevLFckKuAm8KkdEdIA1CmFNBSuQhUP4A2PT1+5u7vzAwa9Oozhbe1lJdPj X-Received: by 2002:a50:f60d:: with SMTP id c13mr17245614edn.279.1569808811842; Sun, 29 Sep 2019 19:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569808811; cv=none; d=google.com; s=arc-20160816; b=Th+G1gffuCwMKqKOAcd7iV7ETIMqbr5JrxlN38cXWhQqCtRBKDLZnAuoMS5mmPfzvu MeF8k5tlATtDd6Wj+FamKNyUB265UaJqVPFrtOiL0LstEAldzBEFobIOBxoM1QU9ED9G Ypl/SIvh9Ge9sP1ktvUMNAx5L9yTl7ugVYmNka8a3stmMh6j37OsQoMsD3I1RuqzRCYN Jc65kDR/qFhBLKs45qTO9yZ2bDA09YPKLsBApVb/CRFxZUtzTr4fz/df1xGbN8J4qsi1 m3MiIDkGKm5cl9RlPcuW96wZtlvBY93CZ/+tWzg0Wn0fgw9n+xfG8O6T+J400qmcgz6U 9Fsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Bsfr0JW8LBngmb82YTb2nrBTIaH8FAhCWLC23s32L9U=; b=yLEb/C9B4BEm7byPCQyF/Qpg6RDsLV+lkCP9ETdhvCs3E6aVax6tJcFwejvBKh4/CJ 1QiGHnrStRcVUvnPlXRq3OsQuMiWS1fOR4+1c0dkmccvILSUsABKvJJNRUe8zs7Jcxgy tJp5Mc8sERZ0ia8F0n5yjy8TRLVj9LWCFO5d6Kv6BjOnuuXnwZvg2M9jl054TnAWtIMh 4D0Dv2Qn7wlEZHXNyfesJvMyei5pF1mvJXTl+SWBQdD1deWNzXnN3I3Ld+negsGum6zI 5Q2Ext7W4iV7FMkNMcRc3/9inv4Uj+sm+tiyXurwj7nH5g+OgCh99/rb0UVAua/ies8q fygA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i24si6569982edj.207.2019.09.29.18.59.47; Sun, 29 Sep 2019 19:00:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729336AbfI3B6C (ORCPT + 99 others); Sun, 29 Sep 2019 21:58:02 -0400 Received: from foss.arm.com ([217.140.110.172]:45406 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbfI3B6C (ORCPT ); Sun, 29 Sep 2019 21:58:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAC311597; Sun, 29 Sep 2019 18:58:01 -0700 (PDT) Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com [10.169.40.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DEE5B3F706; Sun, 29 Sep 2019 18:57:57 -0700 (PDT) From: Jia He To: Catalin Marinas , Will Deacon , 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 Cc: Punit Agrawal , Thomas Gleixner , Andrew Morton , hejianet@gmail.com, Kaly Xin , Jia He Subject: [PATCH v10 2/3] arm64: mm: implement arch_faults_on_old_pte() on arm64 Date: Mon, 30 Sep 2019 09:57:39 +0800 Message-Id: <20190930015740.84362-3-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190930015740.84362-1-justin.he@arm.com> References: <20190930015740.84362-1-justin.he@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); +} +#define arch_faults_on_old_pte arch_faults_on_old_pte + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */ -- 2.17.1