summaryrefslogtreecommitdiff
path: root/arch/x86/tools
diff options
context:
space:
mode:
authorBrian Gerst <brgerst@gmail.com>2025-01-23 14:07:40 -0500
committerIngo Molnar <mingo@kernel.org>2025-02-18 10:15:27 +0100
commit9d7de2aa8b41407bc96d89a80dc1fd637d389d42 (patch)
treeb94af48af75aa5b347f9624e73fd7dc1821a4e2d /arch/x86/tools
parent80d47defddc000271502057ebd7efa4fd6481542 (diff)
downloadlinux-next-9d7de2aa8b41407bc96d89a80dc1fd637d389d42.tar.gz
linux-next-9d7de2aa8b41407bc96d89a80dc1fd637d389d42.zip
x86/percpu/64: Use relative percpu offsets
The percpu section is currently linked at absolute address 0, because older compilers hard-coded the stack protector canary value at a fixed offset from the start of the GS segment. Now that the canary is a normal percpu variable, the percpu section does not need to be linked at a specific address. x86-64 will now calculate the percpu offsets as the delta between the initial percpu address and the dynamically allocated memory, like other architectures. Note that GSBASE is limited to the canonical address width (48 or 57 bits, sign-extended). As long as the kernel text, modules, and the dynamically allocated percpu memory are all in the negative address space, the delta will not overflow this limit. Signed-off-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Uros Bizjak <ubizjak@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20250123190747.745588-9-brgerst@gmail.com
Diffstat (limited to 'arch/x86/tools')
-rw-r--r--arch/x86/tools/relocs.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index 92a1e503305e..3cb3b30b6706 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -835,12 +835,7 @@ static void percpu_init(void)
*/
static int is_percpu_sym(ElfW(Sym) *sym, const char *symname)
{
- int shndx = sym_index(sym);
-
- return (shndx == per_cpu_shndx) &&
- strcmp(symname, "__init_begin") &&
- strcmp(symname, "__per_cpu_load") &&
- strncmp(symname, "init_per_cpu_", 13);
+ return 0;
}
@@ -1062,7 +1057,8 @@ static int cmp_relocs(const void *va, const void *vb)
static void sort_relocs(struct relocs *r)
{
- qsort(r->offset, r->count, sizeof(r->offset[0]), cmp_relocs);
+ if (r->count)
+ qsort(r->offset, r->count, sizeof(r->offset[0]), cmp_relocs);
}
static int write32(uint32_t v, FILE *f)