]>
Commit | Line | Data |
---|---|---|
9a904337 SL |
1 | From 7baf64c75458df5078a9a0ada893f009c328b6ed Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= | |
3 | <rafael@espindo.la> | |
4 | Date: Wed, 19 Dec 2018 11:01:43 -0800 | |
5 | Subject: x86/build: Mark per-CPU symbols as absolute explicitly for LLD | |
6 | MIME-Version: 1.0 | |
7 | Content-Type: text/plain; charset=UTF-8 | |
8 | Content-Transfer-Encoding: 8bit | |
9 | ||
10 | [ Upstream commit d071ae09a4a1414c1433d5ae9908959a7325b0ad ] | |
11 | ||
12 | Accessing per-CPU variables is done by finding the offset of the | |
13 | variable in the per-CPU block and adding it to the address of the | |
14 | respective CPU's block. | |
15 | ||
16 | Section 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 | ||
26 | Note that LLVM's linker does not adhere to the GNU ld's implementation | |
27 | and as such requires implicitly-absolute terms to be explicitly marked | |
28 | as 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 | ||
34 | This is not a functional change for ld.bfd which converts the term to an | |
35 | absolute symbol anyways as specified above. | |
36 | ||
37 | Based on a previous submission by Tri Vo <trong@android.com>. | |
38 | ||
39 | Reported-by: Dmitry Golovin <dima@golovin.in> | |
40 | Signed-off-by: Rafael Ávila de Espíndola <rafael@espindo.la> | |
41 | [ Update commit message per Boris' and Michael's suggestions. ] | |
42 | Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> | |
43 | [ Massage commit message more, fix typos. ] | |
44 | Signed-off-by: Borislav Petkov <bp@suse.de> | |
45 | Tested-by: Dmitry Golovin <dima@golovin.in> | |
46 | Cc: "H. Peter Anvin" <hpa@zytor.com> | |
47 | Cc: Andy Lutomirski <luto@kernel.org> | |
48 | Cc: Brijesh Singh <brijesh.singh@amd.com> | |
49 | Cc: Cao Jin <caoj.fnst@cn.fujitsu.com> | |
50 | Cc: Ingo Molnar <mingo@redhat.com> | |
51 | Cc: Joerg Roedel <jroedel@suse.de> | |
52 | Cc: Masahiro Yamada <yamada.masahiro@socionext.com> | |
53 | Cc: Masami Hiramatsu <mhiramat@kernel.org> | |
54 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
55 | Cc: Tri Vo <trong@android.com> | |
56 | Cc: dima@golovin.in | |
57 | Cc: morbo@google.com | |
58 | Cc: x86-ml <x86@kernel.org> | |
59 | Link: https://lkml.kernel.org/r/20181219190145.252035-1-ndesaulniers@google.com | |
60 | Signed-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 | ||
65 | diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S | |
66 | index 49edf2dd3613..1bd47a144db1 100644 | |
67 | --- a/arch/x86/kernel/vmlinux.lds.S | |
68 | +++ b/arch/x86/kernel/vmlinux.lds.S | |
69 | @@ -345,7 +345,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 | -- | |
79 | 2.19.1 | |
80 |