From patchwork Wed Feb 3 19:04:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61148 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp27817lbl; Wed, 3 Feb 2016 11:07:25 -0800 (PST) X-Received: by 10.98.42.74 with SMTP id q71mr4732279pfq.18.1454526445580; Wed, 03 Feb 2016 11:07:25 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fb6si10871153pab.87.2016.02.03.11.07.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2016 11:07:25 -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 1aR2l0-0001MR-BX; Wed, 03 Feb 2016 19:06:26 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aR2k7-0000Kl-42 for linux-arm-kernel@lists.infradead.org; Wed, 03 Feb 2016 19:05:33 +0000 Received: by mail-wm0-x22f.google.com with SMTP id p63so179809213wmp.1 for ; Wed, 03 Feb 2016 11:05:10 -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=m09qBO0c2dZkuRTKkqmNAvSV/CcAFheujt8iqgDLorc=; b=IQDZURSuK+HuxKWjawkyX5dLdN1TNWHdMXdlY4hFLnvyeH/8QyXsqCipkKxPJxEu/k YdXiHNIgmz4Pz9DXHFvBNCmkqn0sb8c6n/EoErLTUulGns0xSbb9FWJ4nLxAnsREauCn UL1FsihL3NBbkdK/sdZ/UkY0cRJN0X1IKTLuY= 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=m09qBO0c2dZkuRTKkqmNAvSV/CcAFheujt8iqgDLorc=; b=LgG5Nls5Q1dksLjZZudCgxw+lAZFyA38oILeSI0wT3MhG5BmCzfNuhZUPBnR/CXOoG 6+uTYZZqCCwAkCCxFkhXqGT4U3ZJQzCF0EMwEII/SdRkoaRMLl1eI9mRba6GL6EzOYGJ 7KlaXikZEgTWQnLr1/5rkffXUCdGUn8RmkBbguc2exxwQdvfvhPwDQDI2B9im/fbvvX9 OQewth2K5a5pzDQ1PK2wT/RtVt4fZ2mNXtDfYZhJ6iP1yDAmoEzk4cUbYAU7vpUjO7h+ iclE7oJlvQKgYG0TlvX03NkkY441SPD+jm2Lk1+D5uHFzoNkx5gVtbHr7VzsTot+vMMA dghg== X-Gm-Message-State: AG10YOQLq71mdGVAFKNi5oD9X4luJp0crtpN3rzcxac1PnOPRv/xM/neHSzDYOj7aLc0xR3Q X-Received: by 10.194.209.129 with SMTP id mm1mr3910586wjc.47.1454526309389; Wed, 03 Feb 2016 11:05:09 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id k130sm9299460wmg.6.2016.02.03.11.05.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Feb 2016 11:05:08 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, arnd@arndb.de Subject: [PATCH v2 4/4] ARM: use single definition for vectors-to-stubs section offset Date: Wed, 3 Feb 2016 20:04:57 +0100 Message-Id: <1454526297-5269-5-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_110531_546174_A4E693EC X-CRM114-Status: GOOD ( 15.01 ) 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:22f 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 This replaces a couple of unannotated uses of the constant 0x1000 with a single definition in the linker script, and updates the referring code to use it. Note that this involves explicitly emitting a relocation against the literal in .stubs containing the address of vector_swi(), since the assembler refuses to do so. Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/entry-armv.S | 17 +++++++++++++---- arch/arm/kernel/traps.c | 4 +++- arch/arm/kernel/vmlinux.lds.S | 9 ++++++++- 3 files changed, 24 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/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 8575ff42c0d4..c19d3b82edb8 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -1064,8 +1064,7 @@ ENDPROC(vector_\name) .endm .section .stubs, "ax", %progbits -__stubs_start: - @ This must be the first word +.Lvector_swi: .word vector_swi vector_rst: @@ -1205,16 +1204,26 @@ vector_addrexcptn: .globl vector_fiq .section .vectors, "ax", %progbits -.L__vectors_start: W(b) vector_rst W(b) vector_und - W(ldr) pc, .L__vectors_start + 0x1000 +0: W(ldr) pc, . @ vector_swi W(b) vector_pabt W(b) vector_dabt W(b) vector_addrexcptn W(b) vector_irq W(b) vector_fiq + /* + * The assembler refuses to emit the correct relocation for the + * cross-section reference to .Lvector_swi inside the ldr instruction + * above, so we have to emit it manually. Note that the addend cannot + * be set by the .reloc directive, and the initial offset recorded in + * the instruction should compensate for the PC bias of the execution + * mode, hence the use of '.' as the label. + */ + ARM( .reloc 0b, R_ARM_LDR_PC_G0, .Lvector_swi ) + THUMB( .reloc 0b, R_ARM_THM_PC12, .Lvector_swi ) + .data .globl cr_alignment diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index bc698383e822..d90a5b2c02a3 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -792,6 +792,8 @@ void __init early_trap_init(void *vectors_base) { #ifndef CONFIG_CPU_V7M unsigned long vectors = (unsigned long)vectors_base; + extern char __stubs_offset[]; + unsigned long stubs = vectors + (unsigned long)&__stubs_offset; extern char __stubs_start[], __stubs_end[]; extern char __vectors_start[], __vectors_end[]; unsigned i; @@ -813,7 +815,7 @@ void __init early_trap_init(void *vectors_base) * are visible to the instruction stream. */ memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start); - memcpy((void *)vectors + 0x1000, __stubs_start, __stubs_end - __stubs_start); + memcpy((void *)stubs, __stubs_start, __stubs_end - __stubs_start); kuser_init(vectors_base); diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 9f96a54c7d90..8f270c8e9153 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -163,7 +163,14 @@ SECTIONS /* * The vectors and stubs are relocatable code, and the * only thing that matters is their relative offsets + * The .stubs section is virtually placed exactly 4 KB after + * the .vectors section, so that it is in reach for indirect + * jumps from the vector table ('ldr pc,