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: 7843881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6B62DBEEE1 for ; Mon, 14 Dec 2015 11:42:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9239C203DF for ; Mon, 14 Dec 2015 11:42:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7D53203E3 for ; Mon, 14 Dec 2015 11:42:18 +0000 (UTC) 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-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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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)