linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] solve static percpu symbol issue in module and refine code model of module
@ 2020-02-19  7:28 Vincent Chen
  2020-02-19  7:28 ` [PATCH 1/2] riscv: avoid the PIC offset of static percpu data in module beyond 2G limits Vincent Chen
  2020-02-19  7:28 ` [PATCH 2/2] riscv: Change code model of module to medany to improve data accessing Vincent Chen
  0 siblings, 2 replies; 8+ messages in thread
From: Vincent Chen @ 2020-02-19  7:28 UTC (permalink / raw)
  To: paul.walmsley, palmer; +Cc: Vincent Chen, linux-riscv, deanbo422

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

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

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(-)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-02-20  5:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19  7:28 [PATCH 0/2] solve static percpu symbol issue in module and refine code model of module Vincent Chen
2020-02-19  7:28 ` [PATCH 1/2] riscv: avoid the PIC offset of static percpu data in module beyond 2G limits Vincent Chen
2020-02-19 17:52   ` Alexandre Ghiti
2020-02-19 22:43     ` Carlos Eduardo de Paula
2020-02-20  2:31       ` Vincent Chen
2020-02-20  2:29     ` Vincent Chen
2020-02-20  5:53       ` Alex Ghiti
2020-02-19  7:28 ` [PATCH 2/2] riscv: Change code model of module to medany to improve data accessing Vincent Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).