Skip to content
Commit a3f34939 authored by Vincent Chen's avatar Vincent Chen Committed by Greg Kroah-Hartman
Browse files

riscv: avoid the PIC offset of static percpu data in module beyond 2G limits

[ Upstream commit 0cff8bff

 ]

The compiler uses the PIC-relative method to access static variables
instead of GOT when the code model is PIC. Therefore, the limitation of
the access range from the instruction to the symbol address is +-2GB.
Under this circumstance, the kernel cannot load a kernel module if this
module has static per-CPU symbols declared by DEFINE_PER_CPU(). The reason
is that kernel relocates the .data..percpu section of the kernel module to
the end of kernel's .data..percpu. Hence, the distance between the per-CPU
symbols and the instruction will exceed the 2GB limits. To solve this
problem, the kernel should place the loaded module in the memory area
[&_end-2G, VMALLOC_END].

Signed-off-by: default avatarVincent Chen <vincent.chen@sifive.com>
Suggested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
Suggested-by: default avatarAnup Patel <anup@brainfault.org>
Tested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
Tested-by: default avatarCarlos de Paula <me@carlosedp.com>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 1804cdf9
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment