Changeset View
Changeset View
Standalone View
Standalone View
sys/riscv/riscv/elf_machdep.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <vm/vm_param.h> | #include <vm/vm_param.h> | ||||
#include <machine/elf.h> | #include <machine/elf.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
alc: Unnecessary. Already included by vm/pmap.h. | |||||
static const char *riscv_machine_arch(struct proc *p); | static const char *riscv_machine_arch(struct proc *p); | ||||
u_long elf_hwcap; | u_long elf_hwcap; | ||||
struct sysentvec elf64_freebsd_sysvec = { | static struct sysentvec elf64_freebsd_sysvec = { | ||||
.sv_size = SYS_MAXSYSCALL, | .sv_size = SYS_MAXSYSCALL, | ||||
.sv_table = sysent, | .sv_table = sysent, | ||||
.sv_transtrap = NULL, | .sv_transtrap = NULL, | ||||
.sv_fixup = __elfN(freebsd_fixup), | .sv_fixup = __elfN(freebsd_fixup), | ||||
.sv_sendsig = sendsig, | .sv_sendsig = sendsig, | ||||
.sv_sigcode = sigcode, | .sv_sigcode = sigcode, | ||||
.sv_szsigcode = &szsigcode, | .sv_szsigcode = &szsigcode, | ||||
.sv_name = "FreeBSD ELF64", | .sv_name = "FreeBSD ELF64", | ||||
.sv_coredump = __elfN(coredump), | .sv_coredump = __elfN(coredump), | ||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD, | .sv_elf_core_osabi = ELFOSABI_FREEBSD, | ||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, | .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, | ||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes), | .sv_elf_core_prepare_notes = __elfN(prepare_notes), | ||||
.sv_imgact_try = NULL, | .sv_imgact_try = NULL, | ||||
.sv_minsigstksz = MINSIGSTKSZ, | .sv_minsigstksz = MINSIGSTKSZ, | ||||
.sv_minuser = VM_MIN_ADDRESS, | .sv_minuser = VM_MIN_ADDRESS, | ||||
.sv_maxuser = VM_MAXUSER_ADDRESS, | .sv_maxuser = 0, /* Filled in during boot. */ | ||||
.sv_usrstack = USRSTACK, | .sv_usrstack = 0, /* Filled in during boot. */ | ||||
.sv_psstrings = PS_STRINGS, | .sv_psstrings = 0, /* Filled in during boot. */ | ||||
.sv_psstringssz = sizeof(struct ps_strings), | .sv_psstringssz = sizeof(struct ps_strings), | ||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, | .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, | ||||
.sv_copyout_auxargs = __elfN(freebsd_copyout_auxargs), | .sv_copyout_auxargs = __elfN(freebsd_copyout_auxargs), | ||||
.sv_copyout_strings = exec_copyout_strings, | .sv_copyout_strings = exec_copyout_strings, | ||||
.sv_setregs = exec_setregs, | .sv_setregs = exec_setregs, | ||||
.sv_fixlimit = NULL, | .sv_fixlimit = NULL, | ||||
.sv_maxssiz = NULL, | .sv_maxssiz = NULL, | ||||
.sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_SHP | SV_TIMEKEEP | | .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_SHP | SV_TIMEKEEP | | ||||
SV_ASLR | SV_RNG_SEED_VER, | SV_ASLR | SV_RNG_SEED_VER, | ||||
.sv_set_syscall_retval = cpu_set_syscall_retval, | .sv_set_syscall_retval = cpu_set_syscall_retval, | ||||
.sv_fetch_syscall_args = cpu_fetch_syscall_args, | .sv_fetch_syscall_args = cpu_fetch_syscall_args, | ||||
.sv_syscallnames = syscallnames, | .sv_syscallnames = syscallnames, | ||||
.sv_shared_page_base = SHAREDPAGE, | .sv_shared_page_base = 0, /* Filled in during boot. */ | ||||
.sv_shared_page_len = PAGE_SIZE, | .sv_shared_page_len = PAGE_SIZE, | ||||
.sv_schedtail = NULL, | .sv_schedtail = NULL, | ||||
.sv_thread_detach = NULL, | .sv_thread_detach = NULL, | ||||
.sv_trap = NULL, | .sv_trap = NULL, | ||||
.sv_hwcap = &elf_hwcap, | .sv_hwcap = &elf_hwcap, | ||||
.sv_machine_arch = riscv_machine_arch, | .sv_machine_arch = riscv_machine_arch, | ||||
.sv_onexec_old = exec_onexec_old, | .sv_onexec_old = exec_onexec_old, | ||||
.sv_onexit = exit_onexit, | .sv_onexit = exit_onexit, | ||||
Show All 18 Lines | static Elf64_Brandinfo freebsd_brand_info = { | ||||
.compat_3_brand = "FreeBSD", | .compat_3_brand = "FreeBSD", | ||||
.emul_path = NULL, | .emul_path = NULL, | ||||
.interp_path = "/libexec/ld-elf.so.1", | .interp_path = "/libexec/ld-elf.so.1", | ||||
.sysvec = &elf64_freebsd_sysvec, | .sysvec = &elf64_freebsd_sysvec, | ||||
.interp_newpath = NULL, | .interp_newpath = NULL, | ||||
.brand_note = &elf64_freebsd_brandnote, | .brand_note = &elf64_freebsd_brandnote, | ||||
.flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE | .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE | ||||
}; | }; | ||||
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_FIRST, | SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_FIRST, | ||||
(sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_info); | (sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_info); | ||||
static void | |||||
elf64_register_sysvec(void *arg) | |||||
{ | |||||
struct sysentvec *sv; | |||||
sv = arg; | |||||
switch (pmap_mode) { | |||||
case PMAP_MODE_SV48: | |||||
sv->sv_maxuser = VM_MAX_USER_ADDRESS_SV48; | |||||
sv->sv_usrstack = USRSTACK_SV48; | |||||
sv->sv_psstrings = PS_STRINGS_SV48; | |||||
sv->sv_shared_page_base = SHAREDPAGE_SV48; | |||||
break; | |||||
case PMAP_MODE_SV39: | |||||
sv->sv_maxuser = VM_MAX_USER_ADDRESS_SV39; | |||||
sv->sv_usrstack = USRSTACK_SV39; | |||||
sv->sv_psstrings = PS_STRINGS_SV39; | |||||
sv->sv_shared_page_base = SHAREDPAGE_SV39; | |||||
break; | |||||
} | |||||
} | |||||
SYSINIT(elf64_register_sysvec, SI_SUB_VM, SI_ORDER_ANY, elf64_register_sysvec, | |||||
Done Inline ActionsPresumably you could execute this as soon as you know the pmap mode (that is, it could be earlier in case someone is nervous about the sysentvec not being initialized when the existing sysinits are executed?) That said, I think it probably doesn't really matter as we don't really use the sysentvec fields until we try to exec init. jhb: Presumably you could execute this as soon as you know the pmap mode (that is, it could be… | |||||
&elf64_freebsd_sysvec); | |||||
static bool debug_kld; | static bool debug_kld; | ||||
SYSCTL_BOOL(_debug, OID_AUTO, kld_reloc, CTLFLAG_RW, &debug_kld, 0, | SYSCTL_BOOL(_debug, OID_AUTO, kld_reloc, CTLFLAG_RW, &debug_kld, 0, | ||||
"Activate debug prints in elf_reloc_internal()"); | "Activate debug prints in elf_reloc_internal()"); | ||||
struct type2str_ent { | struct type2str_ent { | ||||
int type; | int type; | ||||
const char *str; | const char *str; | ||||
▲ Show 20 Lines • Show All 393 Lines • Show Last 20 Lines |
Unnecessary. Already included by vm/pmap.h.