From patchwork Fri Oct 11 14:09:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 11185613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFC891668 for ; Fri, 11 Oct 2019 14:10:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A697420679 for ; Fri, 11 Oct 2019 14:10:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A697420679 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4702E8E0005; Fri, 11 Oct 2019 10:10:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3F6BE6B000A; Fri, 11 Oct 2019 10:10:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 296248E0005; Fri, 11 Oct 2019 10:10:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id F041F6B0008 for ; Fri, 11 Oct 2019 10:10:02 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 90D7640EE for ; Fri, 11 Oct 2019 14:10:02 +0000 (UTC) X-FDA: 76031687844.24.home18_520f00fc756 X-Spam-Summary: 2,0,0,09f8eadb8978d8c5,d41d8cd98f00b204,justin.he@arm.com,:catalin.marinas@arm.com:will@kernel.org:mark.rutland@arm.com:james.morse@arm.com:maz@kernel.org:willy@infradead.org:kirill.shutemov@linux.intel.com:linux-arm-kernel@lists.infradead.org:linux-kernel@vger.kernel.org::suzuki.poulose@arm.com:bp@alien8.de:hpa@zytor.com:x86@kernel.org:tglx@linutronix.de:akpm@linux-foundation.org:hejianet@gmail.com:kaly.xin@arm.com:nd@arm.com:justin.he@arm.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:2901:3138:3139:3140:3141:3142:3352:3865:3867:3868:3871:3872:3874:5007:6119:6261:6737:7903:8634:10004:11026:11657:11658:11914:12043:12048:12114:12297:12438:12555:12895:13069:13161:13229:13311:13357:14096:14181:14384:14394:14721:21080:21451:21627:21795:30051:30054,0,RBL:217.140.110.172:@arm.com:.lbl8.mailshell.net-62.2.0.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache: 0,MSF:no X-HE-Tag: home18_520f00fc756 X-Filterd-Recvd-Size: 3066 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Oct 2019 14:10:02 +0000 (UTC) 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 20125142F; Fri, 11 Oct 2019 07:10: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 6A1CB3F68E; Fri, 11 Oct 2019 07:09:56 -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, Suzuki Poulose , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: Thomas Gleixner , Andrew Morton , hejianet@gmail.com, Kaly Xin , nd@arm.com, Jia He Subject: [PATCH v12 2/4] arm64: mm: implement arch_faults_on_old_pte() on arm64 Date: Fri, 11 Oct 2019 22:09:37 +0800 Message-Id: <20191011140939.6115-3-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191011140939.6115-1-justin.he@arm.com> References: <20191011140939.6115-1-justin.he@arm.com> 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 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. 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 */