Commit 5d959343 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'loongarch-fixes-6.6-2' of...

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
parents 52a6d9b5 b1dc55a3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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

+21 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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();
}