git: 2b5179105359 - main - kboot: Don't need an arch pointer to get segments
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 Feb 2023 15:50:52 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=2b5179105359537be52c7081f491a4c476aaaff4 commit 2b5179105359537be52c7081f491a4c476aaaff4 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2023-02-03 15:40:30 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-02-03 15:41:40 +0000 kboot: Don't need an arch pointer to get segments There's no need for an arch pointer to get segments. We can call the routine directly since we don't need this code to be called from different context where a pointer is needed. Sponsored by: Netflix Reviewed by: kevans, andrew Differential Revision: https://reviews.freebsd.org/D38266 --- stand/common/bootstrap.h | 3 --- stand/kboot/arch/aarch64/exec.c | 4 +--- stand/kboot/arch/amd64/elf64_freebsd.c | 4 +--- stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c | 5 ++--- stand/kboot/kboot.h | 3 +++ stand/kboot/main.c | 4 +--- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index cc22cbcb729d..80c1a2352b3c 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -372,9 +372,6 @@ struct arch_switch /* Return the hypervisor name/type or NULL if not virtualized. */ const char *(*arch_hypervisor)(void); - - /* For kexec-type loaders, get ksegment structure */ - void (*arch_kexec_kseg_get)(int *nseg, void **kseg); }; extern struct arch_switch archsw; diff --git a/stand/kboot/arch/aarch64/exec.c b/stand/kboot/arch/aarch64/exec.c index b0cb2fcbb531..521e28beb562 100644 --- a/stand/kboot/arch/aarch64/exec.c +++ b/stand/kboot/arch/aarch64/exec.c @@ -275,9 +275,7 @@ elf64_exec(struct preloaded_file *fp) archsw.arch_copyin((void *)trampcode, kernendp, tramp_size); printf("Trampoline bouncing to %#llx\n", (long long)trampoline_data->entry); - if (archsw.arch_kexec_kseg_get == NULL) - panic("architecture did not provide kexec segment mapping"); - archsw.arch_kexec_kseg_get(&nseg, &kseg); + kboot_kseg_get(&nseg, &kseg); error = host_kexec_load(trampolinebase, nseg, kseg, HOST_KEXEC_ARCH_AARCH64); if (error != 0) panic("kexec_load returned error: %d", error); diff --git a/stand/kboot/arch/amd64/elf64_freebsd.c b/stand/kboot/arch/amd64/elf64_freebsd.c index 68588c0f2f02..0d950fb61eb6 100644 --- a/stand/kboot/arch/amd64/elf64_freebsd.c +++ b/stand/kboot/arch/amd64/elf64_freebsd.c @@ -446,9 +446,7 @@ elf64_exec(struct preloaded_file *fp) /* Copy the page table to the ksegs */ archsw.arch_copyin(PT4, trampoline_data->pt4 - staging, 9 * LOADER_PAGE_SIZE); - if (archsw.arch_kexec_kseg_get == NULL) - panic("architecture did not provide kexec segment mapping"); - archsw.arch_kexec_kseg_get(&nseg, &kseg); + kboot_kseg_get(&nseg, &kseg); error = host_kexec_load(trampolinebase, nseg, kseg, HOST_KEXEC_ARCH_X86_64); if (error != 0) panic("kexec_load returned error: %d", error); diff --git a/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c b/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c index 3341771be09a..613186ab19cb 100644 --- a/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c +++ b/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include "syscall_nr.h" #include "host_syscall.h" #include "modinfo.h" +#include "kboot.h" extern char end[]; extern void *kerneltramp; @@ -148,9 +149,7 @@ ppc64_elf_exec(struct preloaded_file *fp) archsw.arch_copyin(trampoline, trampolinebase, szkerneltramp); free(trampoline); - if (archsw.arch_kexec_kseg_get == NULL) - panic("architecture did not provide kexec segment mapping"); - archsw.arch_kexec_kseg_get(&nseg, &kseg); + kboot_kseg_get(&nseg, &kseg); error = host_kexec_load(trampolinebase, nseg, kseg, HOST_KEXEC_ARCH_PPC64); if (error != 0) diff --git a/stand/kboot/kboot.h b/stand/kboot/kboot.h index 4211f21adcb6..49e5dea25b12 100644 --- a/stand/kboot/kboot.h +++ b/stand/kboot/kboot.h @@ -31,6 +31,9 @@ void fdt_arch_fixups(void *fdtp); uint64_t kboot_get_phys_load_segment(void); uint8_t kboot_get_kernel_machine_bits(void); +/* main.c */ +void kboot_kseg_get(int *nseg, void **ptr); + /* hostdisk.c */ extern const char *hostfs_root; const char *hostdisk_gen_probe(void); diff --git a/stand/kboot/main.c b/stand/kboot/main.c index 6631cb38ae22..75c2d55c3f39 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -45,7 +45,6 @@ ssize_t kboot_copyin(const void *src, vm_offset_t dest, const size_t len); ssize_t kboot_copyout(vm_offset_t src, void *dest, const size_t len); ssize_t kboot_readin(readin_handle_t fd, vm_offset_t dest, const size_t len); int kboot_autoload(void); -static void kboot_kseg_get(int *nseg, void **ptr); static void kboot_zfs_probe(void); extern int command_fdt_internal(int argc, char *argv[]); @@ -203,7 +202,6 @@ main(int argc, const char **argv) archsw.arch_copyout = kboot_copyout; archsw.arch_readin = kboot_readin; archsw.arch_autoload = kboot_autoload; - archsw.arch_kexec_kseg_get = kboot_kseg_get; archsw.arch_zfs_probe = kboot_zfs_probe; /* Give us a sane world if we're running as init */ @@ -433,7 +431,7 @@ kboot_autoload(void) return (0); } -static void +void kboot_kseg_get(int *nseg, void **ptr) { int a;