From patchwork Mon Dec 14 11:40:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 58342 Delivered-To: patch@linaro.org Received: by 10.112.73.68 with SMTP id j4csp1413349lbv; Mon, 14 Dec 2015 03:42:02 -0800 (PST) X-Received: by 10.98.72.152 with SMTP id q24mr35333246pfi.156.1450093321039; Mon, 14 Dec 2015 03:42:01 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id l18si10784795pfj.52.2015.12.14.03.42.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Dec 2015 03:42:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8RV3-00086x-Fh; Mon, 14 Dec 2015 11:41:05 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8RUy-0007nr-Da for linux-arm-kernel@lists.infradead.org; Mon, 14 Dec 2015 11:41:02 +0000 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 C844148D; Mon, 14 Dec 2015 03:40:16 -0800 (PST) Received: from leverpostej.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 A0D5C3F21A; Mon, 14 Dec 2015 03:40:39 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] arm64: mm: ensure visbility of page table zeroing Date: Mon, 14 Dec 2015 11:40:23 +0000 Message-Id: <1450093223-5117-2-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450093223-5117-1-git-send-email-mark.rutland@arm.com> References: <20151211191031.GN18828@arm.com> <1450093223-5117-1-git-send-email-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151214_034100_675243_DA919BC8 X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org We allocate pages with PGALLOC_GFP, which implictly ensures that the newly allocated tables are zeroed. However, we plumb the newly allocated tables into (potentially live) tables without an intervening barrier, and thus a concurrent page table walk may see stale data rather than the zeroes written by the allocator. Insert a dsb(ishst) in our run time page table allocators to ensure that such zeroing is visible. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/include/asm/pgalloc.h | 14 +++++++++++--- arch/arm64/mm/pgd.c | 10 ++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h index c150539..b91f6dd 100644 --- a/arch/arm64/include/asm/pgalloc.h +++ b/arch/arm64/include/asm/pgalloc.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -33,7 +34,9 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) { - return (pmd_t *)__get_free_page(PGALLOC_GFP); + pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP); + dsb(ishst); + return pmd; } static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) @@ -53,7 +56,9 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) { - return (pud_t *)__get_free_page(PGALLOC_GFP); + pud_t *pud = (pud_t *)__get_free_page(PGALLOC_GFP); + dsb(ishst); + return pud; } static inline void pud_free(struct mm_struct *mm, pud_t *pud) @@ -75,7 +80,9 @@ extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); static inline pte_t * pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) { - return (pte_t *)__get_free_page(PGALLOC_GFP); + pte_t *pte = (pte_t *)__get_free_page(PGALLOC_GFP); + dsb(ishst); + return pte; } static inline pgtable_t @@ -90,6 +97,7 @@ pte_alloc_one(struct mm_struct *mm, unsigned long addr) __free_page(pte); return NULL; } + dsb(ishst); return pte; } diff --git a/arch/arm64/mm/pgd.c b/arch/arm64/mm/pgd.c index cb3ba1b..5420cf3 100644 --- a/arch/arm64/mm/pgd.c +++ b/arch/arm64/mm/pgd.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -32,10 +33,15 @@ static struct kmem_cache *pgd_cache; pgd_t *pgd_alloc(struct mm_struct *mm) { + pgd_t *pgd; + if (PGD_SIZE == PAGE_SIZE) - return (pgd_t *)__get_free_page(PGALLOC_GFP); + pgd = (pgd_t *)__get_free_page(PGALLOC_GFP); else - return kmem_cache_alloc(pgd_cache, PGALLOC_GFP); + pgd = kmem_cache_alloc(pgd_cache, PGALLOC_GFP); + + dsb(ishst); + return pgd; } void pgd_free(struct mm_struct *mm, pgd_t *pgd)