From patchwork Mon Mar 23 15:36:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46204 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4745520D10 for ; Mon, 23 Mar 2015 15:40:17 +0000 (UTC) Received: by wggy19 with SMTP id y19sf27711058wgg.2 for ; Mon, 23 Mar 2015 08:40:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:in-reply-to:references:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list; bh=3AZnKrxyjkKJoev1V7nxcwEtVGZwwJmy9Clq074Rejs=; b=mXAU/VcCnyL6xKRSVs+6URCLPIT4UVOSQ0SPI1YcDPWdLZGfSIxMikTWYQiyrBK6Sx PwLnRgXR6aNGHA4URV84pWjPHkgohPZX6DxwEVcVkr0DkoSjsN6KKaiM6yg7xYCW/Jp/ G4wAQH2WgoUX3RxPWfxV6gtWDwD0ymj8tXgGmPjgRj42a7chAXeDzLfnMWieZwnN0IPk KJTdt+I7BnbCi0+QJsSBCeUueQhfrPQjQ+9b59X6yQju0M0AAqcmsQ84cFuKAsQDIjag +y2kJ0VEmi3kfTDiSV5ux0K5gtYC56dH/Ly4xtFUdLK6ewkBePWuKSXEuRiq66Shgqs0 kfzg== X-Gm-Message-State: ALoCoQmH2cWZ9CWzfnY3cKX7w5SX1hF+SHuM+efb7xwi41KT+He8nqt7ehj93zCg6UsT04WEmp9M X-Received: by 10.181.29.66 with SMTP id ju2mr2165176wid.1.1427125216536; Mon, 23 Mar 2015 08:40:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.195 with SMTP id o3ls708046laf.82.gmail; Mon, 23 Mar 2015 08:40:16 -0700 (PDT) X-Received: by 10.112.123.99 with SMTP id lz3mr69870004lbb.48.1427125216378; Mon, 23 Mar 2015 08:40:16 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id k8si875770laa.90.2015.03.23.08.40.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 08:40:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lagg8 with SMTP id g8so137396063lag.1 for ; Mon, 23 Mar 2015 08:40:16 -0700 (PDT) X-Received: by 10.152.116.11 with SMTP id js11mr62695738lab.106.1427125216269; Mon, 23 Mar 2015 08:40:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp903999lbq; Mon, 23 Mar 2015 08:40:15 -0700 (PDT) X-Received: by 10.68.221.226 with SMTP id qh2mr22184726pbc.1.1427125214587; Mon, 23 Mar 2015 08:40:14 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id xv8si1564325pbc.123.2015.03.23.08.40.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 08:40:14 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1Ya4R2-0002rA-5D; Mon, 23 Mar 2015 15:38:36 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ya4Pw-00021N-5L for linux-arm-kernel@lists.infradead.org; Mon, 23 Mar 2015 15:37:29 +0000 Received: by wixw10 with SMTP id w10so36987215wix.0 for ; Mon, 23 Mar 2015 08:37:05 -0700 (PDT) X-Received: by 10.194.85.129 with SMTP id h1mr188691765wjz.147.1427125025277; Mon, 23 Mar 2015 08:37:05 -0700 (PDT) Received: from ards-macbook-pro.local (62.82.106.185.static.user.ono.com. [62.82.106.185]) by mx.google.com with ESMTPSA id s5sm11712061wia.1.2015.03.23.08.37.03 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Mar 2015 08:37:04 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, will.deacon@arm.com, catalin.marinas@arm.com Subject: [PATCH 2/4] arm64: fixmap: move translation tables to dedicated region Date: Mon, 23 Mar 2015 16:36:54 +0100 Message-Id: <1427125016-3873-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1427125016-3873-1-git-send-email-ard.biesheuvel@linaro.org> References: <1427125016-3873-1-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: <20150317164353.GN23340@leverpostej> References: <20150317164353.GN23340@leverpostej> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150323_083728_438044_7F45A1AF X-CRM114-Status: GOOD ( 10.82 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.169 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.169 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This moves the fixmap translation tables to a dedicated region in the linker map. This is needed for a split kernel text from the linear mapping, to ensure that the contents of the tables rely on a single translation regime. Also make the population of the translation levels conditional, so that the kernel text can share some levels of translation if needed. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/linkage.h | 2 ++ arch/arm64/kernel/vmlinux.lds.S | 15 ++++++++++----- arch/arm64/mm/mmu.c | 15 +++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/linkage.h b/arch/arm64/include/asm/linkage.h index 636c1bced7d4..dc9354de6f52 100644 --- a/arch/arm64/include/asm/linkage.h +++ b/arch/arm64/include/asm/linkage.h @@ -4,4 +4,6 @@ #define __ALIGN .align 4 #define __ALIGN_STR ".align 4" +#define __pgdir __attribute__((__section__(".pgdir"))) + #endif diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 434ef407ef0f..d3885043f0b7 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -149,11 +149,16 @@ SECTIONS BSS_SECTION(0, 0, 0) - . = ALIGN(PAGE_SIZE); - idmap_pg_dir = .; - . += IDMAP_DIR_SIZE; - swapper_pg_dir = .; - . += SWAPPER_DIR_SIZE; + .pgdir : { + . = ALIGN(PAGE_SIZE); + __pgdir_start = .; + idmap_pg_dir = .; + . += IDMAP_DIR_SIZE; + *(.pgdir) + swapper_pg_dir = .; + . += SWAPPER_DIR_SIZE; + __pgdir_stop = .; + } _end = .; diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 43496748e3d9..bb3ce41130f3 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -549,12 +549,12 @@ void vmemmap_free(unsigned long start, unsigned long end) } #endif /* CONFIG_SPARSEMEM_VMEMMAP */ -static pte_t bm_pte[PTRS_PER_PTE] __page_aligned_bss; +static pte_t bm_pte[PTRS_PER_PTE] __pgdir; #if CONFIG_ARM64_PGTABLE_LEVELS > 2 -static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss; +static pmd_t bm_pmd[PTRS_PER_PMD] __pgdir; #endif #if CONFIG_ARM64_PGTABLE_LEVELS > 3 -static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss; +static pud_t bm_pud[PTRS_PER_PUD] __pgdir; #endif static inline pud_t * fixmap_pud(unsigned long addr) @@ -592,11 +592,14 @@ void __init early_fixmap_init(void) unsigned long addr = FIXADDR_START; pgd = pgd_offset_k(addr); - pgd_populate(&init_mm, pgd, bm_pud); + if (pgd_none(*pgd)) + pgd_populate(&init_mm, pgd, bm_pud); pud = pud_offset(pgd, addr); - pud_populate(&init_mm, pud, bm_pmd); + if (pud_none(*pud)) + pud_populate(&init_mm, pud, bm_pmd); pmd = pmd_offset(pud, addr); - pmd_populate_kernel(&init_mm, pmd, bm_pte); + if (pmd_none(*pmd)) + pmd_populate_kernel(&init_mm, pmd, bm_pte); /* * The boot-ioremap range spans multiple pmds, for which