LoongArch fixes for v6.6-rc4

-----BEGIN PGP SIGNATURE-----
 
 iQJKBAABCAA0FiEEzOlt8mkP+tbeiYy5AoYrw/LiJnoFAmUT9IEWHGNoZW5odWFj
 YWlAa2VybmVsLm9yZwAKCRAChivD8uImesv0D/0YfPF+lZ5riqJRuDOa+GLT2lir
 6LD1poWr1GTsRAM0qn0q7LLb64LmDOG4Y5WoU+I0/JZVMPjcLGKDOi9YUDD4YSgV
 6QAiWeHLMHrnLyTGr5N7gYStyqh28O0//Z7upVjXeDuJ20Z1tXk+oUpg8f/98q3j
 ANyGlEOObExghBbhrS7pWXN4BT3t/PyN8/GJTPvcaAfcjmyk0NVUk25758WYKiX1
 niPd2LSiTUplMYkXnxYnqheEo73tNRkK8HdYQnUEMOwYALwz1XyPMCIZGNhTrxd1
 krphBce1nCt1Q7M8A1vUqH8XeK6mdwMIsHrWRzg0CtU0BVUnfBJgCiM4lsPBGtZF
 p9z0YADMujM696SjVExFwam3r1gARketu+idz5Rtt7FUumOWXeXYGBF4yCZ+y5S8
 oZQ2E5hLX3z/WoMaYESiW5Gm6PLDJvJbX9UhaZINStl77CS088L5fU3leuhQM6jP
 e1fLBR68N5EHNJqjaWsp/7+ap3v7O6lwSO1QsRDjXiCWmZ96ybIBYNawPyEoKOSU
 1B9Qc7Er7aNUM8SDbIuzOmrWYhVCbq+5tyJAKbPifsl9jowA5P7hqFBWJ5l/ijsy
 njMg+bbl8/NBU/+PZAaRmnXZJGMnwy/W/zfNQjm/cGXRB1vXa7/symkFIIY8UI5c
 P3pJC4n1fedzOi4P5Q==
 =g9gX
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2023-09-28 10:27:45 -07:00
commit 5d959343ae
3 changed files with 31 additions and 2 deletions

View file

@ -111,6 +111,15 @@
#define R_LARCH_TLS_GD_HI20 98
#define R_LARCH_32_PCREL 99
#define R_LARCH_RELAX 100
#define R_LARCH_DELETE 101
#define R_LARCH_ALIGN 102
#define R_LARCH_PCREL20_S2 103
#define R_LARCH_CFA 104
#define R_LARCH_ADD6 105
#define R_LARCH_SUB6 106
#define R_LARCH_ADD_ULEB128 107
#define R_LARCH_SUB_ULEB128 108
#define R_LARCH_64_PCREL 109
#ifndef ELF_ARCH

View file

@ -367,6 +367,24 @@ static int apply_r_larch_got_pc(struct module *mod,
return apply_r_larch_pcala(mod, location, got, rela_stack, rela_stack_top, type);
}
static int apply_r_larch_32_pcrel(struct module *mod, u32 *location, Elf_Addr v,
s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
{
ptrdiff_t offset = (void *)v - (void *)location;
*(u32 *)location = offset;
return 0;
}
static int apply_r_larch_64_pcrel(struct module *mod, u32 *location, Elf_Addr v,
s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
{
ptrdiff_t offset = (void *)v - (void *)location;
*(u64 *)location = offset;
return 0;
}
/*
* reloc_handlers_rela() - Apply a particular relocation to a module
* @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,
/* The handlers for known reloc types */
static reloc_rela_handler reloc_rela_handlers[] = {
[R_LARCH_NONE ... R_LARCH_RELAX] = apply_r_larch_error,
[R_LARCH_NONE ... R_LARCH_64_PCREL] = apply_r_larch_error,
[R_LARCH_NONE] = apply_r_larch_none,
[R_LARCH_32] = apply_r_larch_32,
@ -396,6 +414,8 @@ static reloc_rela_handler reloc_rela_handlers[] = {
[R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] = apply_r_larch_sop_imm_field,
[R_LARCH_ADD32 ... R_LARCH_SUB64] = apply_r_larch_add_sub,
[R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] = apply_r_larch_pcala,
[R_LARCH_32_PCREL] = apply_r_larch_32_pcrel,
[R_LARCH_64_PCREL] = apply_r_larch_64_pcrel,
};
int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,

View file

@ -436,7 +436,7 @@ void __init paging_init(void)
void __init mem_init(void)
{
high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
memblock_free_all();
}