From patchwork Thu Mar 3 13:09:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63479 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2939362lbc; Thu, 3 Mar 2016 05:11:26 -0800 (PST) X-Received: by 10.98.9.92 with SMTP id e89mr3602370pfd.34.1457010686212; Thu, 03 Mar 2016 05:11:26 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fl1si4490982pab.55.2016.03.03.05.11.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Mar 2016 05:11:26 -0800 (PST) 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; 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; dkim=neutral (body hash did not verify) header.i=@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 1abT1O-0005eF-0F; Thu, 03 Mar 2016 13:10:26 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1abT16-000490-Mz for linux-arm-kernel@lists.infradead.org; Thu, 03 Mar 2016 13:10:10 +0000 Received: by mail-wm0-x22a.google.com with SMTP id p65so34073658wmp.1 for ; Thu, 03 Mar 2016 05:09:49 -0800 (PST) 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=CiWOxAtDNeQ7vrBvpxD0mDdc8LaLi9n5piEKFxxi3IA=; b=c3cHC+ntbEIQEHKsupjiMt7/r4OdYYVGj7Zo/orFt0UasXWL3hgVmS9FP4E2gy36Y9 BwzWnjtSlwRI7yZW/2XmiybJGQfIBHI7DT6seJV+aRzRL9U4RwaI22YiMNaR/GYrNt3k AaFDCvmvXl2cRBLvehPwyYOPM0kusOfCyMRWY= 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=CiWOxAtDNeQ7vrBvpxD0mDdc8LaLi9n5piEKFxxi3IA=; b=gjWcRXkBgbYLM6Olqv/3fsVgtweD7YnHuyoFR9+VSM8g69CQymlI0SEPC3LC55Ba1G EASNL3n0cgR+ZvN4MTKhEQS0B0xDjBnLqu6h1ZI0tszG6HnsUU4U43f1PY6VHtest1ha A8zgKGJFP3wFLfr7fHVVApnaStd4oTcoXv6CWyAW/8fZ/ybj2Q36Tyhx/BCWTXrgfgZW dAeAqiMptilBr8LLHu0HyKXmybIStdyB3WRghyczKtlyVu6o+IF5CWvFprl4arKdRlFv kdde9387hxuzyEWH6pCq+E4s1I8M7NiXF4ZupCrsONhbNwxJHm85OKtKCBGmWqNh2en3 38Hg== X-Gm-Message-State: AD7BkJL5R+s5izixWLdRG2UnHJ890uPv/P7Uu0dnJi2Bgbnf89xq2UMYjZ+nNxY+8cDL17Qb X-Received: by 10.28.7.9 with SMTP id 9mr5684937wmh.8.1457010588507; Thu, 03 Mar 2016 05:09:48 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id hh8sm40429803wjc.42.2016.03.03.05.09.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Mar 2016 05:09:47 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, mark.rutland@arm.com, jeremy.linton@arm.com, labbott@fedoraproject.org Subject: [PATCH 2/3] arm64: cover the .head.text section in the .text segment mapping Date: Thu, 3 Mar 2016 14:09:40 +0100 Message-Id: <1457010581-4924-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457010581-4924-1-git-send-email-ard.biesheuvel@linaro.org> References: <1457010581-4924-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160303_051009_031367_FA9748D4 X-CRM114-Status: GOOD ( 15.19 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 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 the GIC interrupt handling entry point, among other things, 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 4c56e7a0621b..7a141c098bbb 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 d2d8b8c2e17f..1d727018e90b 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -387,7 +387,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); /* @@ -419,7 +419,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. @@ -451,8 +451,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 @@ -501,7 +501,7 @@ static void __init map_kernel(pgd_t *pgd) { static struct vm_struct vmlinux_text, vmlinux_rodata, vmlinux_init, vmlinux_data; - map_kernel_chunk(pgd, _stext, __start_rodata, PAGE_KERNEL_EXEC, &vmlinux_text); + map_kernel_chunk(pgd, _text, __start_rodata, PAGE_KERNEL_EXEC, &vmlinux_text); map_kernel_chunk(pgd, __start_rodata, _etext, PAGE_KERNEL, &vmlinux_rodata); map_kernel_chunk(pgd, __init_begin, __init_end, PAGE_KERNEL_EXEC, &vmlinux_init);