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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *  arch/um/kernel/elf_aux.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *  Scan the Elf auxiliary vector provided by the host to extract
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *  information about vsyscall-page, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *  Copyright (C) 2004 Fujitsu Siemens Computers GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *  Author: Bodo Stroesser (bodo.stroesser@fujitsu-siemens.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <elf_user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <mem_user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) typedef Elf32_auxv_t elf_auxv_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /* These are initialized very early in boot and never changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) char * elf_aux_platform;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) extern long elf_aux_hwcap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned long vsyscall_ehdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsigned long vsyscall_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned long __kernel_vsyscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) __init void scan_elf_aux( char **envp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	long page_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	elf_auxv_t * auxv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	while ( *envp++ != NULL) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	for ( auxv = (elf_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		switch ( auxv->a_type ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 			case AT_SYSINFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 				__kernel_vsyscall = auxv->a_un.a_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 				/* See if the page is under TASK_SIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 				if (__kernel_vsyscall < (unsigned long) envp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 					__kernel_vsyscall = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			case AT_SYSINFO_EHDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 				vsyscall_ehdr = auxv->a_un.a_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 				/* See if the page is under TASK_SIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 				if (vsyscall_ehdr < (unsigned long) envp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 					vsyscall_ehdr = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 			case AT_HWCAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 				elf_aux_hwcap = auxv->a_un.a_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 			case AT_PLATFORM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)                                 /* elf.h removed the pointer elements from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)                                  * a_un, so we have to use a_val, which is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)                                  * all that's left.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)                                  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 				elf_aux_platform =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 					(char *) (long) auxv->a_un.a_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 			case AT_PAGESZ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 				page_size = auxv->a_un.a_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	if ( ! __kernel_vsyscall || ! vsyscall_ehdr ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	     ! elf_aux_hwcap || ! elf_aux_platform ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	     ! page_size || (vsyscall_ehdr % page_size) ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		__kernel_vsyscall = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		vsyscall_ehdr = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 		elf_aux_hwcap = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		elf_aux_platform = "i586";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 		vsyscall_end = vsyscall_ehdr + page_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }