]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.34/x86-build-mark-per-cpu-symbols-as-absolute-explicitl.patch
Linux 4.19.34
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / x86-build-mark-per-cpu-symbols-as-absolute-explicitl.patch
CommitLineData
ba172962
SL
1From 865c5f0c601ff568994c3eae6116e8dd871833c5 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?=
3 <rafael@espindo.la>
4Date: Wed, 19 Dec 2018 11:01:43 -0800
5Subject: x86/build: Mark per-CPU symbols as absolute explicitly for LLD
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10[ Upstream commit d071ae09a4a1414c1433d5ae9908959a7325b0ad ]
11
12Accessing per-CPU variables is done by finding the offset of the
13variable in the per-CPU block and adding it to the address of the
14respective CPU's block.
15
16Section 3.10.8 of ld.bfd's documentation states:
17
18 For expressions involving numbers, relative addresses and absolute
19 addresses, ld follows these rules to evaluate terms:
20
21 Other binary operations, that is, between two relative addresses
22 not in the same section, or between a relative address and an
23 absolute address, first convert any non-absolute term to an
24 absolute address before applying the operator."
25
26Note that LLVM's linker does not adhere to the GNU ld's implementation
27and as such requires implicitly-absolute terms to be explicitly marked
28as absolute in the linker script. If not, it fails currently with:
29
30 ld.lld: error: ./arch/x86/kernel/vmlinux.lds:153: at least one side of the expression must be absolute
31 ld.lld: error: ./arch/x86/kernel/vmlinux.lds:154: at least one side of the expression must be absolute
32 Makefile:1040: recipe for target 'vmlinux' failed
33
34This is not a functional change for ld.bfd which converts the term to an
35absolute symbol anyways as specified above.
36
37Based on a previous submission by Tri Vo <trong@android.com>.
38
39Reported-by: Dmitry Golovin <dima@golovin.in>
40Signed-off-by: Rafael Ávila de Espíndola <rafael@espindo.la>
41[ Update commit message per Boris' and Michael's suggestions. ]
42Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
43[ Massage commit message more, fix typos. ]
44Signed-off-by: Borislav Petkov <bp@suse.de>
45Tested-by: Dmitry Golovin <dima@golovin.in>
46Cc: "H. Peter Anvin" <hpa@zytor.com>
47Cc: Andy Lutomirski <luto@kernel.org>
48Cc: Brijesh Singh <brijesh.singh@amd.com>
49Cc: Cao Jin <caoj.fnst@cn.fujitsu.com>
50Cc: Ingo Molnar <mingo@redhat.com>
51Cc: Joerg Roedel <jroedel@suse.de>
52Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
53Cc: Masami Hiramatsu <mhiramat@kernel.org>
54Cc: Thomas Gleixner <tglx@linutronix.de>
55Cc: Tri Vo <trong@android.com>
56Cc: dima@golovin.in
57Cc: morbo@google.com
58Cc: x86-ml <x86@kernel.org>
59Link: https://lkml.kernel.org/r/20181219190145.252035-1-ndesaulniers@google.com
60Signed-off-by: Sasha Levin <sashal@kernel.org>
61---
62 arch/x86/kernel/vmlinux.lds.S | 2 +-
63 1 file changed, 1 insertion(+), 1 deletion(-)
64
65diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
66index 5dd3317d761f..c63bab98780c 100644
67--- a/arch/x86/kernel/vmlinux.lds.S
68+++ b/arch/x86/kernel/vmlinux.lds.S
69@@ -411,7 +411,7 @@ SECTIONS
70 * Per-cpu symbols which need to be offset from __per_cpu_load
71 * for the boot processor.
72 */
73-#define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
74+#define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x) + __per_cpu_load
75 INIT_PER_CPU(gdt_page);
76 INIT_PER_CPU(irq_stack_union);
77
78--
792.19.1
80