From patchwork Tue Feb 2 13:19:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61022 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp728076lbb; Tue, 2 Feb 2016 05:22:49 -0800 (PST) X-Received: by 10.98.7.14 with SMTP id b14mr21660744pfd.40.1454419369248; Tue, 02 Feb 2016 05:22:49 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id y22si1985819pfi.57.2016.02.02.05.22.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Feb 2016 05:22:49 -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; 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 1aQatA-0004Jy-6I; Tue, 02 Feb 2016 13:21:00 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQasM-0002XG-BC for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2016 13:20:13 +0000 Received: by mail-wm0-x231.google.com with SMTP id l66so22419327wml.0 for ; Tue, 02 Feb 2016 05:19: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=nyxiyn+B+f6EB3Umkn6zqXt7yTqzBVahbLFu8hl6Gw8=; b=IXEa99aZaRi8T/mhQtlrHaS6COh+hxrWWxOfp5nPPaf9h8mACNSl2wAvFUBwljodEV 9//O2pt+R0DU2akDR8YHiaCvlZaBhtpfXu2xze5ieC1Qqj+zezfEgkIhq0scpF76SQ00 NZLmhabI8XMFnYLIRm/zMn9YDxfLyp0rErDEA= 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=nyxiyn+B+f6EB3Umkn6zqXt7yTqzBVahbLFu8hl6Gw8=; b=RKc++Qci/HAHwYJE/f9VwNfPZuRDgiLb2Ch91pRwcmmIWMISS0kC/x0RwSHzR2XArw 8CXcfwNtkEMAzLC7qdmNsLa1Jc7RIbOmEaiLXE6vEX9gvjyIRSb5o+MqrKmJYt3Kmcjv y5vO/xzTMtJWJzdVsfXzLfH/tgK1Em2djFqgmcyAVe4w1TqrMOacuC7cYOogneSk3LyE K1JKBibYVCoPNPUCVtbrY0YFkN8d22Fi+a3cCohvipBgIPQOmYrye64+fkFVwL14QBHp 25jn8AkIlfysodSZpRC0axThq8dzpFs/amDP6xxXmbw7o5/L4ZRGPutjRzgreYMu7dqX 6MtQ== X-Gm-Message-State: AG10YORCpMwR7ge1ZJqOulTy0z54/sirw1EkCR3omMcJQXYcHxzpiCmq8DB+/p9aijjLmQd2 X-Received: by 10.194.23.232 with SMTP id p8mr33479884wjf.80.1454419188322; Tue, 02 Feb 2016 05:19:48 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id r10sm1469906wjz.24.2016.02.02.05.19.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Feb 2016 05:19:47 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, arnd@arndb.de, broonie@linaro.org Subject: [PATCH 1/3] ARM: move .vectors and .stubs sections back into the kernel VMA Date: Tue, 2 Feb 2016 14:19:32 +0100 Message-Id: <1454419174-21290-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454419174-21290-1-git-send-email-ard.biesheuvel@linaro.org> References: <1454419174-21290-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160202_052010_652762_11DA7168 X-CRM114-Status: GOOD ( 16.24 ) 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:231 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: linus.walleij@linaro.org, Ard Biesheuvel , nico@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Commit b9b32bf70f2f ("ARM: use linker magic for vectors and vector stubs") updated the linker script to emit the .vectors and .stubs sections into a VMA range that is zero based and disjoint from the normal static kernel region. The reason for that was that this way, the sections can be placed exactly 4 KB apart, while the payload of the .vectors section is only 32 bytes. Since the symbols that are part of the .stubs section are emitted into the kallsyms table, they appear with zero based addresses as well, e.g., 00000000 t __vectors_start 00001000 t __stubs_start 00001004 t vector_rst 00001020 t vector_irq 000010a0 t vector_dabt 00001120 t vector_pabt 000011a0 t vector_und 00001220 t vector_addrexcptn 00001240 t vector_fiq 00001240 T vector_fiq_offset As this confuses perf when it accesses the kallsyms tables, commit 7122c3e9154b ("scripts/link-vmlinux.sh: only filter kernel symbols for arm") implemented a somewhat ugly special case for ARM, where the value of CONFIG_PAGE_OFFSET is passed to scripts/kallsyms, and symbols whose address is below it are filtered out. Note that this special case only applies to CONFIG_XIP_KERNEL=n, not because the issue the patch addresses exists only in that case, but because finding a limit below which to apply the filtering is too difficult. Since the constraint we are trying to meet here is that the .vectors section lives exactly 4 KB before the .stubs section, regardless of the absolute addresses of either (since relative branches are used to jump from the vector table to the stubs), we can simply emit the .stubs section as part of the kernel VMA, and place the .vectors section 4 KB before it using an explicit VMA override. By doing that, and renaming the __vectors_start symbol that is local to arch/arm/kernel/entry-armv.S (not the one in the linker script), the kallsyms table looks somewhat sane, regardless of whether CONFIG_XIP_KERNEL is set, and we can drop the special case in scripts/kallsyms entirely. E.g., 00001240 A vector_fiq_offset ... c0c35000 T __init_begin c0c35000 t __stubs_start c0c35000 T __stubs_start c0c35004 t vector_rst c0c35020 t vector_irq c0c350a0 t vector_dabt c0c35120 t vector_pabt c0c351a0 t vector_und c0c35220 t vector_addrexcptn c0c35240 T vector_fiq c0c352c0 T __stubs_end c0c352c0 T __vectors_start c0c352e0 t __mmap_switched c0c352e0 T _sinittext c0c352e0 T __vectors_end (Note that vector_fiq_offset is now an absolute symbol, which kallsyms already ignores by default) The sections themselves are emitted 4 KB apart, as required: ... [16] .stubs PROGBITS c0c35000 a35000 0002c0 00 AX 0 0 32 [17] .vectors PROGBITS c0c34000 a44000 000020 00 AX 0 0 2 ... and the relative branches in the .vectors section still point to the right place: c0c34000 <.vectors>: c0c34000: f001 b800 b.w c0c35004 c0c34004: f001 b8cc b.w c0c351a0 c0c34008: f8df fff4 ldr.w pc, [pc, #4084] ; c0c35000 c0c3400c: f001 b888 b.w c0c35120 c0c34010: f001 b846 b.w c0c350a0 c0c34014: f001 b904 b.w c0c35220 c0c34018: f001 b802 b.w c0c35020 c0c3401c: f001 b910 b.w c0c35240 Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/entry-armv.S | 7 +++---- arch/arm/kernel/vmlinux.lds.S | 15 ++++++++------- 2 files changed, 11 insertions(+), 11 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/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 3ce377f7251f..8575ff42c0d4 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -1202,14 +1202,13 @@ vector_addrexcptn: .long __fiq_svc @ e .long __fiq_svc @ f - .globl vector_fiq_offset - .equ vector_fiq_offset, vector_fiq + .globl vector_fiq .section .vectors, "ax", %progbits -__vectors_start: +.L__vectors_start: W(b) vector_rst W(b) vector_und - W(ldr) pc, __vectors_start + 0x1000 + W(ldr) pc, .L__vectors_start + 0x1000 W(b) vector_pabt W(b) vector_dabt W(b) vector_addrexcptn diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 8b60fde5ce48..7160658fd5d4 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -164,19 +164,20 @@ SECTIONS * The vectors and stubs are relocatable code, and the * only thing that matters is their relative offsets */ + __stubs_start = .; + .stubs : { + *(.stubs) + } + __stubs_end = .; + __vectors_start = .; - .vectors 0 : AT(__vectors_start) { + .vectors ADDR(.stubs) - 0x1000 : AT(__vectors_start) { *(.vectors) } . = __vectors_start + SIZEOF(.vectors); __vectors_end = .; - __stubs_start = .; - .stubs 0x1000 : AT(__stubs_start) { - *(.stubs) - } - . = __stubs_start + SIZEOF(.stubs); - __stubs_end = .; + vector_fiq_offset = vector_fiq - ADDR(.vectors); INIT_TEXT_SECTION(8) .exit.text : {