diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-05-31 14:10:54 -0700 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-05-31 14:10:54 -0700 | 
| commit | 35b51afd23c98e2f055ac563aca36173a12588b9 (patch) | |
| tree | cadaa21cf4063afa7d2e420e97c1c8d186fb9795 /arch/riscv/kernel/module.c | |
| parent | e1cbc3b96a9974746b2a80c3a6c8a0f7eff7b1b5 (diff) | |
| parent | 7699f7aacf3ebfee51c670b6f796b2797f0f7487 (diff) | |
Merge tag 'riscv-for-linus-5.19-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt:
 - Support for the Svpbmt extension, which allows memory attributes to
   be encoded in pages
 - Support for the Allwinner D1's implementation of page-based memory
   attributes
 - Support for running rv32 binaries on rv64 systems, via the compat
   subsystem
 - Support for kexec_file()
 - Support for the new generic ticket-based spinlocks, which allows us
   to also move to qrwlock. These should have already gone in through
   the asm-geneic tree as well
 - A handful of cleanups and fixes, include some larger ones around
   atomics and XIP
* tag 'riscv-for-linus-5.19-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (51 commits)
  RISC-V: Prepare dropping week attribute from arch_kexec_apply_relocations[_add]
  riscv: compat: Using seperated vdso_maps for compat_vdso_info
  RISC-V: Fix the XIP build
  RISC-V: Split out the XIP fixups into their own file
  RISC-V: ignore xipImage
  RISC-V: Avoid empty create_*_mapping definitions
  riscv: Don't output a bogus mmu-type on a no MMU kernel
  riscv: atomic: Add custom conditional atomic operation implementation
  riscv: atomic: Optimize dec_if_positive functions
  riscv: atomic: Cleanup unnecessary definition
  RISC-V: Load purgatory in kexec_file
  RISC-V: Add purgatory
  RISC-V: Support for kexec_file on panic
  RISC-V: Add kexec_file support
  RISC-V: use memcpy for kexec_file mode
  kexec_file: Fix kexec_file.c build error for riscv platform
  riscv: compat: Add COMPAT Kbuild skeletal support
  riscv: compat: ptrace: Add compat_arch_ptrace implement
  riscv: compat: signal: Add rt_frame implementation
  riscv: add memory-type errata for T-Head
  ...
Diffstat (limited to 'arch/riscv/kernel/module.c')
| -rw-r--r-- | arch/riscv/kernel/module.c | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index c29cef90d1dd..91fe16bfaa07 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -11,6 +11,7 @@  #include <linux/vmalloc.h>  #include <linux/sizes.h>  #include <linux/pgtable.h> +#include <asm/alternative.h>  #include <asm/sections.h>  /* @@ -427,3 +428,31 @@ void *module_alloc(unsigned long size)  				    __builtin_return_address(0));  }  #endif + +static const Elf_Shdr *find_section(const Elf_Ehdr *hdr, +				    const Elf_Shdr *sechdrs, +				    const char *name) +{ +	const Elf_Shdr *s, *se; +	const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; + +	for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { +		if (strcmp(name, secstrs + s->sh_name) == 0) +			return s; +	} + +	return NULL; +} + +int module_finalize(const Elf_Ehdr *hdr, +		    const Elf_Shdr *sechdrs, +		    struct module *me) +{ +	const Elf_Shdr *s; + +	s = find_section(hdr, sechdrs, ".alternative"); +	if (s) +		apply_module_alternatives((void *)s->sh_addr, s->sh_size); + +	return 0; +} | 
