From patchwork Wed Mar 30 15:43:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64718 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2672764lbc; Wed, 30 Mar 2016 08:51:39 -0700 (PDT) X-Received: by 10.67.3.67 with SMTP id bu3mr14207123pad.39.1459353099534; Wed, 30 Mar 2016 08:51:39 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id kv12si7268155pab.194.2016.03.30.08.51.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Mar 2016 08:51:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.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 1alIOC-0004NU-Sl; Wed, 30 Mar 2016 15:50:36 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alIHW-0005qP-GN for linux-arm-kernel@bombadil.infradead.org; Wed, 30 Mar 2016 15:43:42 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by merlin.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1alIHV-0006zp-2S for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2016 15:43:41 +0000 Received: by mail-wm0-x230.google.com with SMTP id 191so94724617wmq.0 for ; Wed, 30 Mar 2016 08:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L+iuVKhY2cMpOG2bh4VBbJ3yS7Gamco3BPlk9hvMGCw=; b=APTopY7lH+7QOl0tItSMbLUz/xDR+7PmfiEue2lLq9QH671vwPUJ2a6IjNZB7fhptR lOAFlDCA/TCQ0Yvg00axEClGg/yJCy3Pn7PSLxsYDDK34IEVU/zR2ue/6wvMNYN2bUlJ Q2X317HuiAzKh3j9iGlSlAnzkfYL8n1sQzGws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L+iuVKhY2cMpOG2bh4VBbJ3yS7Gamco3BPlk9hvMGCw=; b=fw3u/ghMuhRSo3ivn/iPV4tj/kU5Hu5CLZY3gkkH9HRom8nt+9W4jgJtDuyfVupZae 9V0EDlQ1JQeioX8pjzs09iRv1X9fGN21XJ4AjBYUQzmQdAwGnonh1/o49lE+aD3pUeha N0wHN4FSw+Ie/3kydWGb2KLuAKC1KGDUarpTsuWYyMThhNOsVJBlSe8BVapZEbI6UVdd /UHSWlInco02s1MIwXm2/vM8DKFDKYjh2rxxUopO4LOvAHNkRtNuC07SDALnU2mVQH5m pL0V8vtkajLOqr4NOUXCkBzEkS6KrMu/gQM9KrQfqziuCCvV1mJl0cqnLLT2aqzuswnT u8ug== X-Gm-Message-State: AD7BkJJKOO+qs4gM+BQeSBN7Q9OBZfgAz8UD1h0Ygybw2l+0Rr8m+gTPd319l5tVuEmaTZ/u X-Received: by 10.194.134.134 with SMTP id pk6mr10458745wjb.176.1459352599267; Wed, 30 Mar 2016 08:43:19 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id h7sm20330403wmf.9.2016.03.30.08.43.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 08:43:18 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, jeremy.linton@arm.com Subject: [PATCH v2 3/4] arm64: cover the .head.text section in the .text segment mapping Date: Wed, 30 Mar 2016 17:43:08 +0200 Message-Id: <1459352589-28721-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459352589-28721-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459352589-28721-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_114341_337324_4456B13A X-CRM114-Status: GOOD ( 15.97 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:230 listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Keeping .head.text out of the .text mapping buys us very little: its actual payload is only 4 KB, most of which is padding, but the page alignment may add up to 2 MB (in case of CONFIG_DEBUG_ALIGN_RODATA=y) of additional padding to the uncompressed kernel Image. Also, on 4 KB granule kernels, the 4 KB misalignment of .text forces us to map the adjacent 56 KB of code without the PTE_CONT attribute, and since this region contains things like the vector table and the GIC interrupt handling entry point, this region is likely to benefit from the reduced TLB pressure that results from PTE_CONT mappings. So remove the alignment between the .head.text and .text sections, and use the [_text, _etext) rather than the [_stext, _etext) interval for mapping the .text segment. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/vmlinux.lds.S | 1 - arch/arm64/mm/mmu.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) -- 2.5.0 _______________________________________________ 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/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 5a1939a74ff3..61a1075b9c30 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -96,7 +96,6 @@ SECTIONS _text = .; HEAD_TEXT } - ALIGN_DEBUG_RO_MIN(PAGE_SIZE) .text : { /* Real text segment */ _stext = .; /* Text and read-only data */ __exception_text_start = .; diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 9be2065f8ddb..dbad533076d1 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -385,7 +385,7 @@ static void create_mapping_late(phys_addr_t phys, unsigned long virt, static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end) { - unsigned long kernel_start = __pa(_stext); + unsigned long kernel_start = __pa(_text); unsigned long kernel_end = __pa(_etext); /* @@ -417,7 +417,7 @@ static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end early_pgtable_alloc); /* - * Map the linear alias of the [_stext, _etext) interval as + * Map the linear alias of the [_text, _etext) interval as * read-only/non-executable. This makes the contents of the * region accessible to subsystems such as hibernate, but * protects it from inadvertent modification or execution. @@ -449,8 +449,8 @@ void mark_rodata_ro(void) { unsigned long section_size; - section_size = (unsigned long)__start_rodata - (unsigned long)_stext; - create_mapping_late(__pa(_stext), (unsigned long)_stext, + section_size = (unsigned long)__start_rodata - (unsigned long)_text; + create_mapping_late(__pa(_text), (unsigned long)_text, section_size, PAGE_KERNEL_ROX); /* * mark .rodata as read only. Use _etext rather than __end_rodata to @@ -499,7 +499,7 @@ static void __init map_kernel(pgd_t *pgd) { static struct vm_struct vmlinux_text, vmlinux_rodata, vmlinux_init, vmlinux_data; - map_kernel_segment(pgd, _stext, __start_rodata, PAGE_KERNEL_EXEC, &vmlinux_text); + map_kernel_segment(pgd, _text, __start_rodata, PAGE_KERNEL_EXEC, &vmlinux_text); map_kernel_segment(pgd, __start_rodata, _etext, PAGE_KERNEL, &vmlinux_rodata); map_kernel_segment(pgd, __init_begin, __init_end, PAGE_KERNEL_EXEC, &vmlinux_init);