Skip to content

solve static percpu symbol issue in module and refine code model of module

Vincent Chen linux-riscv 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest0 of 2 patches 1 replyIn review

Changes from v1->v2 from the cover letter

1. Unify the definition of VMALLOC_MODULE_START
2. Modify the indent

Patches in v1 No applies recorded yet

None of the 2 patches the cover letter announces are in this archive.

Reviews trailers per patch

PatchAlexandre GhitiCarlos de Paula
SeriesT-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] solve static percpu symbol issue in module and refine code model of module

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].

Because the loaded module locates in the region [&_end-2G,VMALLOC_END] at runtime, the distance from the module start to the end of the kernel image does not exceed 2GB. Hence, the second patch changes the code model of the kernel module from PIC to medany to improve the performance of data access.

Changes from v1->v2
1. Unify the definition of VMALLOC_MODULE_START
2. Modify the indent

Vincent Chen (2):
riscv: avoid the PIC offset of static percpu data in module beyond 2G
limits
riscv: Replace PIC with medany to improve data accessing in module

 arch/riscv/Makefile        |  6 ++++--
 arch/riscv/kernel/module.c | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4