linux-stable/arch
Ben Dooks e8716ea35e riscv: add as-options for modules with assembly compontents
commit c1f6eff304 upstream.

When trying to load modules built for RISC-V which include assembly files
the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'"
due to R_RISCV_ALIGN relocations being generated by the assembler.

The R_RISCV_ALIGN relocations can be removed at the expense of code space
by adding -mno-relax to gcc and as.  In commit 7a8e7da422
("RISC-V: Fixes to module loading") -mno-relax is added to the build
variable KBUILD_CFLAGS_MODULE. See [1] for more info.

The issue is that when kbuild builds a .S file, it invokes gcc with
the -mno-relax flag, but this is not being passed through to the
assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that
the assembler is invoked correctly. This may have now been fixed in
gcc[2] and this addition should not stop newer gcc and as from working.

[1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183
[2] 3b0a7d624e

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Link: https://lore.kernel.org/r/20220529152200.609809-1-ben.dooks@codethink.co.uk
Fixes: ab1ef68e54 ("RISC-V: Add sections of PLT and GOT for kernel module")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:27:55 +02:00
..
alpha alpha: fix alloc_zeroed_user_highpage_movable() 2022-06-09 10:29:51 +02:00
arc ARC: remove redundant READ_ONCE() in cmpxchg loop 2022-04-18 14:47:05 -07:00
arm ARM: dts: stm32: use the correct clock source for CEC on stm32mp151 2022-07-22 10:21:54 +02:00
arm64 arm64: dts: broadcom: bcm4908: Fix cpu node for smp boot 2022-07-22 10:21:33 +02:00
csky csky: patch_text: Fixup last cpu should be master 2022-06-09 10:30:50 +02:00
h8300 Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2022-04-01 19:57:03 -07:00
hexagon ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
ia64 vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
m68k m68knommu: fix undefined reference to `mach_get_rtc_pll' 2022-06-14 18:45:03 +02:00
microblaze Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
mips vmcore: convert copy_oldmem_page() to take an iov_iter 2022-06-29 09:04:36 +02:00
nios2 nios2: use fallback for random_get_entropy() instead of zero 2022-05-30 09:24:05 +02:00
openrisc openrisc: start CPU timer early in boot 2022-06-09 10:29:44 +02:00
parisc parisc/unaligned: Fix emulate_ldw() breakage 2022-07-07 17:54:46 +02:00
powerpc powerpc/xive/spapr: correct bitmap allocation size 2022-07-22 10:21:46 +02:00
riscv riscv: add as-options for modules with assembly compontents 2022-07-29 17:27:55 +02:00
s390 s390/nospec: build expoline.o for modules_prepare target 2022-07-22 10:21:45 +02:00
sh sh: convert nommu io{re,un}map() to static inline functions 2022-07-22 10:21:22 +02:00
sparc signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:30:00 +02:00
um um: Add missing apply_returns() 2022-07-23 12:57:00 +02:00
x86 x86/bugs: Remove apostrophe typo 2022-07-23 12:56:59 +02:00
xtensa xtensa: Fix refcount leak bug in time.c 2022-06-29 09:04:40 +02:00
.gitignore
Kconfig vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP 2022-04-19 12:08:57 -07:00