Skip to content

Commit d72c4a3

Browse files
daxtensmpe
authored andcommitted
powerpc/64/asm: Do not reassign labels
The LLVM integrated assembler really does not like us reassigning things to the same label: <instantiation>:7:9: error: invalid reassignment of non-absolute variable 'fs_label' This happens across a bunch of platforms: ClangBuiltLinux#1043 ClangBuiltLinux#1008 ClangBuiltLinux#920 ClangBuiltLinux#1050 There is no hope of getting this fixed in LLVM (see ClangBuiltLinux#1043 (comment) and https://bugs.llvm.org/show_bug.cgi?id=47798#c1 ) so if we want to build with LLVM_IAS, we need to hack around it ourselves. For us the big problem comes from this: \#define USE_FIXED_SECTION(sname) \ fs_label = start_##sname; \ fs_start = sname##_start; \ use_ftsec sname; \#define USE_TEXT_SECTION() fs_label = start_text; \ fs_start = text_start; \ .text and in particular fs_label. This works around it by not setting those 'variables' and requiring that users of the variables instead track for themselves what section they are in. This isn't amazing, by any stretch, but it gets us further in the compilation. Note that even though users have to keep track of the section, using a wrong one produces an error with both binutils and llvm which prevents from using wrong section at the compile time: llvm error example: AS arch/powerpc/kernel/head_64.o <unknown>:0: error: Cannot represent a difference across sections make[3]: *** [/home/aik/p/kernels-llvm/llvm/scripts/Makefile.build:388: arch/powerpc/kernel/head_64.o] Error 1 binutils error example: /home/aik/p/kernels-llvm/llvm/arch/powerpc/kernel/exceptions-64s.S: Assembler messages: /home/aik/p/kernels-llvm/llvm/arch/powerpc/kernel/exceptions-64s.S:1974: Error: can't resolve `system_call_common' {.text section} - `start_r eal_vectors' {.head.text.real_vectors section} make[3]: *** [/home/aik/p/kernels-llvm/llvm/scripts/Makefile.build:388: arch/powerpc/kernel/head_64.o] Error 1 Signed-off-by: Daniel Axtens <[email protected]> Signed-off-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fd98395 commit d72c4a3

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

arch/powerpc/include/asm/head-64.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,9 @@ linker_stub_catch: \
9898
. = sname##_len;
9999

100100
#define USE_FIXED_SECTION(sname) \
101-
fs_label = start_##sname; \
102-
fs_start = sname##_start; \
103101
use_ftsec sname;
104102

105103
#define USE_TEXT_SECTION() \
106-
fs_label = start_text; \
107-
fs_start = text_start; \
108104
.text
109105

110106
#define CLOSE_FIXED_SECTION(sname) \
@@ -161,13 +157,15 @@ end_##sname:
161157
* - ABS_ADDR is used to find the absolute address of any symbol, from within
162158
* a fixed section.
163159
*/
164-
#define DEFINE_FIXED_SYMBOL(label) \
165-
label##_absolute = (label - fs_label + fs_start)
160+
// define label as being _in_ sname
161+
#define DEFINE_FIXED_SYMBOL(label, sname) \
162+
label##_absolute = (label - start_ ## sname + sname ## _start)
166163

167164
#define FIXED_SYMBOL_ABS_ADDR(label) \
168165
(label##_absolute)
169166

170-
#define ABS_ADDR(label) (label - fs_label + fs_start)
167+
// find label from _within_ sname
168+
#define ABS_ADDR(label, sname) (label - start_ ## sname + sname ## _start)
171169

172170
#endif /* __ASSEMBLY__ */
173171

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
.balign IFETCH_ALIGN_BYTES; \
4949
.global name; \
5050
_ASM_NOKPROBE_SYMBOL(name); \
51-
DEFINE_FIXED_SYMBOL(name); \
51+
DEFINE_FIXED_SYMBOL(name, text); \
5252
name:
5353

5454
#define TRAMP_REAL_BEGIN(name) \
@@ -76,18 +76,18 @@ name:
7676
ld reg,PACAKBASE(r13); /* get high part of &label */ \
7777
ori reg,reg,FIXED_SYMBOL_ABS_ADDR(label)
7878

79-
#define __LOAD_HANDLER(reg, label) \
79+
#define __LOAD_HANDLER(reg, label, section) \
8080
ld reg,PACAKBASE(r13); \
81-
ori reg,reg,(ABS_ADDR(label))@l
81+
ori reg,reg,(ABS_ADDR(label, section))@l
8282

8383
/*
8484
* Branches from unrelocated code (e.g., interrupts) to labels outside
8585
* head-y require >64K offsets.
8686
*/
87-
#define __LOAD_FAR_HANDLER(reg, label) \
87+
#define __LOAD_FAR_HANDLER(reg, label, section) \
8888
ld reg,PACAKBASE(r13); \
89-
ori reg,reg,(ABS_ADDR(label))@l; \
90-
addis reg,reg,(ABS_ADDR(label))@h
89+
ori reg,reg,(ABS_ADDR(label, section))@l; \
90+
addis reg,reg,(ABS_ADDR(label, section))@h
9191

9292
/*
9393
* Interrupt code generation macros
@@ -381,7 +381,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
381381
* This switches to virtual mode and sets MSR[RI].
382382
*/
383383
.macro __GEN_COMMON_ENTRY name
384-
DEFINE_FIXED_SYMBOL(\name\()_common_real)
384+
DEFINE_FIXED_SYMBOL(\name\()_common_real, text)
385385
\name\()_common_real:
386386
.if IKVM_REAL
387387
KVMTEST \name kvm_interrupt
@@ -404,7 +404,7 @@ DEFINE_FIXED_SYMBOL(\name\()_common_real)
404404
.endif
405405

406406
.balign IFETCH_ALIGN_BYTES
407-
DEFINE_FIXED_SYMBOL(\name\()_common_virt)
407+
DEFINE_FIXED_SYMBOL(\name\()_common_virt, text)
408408
\name\()_common_virt:
409409
.if IKVM_VIRT
410410
KVMTEST \name kvm_interrupt
@@ -418,7 +418,7 @@ DEFINE_FIXED_SYMBOL(\name\()_common_virt)
418418
* want to run in real mode.
419419
*/
420420
.macro __GEN_REALMODE_COMMON_ENTRY name
421-
DEFINE_FIXED_SYMBOL(\name\()_common_real)
421+
DEFINE_FIXED_SYMBOL(\name\()_common_real, text)
422422
\name\()_common_real:
423423
.if IKVM_REAL
424424
KVMTEST \name kvm_interrupt
@@ -852,12 +852,12 @@ SOFT_MASK_TABLE(0xc000000000003000, 0xc000000000004000)
852852

853853
#ifdef CONFIG_RELOCATABLE
854854
TRAMP_VIRT_BEGIN(system_call_vectored_tramp)
855-
__LOAD_HANDLER(r10, system_call_vectored_common)
855+
__LOAD_HANDLER(r10, system_call_vectored_common, virt_trampolines)
856856
mtctr r10
857857
bctr
858858

859859
TRAMP_VIRT_BEGIN(system_call_vectored_sigill_tramp)
860-
__LOAD_HANDLER(r10, system_call_vectored_sigill)
860+
__LOAD_HANDLER(r10, system_call_vectored_sigill, virt_trampolines)
861861
mtctr r10
862862
bctr
863863
#endif
@@ -961,7 +961,7 @@ TRAMP_REAL_BEGIN(system_reset_idle_wake)
961961
/* We are waking up from idle, so may clobber any volatile register */
962962
cmpwi cr1,r5,2
963963
bltlr cr1 /* no state loss, return to idle caller with r3=SRR1 */
964-
__LOAD_FAR_HANDLER(r12, DOTSYM(idle_return_gpr_loss))
964+
__LOAD_FAR_HANDLER(r12, DOTSYM(idle_return_gpr_loss), real_trampolines)
965965
mtctr r12
966966
bctr
967967
#endif
@@ -1960,12 +1960,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
19601960
HMT_MEDIUM
19611961

19621962
.if ! \virt
1963-
__LOAD_HANDLER(r10, system_call_common_real)
1963+
__LOAD_HANDLER(r10, system_call_common_real, real_vectors)
19641964
mtctr r10
19651965
bctr
19661966
.else
19671967
#ifdef CONFIG_RELOCATABLE
1968-
__LOAD_HANDLER(r10, system_call_common)
1968+
__LOAD_HANDLER(r10, system_call_common, virt_vectors)
19691969
mtctr r10
19701970
bctr
19711971
#else
@@ -2019,7 +2019,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
20192019
* Requires __LOAD_FAR_HANDLER beause kvmppc_hcall lives
20202020
* outside the head section.
20212021
*/
2022-
__LOAD_FAR_HANDLER(r10, kvmppc_hcall)
2022+
__LOAD_FAR_HANDLER(r10, kvmppc_hcall, real_trampolines)
20232023
mtctr r10
20242024
bctr
20252025
#else
@@ -3061,7 +3061,7 @@ USE_FIXED_SECTION(virt_trampolines)
30613061
.align 7
30623062
.globl __end_interrupts
30633063
__end_interrupts:
3064-
DEFINE_FIXED_SYMBOL(__end_interrupts)
3064+
DEFINE_FIXED_SYMBOL(__end_interrupts, virt_trampolines)
30653065

30663066
CLOSE_FIXED_SECTION(real_vectors);
30673067
CLOSE_FIXED_SECTION(real_trampolines);

arch/powerpc/kernel/head_64.S

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ __secondary_hold_acknowledge:
126126
. = 0x5c
127127
.globl __run_at_load
128128
__run_at_load:
129-
DEFINE_FIXED_SYMBOL(__run_at_load)
129+
DEFINE_FIXED_SYMBOL(__run_at_load, first_256B)
130130
.long RUN_AT_LOAD_DEFAULT
131131
#endif
132132

@@ -156,15 +156,15 @@ __secondary_hold:
156156
/* Tell the master cpu we're here */
157157
/* Relocation is off & we are located at an address less */
158158
/* than 0x100, so only need to grab low order offset. */
159-
std r24,(ABS_ADDR(__secondary_hold_acknowledge))(0)
159+
std r24,(ABS_ADDR(__secondary_hold_acknowledge, first_256B))(0)
160160
sync
161161

162162
li r26,0
163163
#ifdef CONFIG_PPC_BOOK3E
164164
tovirt(r26,r26)
165165
#endif
166166
/* All secondary cpus wait here until told to start. */
167-
100: ld r12,(ABS_ADDR(__secondary_hold_spinloop))(r26)
167+
100: ld r12,(ABS_ADDR(__secondary_hold_spinloop, first_256B))(r26)
168168
cmpdi 0,r12,0
169169
beq 100b
170170

@@ -649,15 +649,15 @@ __after_prom_start:
649649
3:
650650
#endif
651651
/* # bytes of memory to copy */
652-
lis r5,(ABS_ADDR(copy_to_here))@ha
653-
addi r5,r5,(ABS_ADDR(copy_to_here))@l
652+
lis r5,(ABS_ADDR(copy_to_here, text))@ha
653+
addi r5,r5,(ABS_ADDR(copy_to_here, text))@l
654654

655655
bl copy_and_flush /* copy the first n bytes */
656656
/* this includes the code being */
657657
/* executed here. */
658658
/* Jump to the copy of this code that we just made */
659-
addis r8,r3,(ABS_ADDR(4f))@ha
660-
addi r12,r8,(ABS_ADDR(4f))@l
659+
addis r8,r3,(ABS_ADDR(4f, text))@ha
660+
addi r12,r8,(ABS_ADDR(4f, text))@l
661661
mtctr r12
662662
bctr
663663

@@ -669,8 +669,8 @@ p_end: .8byte _end - copy_to_here
669669
* Now copy the rest of the kernel up to _end, add
670670
* _end - copy_to_here to the copy limit and run again.
671671
*/
672-
addis r8,r26,(ABS_ADDR(p_end))@ha
673-
ld r8,(ABS_ADDR(p_end))@l(r8)
672+
addis r8,r26,(ABS_ADDR(p_end, text))@ha
673+
ld r8,(ABS_ADDR(p_end, text))@l(r8)
674674
add r5,r5,r8
675675
5: bl copy_and_flush /* copy the rest */
676676

arch/powerpc/kernel/interrupt_64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ interrupt_return_macro hsrr
695695

696696
.globl __end_soft_masked
697697
__end_soft_masked:
698-
DEFINE_FIXED_SYMBOL(__end_soft_masked)
698+
DEFINE_FIXED_SYMBOL(__end_soft_masked, text)
699699
#endif /* CONFIG_PPC_BOOK3S */
700700

701701
#ifdef CONFIG_PPC_BOOK3S

0 commit comments

Comments
 (0)