Skip to content

Commit 5d95934

Browse files
committed
Merge tag 'loongarch-fixes-6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai Chen: "Fix high_memory calculation and module loader errors with latest binutils" * tag 'loongarch-fixes-6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: Add support for 64_PCREL relocation type LoongArch: Add support for 32_PCREL relocation type LoongArch: Define relocation types for ABI v2.10 LoongArch: numa: Fix high_memory calculation
2 parents 52a6d9b + b1dc55a commit 5d95934

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

arch/loongarch/include/asm/elf.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@
111111
#define R_LARCH_TLS_GD_HI20 98
112112
#define R_LARCH_32_PCREL 99
113113
#define R_LARCH_RELAX 100
114+
#define R_LARCH_DELETE 101
115+
#define R_LARCH_ALIGN 102
116+
#define R_LARCH_PCREL20_S2 103
117+
#define R_LARCH_CFA 104
118+
#define R_LARCH_ADD6 105
119+
#define R_LARCH_SUB6 106
120+
#define R_LARCH_ADD_ULEB128 107
121+
#define R_LARCH_SUB_ULEB128 108
122+
#define R_LARCH_64_PCREL 109
114123

115124
#ifndef ELF_ARCH
116125

arch/loongarch/kernel/module.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,24 @@ static int apply_r_larch_got_pc(struct module *mod,
367367
return apply_r_larch_pcala(mod, location, got, rela_stack, rela_stack_top, type);
368368
}
369369

370+
static int apply_r_larch_32_pcrel(struct module *mod, u32 *location, Elf_Addr v,
371+
s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
372+
{
373+
ptrdiff_t offset = (void *)v - (void *)location;
374+
375+
*(u32 *)location = offset;
376+
return 0;
377+
}
378+
379+
static int apply_r_larch_64_pcrel(struct module *mod, u32 *location, Elf_Addr v,
380+
s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
381+
{
382+
ptrdiff_t offset = (void *)v - (void *)location;
383+
384+
*(u64 *)location = offset;
385+
return 0;
386+
}
387+
370388
/*
371389
* reloc_handlers_rela() - Apply a particular relocation to a module
372390
* @mod: the module to apply the reloc to
@@ -382,7 +400,7 @@ typedef int (*reloc_rela_handler)(struct module *mod, u32 *location, Elf_Addr v,
382400

383401
/* The handlers for known reloc types */
384402
static reloc_rela_handler reloc_rela_handlers[] = {
385-
[R_LARCH_NONE ... R_LARCH_RELAX] = apply_r_larch_error,
403+
[R_LARCH_NONE ... R_LARCH_64_PCREL] = apply_r_larch_error,
386404

387405
[R_LARCH_NONE] = apply_r_larch_none,
388406
[R_LARCH_32] = apply_r_larch_32,
@@ -396,6 +414,8 @@ static reloc_rela_handler reloc_rela_handlers[] = {
396414
[R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] = apply_r_larch_sop_imm_field,
397415
[R_LARCH_ADD32 ... R_LARCH_SUB64] = apply_r_larch_add_sub,
398416
[R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] = apply_r_larch_pcala,
417+
[R_LARCH_32_PCREL] = apply_r_larch_32_pcrel,
418+
[R_LARCH_64_PCREL] = apply_r_larch_64_pcrel,
399419
};
400420

401421
int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,

arch/loongarch/kernel/numa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ void __init paging_init(void)
436436

437437
void __init mem_init(void)
438438
{
439-
high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
439+
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
440440
memblock_free_all();
441441
}
442442

0 commit comments

Comments
 (0)