From patchwork Fri Aug 24 15:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 145081 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1411031ljw; Fri, 24 Aug 2018 08:53:28 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb6AKq0S4NS7HBJFSOQqzZ+i6cagGnrR6ILz5JPdqaYNvh+6hLanQNq0X9/LlZGCtwNO8cl X-Received: by 2002:aa7:800f:: with SMTP id j15-v6mr2621322pfi.174.1535126008094; Fri, 24 Aug 2018 08:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535126008; cv=none; d=google.com; s=arc-20160816; b=Jx3IBXNs7rAAYcjtmG1+nKzvxsna/RAfSxRqPp0MLB9zU9jAgW08R8EnB3198F67Yz edyxiBVqQOUA41ZUTYWSU+6TsD2WMxcRhqLMS698S3LiSdIwbo+XzWLW3PkRoEKfL1ix /DhOmRW5PXUgRApif//YDGnF5ceqMXr0QfBYsDp+27IME6sPw80gJSnRqeo4ZWScduEe VSqQyQlLmC7YEM+HAS8RHDrsJgW2pyR3+3iqsU9U0KQb1OS3IwUNdJ/txCl/dztsQ6ok UqsJSfyF3u9u64PliYLzXs0m/f3BknyXALpsnnaC/2bvPI025sLLW1FAcWVAWWFDywRX sYPw== 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:arc-authentication-results; bh=mgLzZPBJn+RP+iAVaiUfifPZNPKh2V3/3J8/kCSjBtc=; b=Ud/sMUSdVlOg3rsITXEnO5Un8MQrwVyT1ApQPoJCPX9QGdheQScEFsCwTcSA1ytZra RSGySBMSm7GV4mXbYmLXCgFJaAETl1bKOdQAvOVlUKYu5z5RdIFFhnPc4GeJcVn0z4wV SG+QzGE95yK0na0suVnJg7/I6UEWCI+4BYAXWK9yRj8cgfdFbUXvCj+H21I09LDZ0qH2 KRjEKqyND4dDm3jsqleqbwexPRyae9VoiCfgAxE3LXtyFAr7ikQ3B5+hw5MRuOS+u03A PuyWS0ujGyY6gaSfbWil0bWT57FrKMokNHvkkrOCSPH+KHZJP3odoFRTE856GSyeU95l Riig== 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 g10-v6si6762177plt.468.2018.08.24.08.53.27; Fri, 24 Aug 2018 08:53:28 -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 S1728150AbeHXT2i (ORCPT + 32 others); Fri, 24 Aug 2018 15:28:38 -0400 Received: from foss.arm.com ([217.140.101.70]:32826 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbeHXT1v (ORCPT ); Fri, 24 Aug 2018 15:27:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0A8B41682; Fri, 24 Aug 2018 08:52:38 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D01ED3F7F3; Fri, 24 Aug 2018 08:52:37 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id C7F1D1AE3307; Fri, 24 Aug 2018 16:52:47 +0100 (BST) From: Will Deacon To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, benh@au1.ibm.com, torvalds@linux-foundation.org, npiggin@gmail.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, Will Deacon Subject: [RFC PATCH 03/11] arm64: pgtable: Implement p[mu]d_valid() and check in set_p[mu]d() Date: Fri, 24 Aug 2018 16:52:38 +0100 Message-Id: <1535125966-7666-4-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1535125966-7666-1-git-send-email-will.deacon@arm.com> References: <1535125966-7666-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that our walk-cache invalidation routines imply a DSB before the invalidation, we no longer need one when we are clearing an entry during unmap. Signed-off-by: Will Deacon --- arch/arm64/include/asm/pgtable.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 1bdeca8918a6..2ab2031b778c 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -360,6 +360,7 @@ static inline int pmd_protnone(pmd_t pmd) #define pmd_present(pmd) pte_present(pmd_pte(pmd)) #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd)) #define pmd_young(pmd) pte_young(pmd_pte(pmd)) +#define pmd_valid(pmd) pte_valid(pmd_pte(pmd)) #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd))) #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd))) #define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd))) @@ -431,7 +432,9 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, static inline void set_pmd(pmd_t *pmdp, pmd_t pmd) { WRITE_ONCE(*pmdp, pmd); - dsb(ishst); + + if (pmd_valid(pmd)) + dsb(ishst); } static inline void pmd_clear(pmd_t *pmdp) @@ -477,11 +480,14 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd) #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT)) #define pud_present(pud) pte_present(pud_pte(pud)) +#define pud_valid(pud) pte_valid(pud_pte(pud)) static inline void set_pud(pud_t *pudp, pud_t pud) { WRITE_ONCE(*pudp, pud); - dsb(ishst); + + if (pud_valid(pud)) + dsb(ishst); } static inline void pud_clear(pud_t *pudp)