Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*  Kernel module help for powerpc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)     Copyright (C) 2001, 2003 Rusty Russell IBM Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)     Copyright (C) 2008 Freescale Semiconductor, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/moduleloader.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/firmware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sort.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static LIST_HEAD(module_bug_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 				    const Elf_Shdr *sechdrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 				    const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	char *secstrings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	for (i = 1; i < hdr->e_shnum; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		if (strcmp(secstrings+sechdrs[i].sh_name, name) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 			return &sechdrs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int module_finalize(const Elf_Ehdr *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		const Elf_Shdr *sechdrs, struct module *me)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	const Elf_Shdr *sect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	rc = module_finalize_ftrace(me, sechdrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	/* Apply feature fixups */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	sect = find_section(hdr, sechdrs, "__ftr_fixup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (sect != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		do_feature_fixups(cur_cpu_spec->cpu_features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 				  (void *)sect->sh_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 				  (void *)sect->sh_addr + sect->sh_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	sect = find_section(hdr, sechdrs, "__mmu_ftr_fixup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (sect != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		do_feature_fixups(cur_cpu_spec->mmu_features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 				  (void *)sect->sh_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 				  (void *)sect->sh_addr + sect->sh_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	sect = find_section(hdr, sechdrs, "__fw_ftr_fixup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	if (sect != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		do_feature_fixups(powerpc_firmware_features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 				  (void *)sect->sh_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 				  (void *)sect->sh_addr + sect->sh_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #endif /* CONFIG_PPC64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #ifdef PPC64_ELF_ABI_v1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	sect = find_section(hdr, sechdrs, ".opd");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	if (sect != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 		me->arch.start_opd = sect->sh_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		me->arch.end_opd = sect->sh_addr + sect->sh_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #endif /* PPC64_ELF_ABI_v1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #ifdef CONFIG_PPC_BARRIER_NOSPEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	sect = find_section(hdr, sechdrs, "__spec_barrier_fixup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	if (sect != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 		do_barrier_nospec_fixups_range(barrier_nospec_enabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 				  (void *)sect->sh_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 				  (void *)sect->sh_addr + sect->sh_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #endif /* CONFIG_PPC_BARRIER_NOSPEC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	sect = find_section(hdr, sechdrs, "__lwsync_fixup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	if (sect != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 		do_lwsync_fixups(cur_cpu_spec->cpu_features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 				 (void *)sect->sh_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 				 (void *)sect->sh_addr + sect->sh_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #ifdef MODULES_VADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) void *module_alloc(unsigned long size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) 	BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 	return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, GFP_KERNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) 				    PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) 				    __builtin_return_address(0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #endif