]> git.baikalelectronics.ru Git - kernel.git/commit
riscv: avoid the PIC offset of static percpu data in module beyond 2G limits
authorVincent Chen <vincent.chen@sifive.com>
Fri, 21 Feb 2020 02:47:54 +0000 (10:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2020 07:25:48 +0000 (08:25 +0100)
commit9c1c8c8dc38a0a332cce9cea846f901000302f28
tree3dfa10d44e27d62c1d5af6e368e187b3d4fa167d
parentd2eff37aab520704467b2cb3f1fa5b45599bcfcd
riscv: avoid the PIC offset of static percpu data in module beyond 2G limits

[ Upstream commit 2f468a58133474d85c16361e65fef8f941f9dd5a ]

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: Vincent Chen <vincent.chen@sifive.com>
Suggested-by: Alexandre Ghiti <alex@ghiti.fr>
Suggested-by: Anup Patel <anup@brainfault.org>
Tested-by: Alexandre Ghiti <alex@ghiti.fr>
Tested-by: Carlos de Paula <me@carlosedp.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/kernel/module.c