From patchwork Wed Feb 3 19:04:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61145 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp27412lbl; Wed, 3 Feb 2016 11:06:47 -0800 (PST) X-Received: by 10.66.220.170 with SMTP id px10mr4707425pac.145.1454526405830; Wed, 03 Feb 2016 11:06:45 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id oj11si10839277pab.106.2016.02.03.11.06.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2016 11:06:45 -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 1aR2kJ-0000r2-2T; Wed, 03 Feb 2016 19:05:43 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aR2k2-0008Ba-9P for linux-arm-kernel@lists.infradead.org; Wed, 03 Feb 2016 19:05:28 +0000 Received: by mail-wm0-x232.google.com with SMTP id r129so179673262wmr.0 for ; Wed, 03 Feb 2016 11:05:05 -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=X8ZyXOFLEuy8mh1tzNIMIozjud6chPMWo/j9nfDl/hk=; b=fJ5bqA69BhyVNxSaVAswOWB30bO1r1CEOXrPG2qSQLiwawhyjs+nOJh3sfqNIzP+cF SYtqtliUCSABQQdzXURxowtJNecaa/62BoKFdVNG1uJpEB8s7ixlgepTYoJLFo7W7nCa dn6KuCYG67CMZAeqWv8iVUFucZFW2BO7OC0Uw= 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=X8ZyXOFLEuy8mh1tzNIMIozjud6chPMWo/j9nfDl/hk=; b=SisEIs2GlqVVJoygby9yyy425UX3oeVaBbLVdA7ThYg30c0wZvMan5y07v1lMBsgzI kQJDL3uAzsSnYJErTR3ajevCV1ACcRRhee/oA5pWAlSjaRUT2xc5uRwH2GfFv5Hbarpm G9Tgw3S+5R1On2cZQ6yNemngKqae44tzQoLpbthDCjE/DMTZtayfRr8En6TS9LevcOrt cQY8/p9nJGq6+14a7uIeizAqX7ZvLAuhpXlYLQdeC6vkX7z1lx/h/uD28wEXYthyRARk uDfu9062k5+eUc/+fJP3rtFRsvC4WhPpZ6yCWui6Es04NxXj2/qlwPl8QpJnojaUmTue bJlw== X-Gm-Message-State: AG10YORVLhgl68blZuEGos6AQys1Xog5qmtbuH/1BIFkepCgrJMvYm6mq1akOAcjsNqEpBga X-Received: by 10.194.203.168 with SMTP id kr8mr3700537wjc.168.1454526304527; Wed, 03 Feb 2016 11:05:04 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id k130sm9299460wmg.6.2016.02.03.11.05.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Feb 2016 11:05:03 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, arnd@arndb.de Subject: [PATCH v2 1/4] ARM: move .vectors and .stubs sections back into the kernel VMA Date: Wed, 3 Feb 2016 20:04:54 +0100 Message-Id: <1454526297-5269-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454526297-5269-1-git-send-email-ard.biesheuvel@linaro.org> References: <1454526297-5269-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160203_110526_731188_E50C6781 X-CRM114-Status: GOOD ( 16.48 ) 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:232 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 Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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: Chris.Brandt@renesas.com, 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 Acked-by: Nicolas Pitre 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..9f96a54c7d90 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 : { + __stubs_start = .; + *(.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 = .; + PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors)); INIT_TEXT_SECTION(8) .exit.text : {