From owner-svn-src-user@FreeBSD.ORG Sun Dec 28 15:37:52 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 581788C0; Sun, 28 Dec 2014 15:37:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AEB8662DE; Sun, 28 Dec 2014 15:37:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBSFbqHV018319; Sun, 28 Dec 2014 15:37:52 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBSFbq4p018318; Sun, 28 Dec 2014 15:37:52 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412281537.sBSFbq4p018318@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sun, 28 Dec 2014 15:37:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276329 - user/nwhitehorn/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2014 15:37:52 -0000 Author: nwhitehorn Date: Sun Dec 28 15:37:51 2014 New Revision: 276329 URL: https://svnweb.freebsd.org/changeset/base/276329 Log: Branch sys/boot for work making a kexec-based user-space loader for FreeBSD on Linux. IBM seems to have embraced kboot (Linux+kexec) as boot firmware on POWER8, so we'll need this to have a reasonable user experience. Conceivably also useful for depenguination. Added: - copied from r276328, head/sys/boot/ Directory Properties: user/nwhitehorn/kboot/ (props changed) From owner-svn-src-user@FreeBSD.ORG Sun Dec 28 16:56:55 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A85F06A4; Sun, 28 Dec 2014 16:56:55 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9355564D42; Sun, 28 Dec 2014 16:56:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBSGutwN056030; Sun, 28 Dec 2014 16:56:55 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBSGurrt056015; Sun, 28 Dec 2014 16:56:53 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412281656.sBSGurrt056015@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sun, 28 Dec 2014 16:56:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276331 - in user/nwhitehorn/kboot/powerpc: . kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2014 16:56:55 -0000 Author: nwhitehorn Date: Sun Dec 28 16:56:52 2014 New Revision: 276331 URL: https://svnweb.freebsd.org/changeset/base/276331 Log: Add some initial bits, enough to print out the loader greeting. This uses FreeBSD syscalls for now, but with changes to the numbers, it also works on Linux. Disk and network IO are the next steps. Added: user/nwhitehorn/kboot/powerpc/kboot/ user/nwhitehorn/kboot/powerpc/kboot/Makefile (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/conf.c (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/help.kboot user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/hostcons.c (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/ldscript.powerpc user/nwhitehorn/kboot/powerpc/kboot/main.c (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/metadata.c (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c (contents, props changed) user/nwhitehorn/kboot/powerpc/kboot/version Modified: user/nwhitehorn/kboot/powerpc/Makefile Modified: user/nwhitehorn/kboot/powerpc/Makefile ============================================================================== --- user/nwhitehorn/kboot/powerpc/Makefile Sun Dec 28 15:38:50 2014 (r276330) +++ user/nwhitehorn/kboot/powerpc/Makefile Sun Dec 28 16:56:52 2014 (r276331) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= boot1.chrp ofw ps3 uboot +SUBDIR= boot1.chrp kboot ofw ps3 uboot .include Added: user/nwhitehorn/kboot/powerpc/kboot/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/Makefile Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,130 @@ +# $FreeBSD$ + +.include +MK_SSP= no + +PROG= loader.kboot +NEWVERSWHAT= "kboot loader" ${MACHINE_ARCH} +BINDIR?= /boot +INSTALLFLAGS= -b + +# Architecture-specific loader code +SRCS= conf.c metadata.c vers.c main.c ppc64_elf_freebsd.c +SRCS+= host_syscall.S hostcons.c +SRCS+= ucmpdi2.c + +LOADER_DISK_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes +LOADER_CD9660_SUPPORT?= yes +LOADER_EXT2FS_SUPPORT?= yes +LOADER_NET_SUPPORT?= yes +LOADER_NFS_SUPPORT?= yes +LOADER_TFTP_SUPPORT?= no +LOADER_GZIP_SUPPORT?= yes +LOADER_FDT_SUPPORT?= no +LOADER_BZIP2_SUPPORT?= no + +.if ${LOADER_DISK_SUPPORT} == "yes" +CFLAGS+= -DLOADER_DISK_SUPPORT +.endif +.if ${LOADER_UFS_SUPPORT} == "yes" +CFLAGS+= -DLOADER_UFS_SUPPORT +.endif +.if ${LOADER_CD9660_SUPPORT} == "yes" +CFLAGS+= -DLOADER_CD9660_SUPPORT +.endif +.if ${LOADER_EXT2FS_SUPPORT} == "yes" +CFLAGS+= -DLOADER_EXT2FS_SUPPORT +.endif +.if ${LOADER_GZIP_SUPPORT} == "yes" +CFLAGS+= -DLOADER_GZIP_SUPPORT +.endif +.if ${LOADER_BZIP2_SUPPORT} == "yes" +CFLAGS+= -DLOADER_BZIP2_SUPPORT +.endif +.if ${LOADER_NET_SUPPORT} == "yes" +CFLAGS+= -DLOADER_NET_SUPPORT +.endif +.if ${LOADER_NFS_SUPPORT} == "yes" +CFLAGS+= -DLOADER_NFS_SUPPORT +.endif +.if ${LOADER_TFTP_SUPPORT} == "yes" +CFLAGS+= -DLOADER_TFTP_SUPPORT +.endif +.if ${LOADER_FDT_SUPPORT} == "yes" +CFLAGS+= -I${.CURDIR}/../../fdt +CFLAGS+= -I${.OBJDIR}/../../fdt +CFLAGS+= -DLOADER_FDT_SUPPORT +LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a +.endif + + +.if ${MK_FORTH} != "no" +# Enable BootForth +BOOT_FORTH= yes +CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/powerpc +LIBFICL= ${.OBJDIR}/../../ficl/libficl.a +.endif + +# Avoid the open-close-dance for every file access as some firmwares perform +# an auto-negotiation on every open of the network interface and thus causes +# netbooting to take horribly long. +CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64 + +# Always add MI sources +.PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern +.include "${.CURDIR}/../../common/Makefile.inc" +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. +CFLAGS+= -I. + +CLEANFILES+= vers.c loader.help + +CFLAGS+= -Wall -ffreestanding -msoft-float -DAIM +# load address. set in linker script +RELOC?= 0x0 +CFLAGS+= -DRELOC=${RELOC} + +LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc + +# 64-bit bridge extensions +CFLAGS+= -Wa,-mppc64bridge + +# Pull in common loader code +#.PATH: ${.CURDIR}/../../ofw/common +#.include "${.CURDIR}/../../ofw/common/Makefile.inc" + +# where to get libstand from +LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a +CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ + +DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} + +SC_DFLT_FONT=cp437 + +font.h: + uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h + +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version + sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} + +loader.help: help.common help.kboot ${.CURDIR}/../../fdt/help.fdt + cat ${.ALLSRC} | \ + awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} + +.PATH: ${.CURDIR}/../../forth +FILES= loader.help loader.4th support.4th loader.conf +FILES+= screen.4th frames.4th +FILES+= beastie.4th brand.4th check-password.4th color.4th delay.4th +FILES+= menu.4th menu-commands.4th menusets.4th shortcuts.4th version.4th +FILESDIR_loader.conf= /boot/defaults + +.if !exists(${DESTDIR}/boot/loader.rc) +FILES+= loader.rc +.endif + +.if !exists(${DESTDIR}/boot/menu.rc) +FILES+= menu.rc +.endif + +.include Added: user/nwhitehorn/kboot/powerpc/kboot/conf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/conf.c Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,127 @@ +/*- + * Copyright (C) 1999 Michael Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include "bootstrap.h" + +#if defined(LOADER_NET_SUPPORT) +#include "dev_net.h" +#endif + +extern struct devsw kbootdisk; +extern struct devsw kbootcdrom; + +/* + * We could use linker sets for some or all of these, but + * then we would have to control what ended up linked into + * the bootstrap. So it's easier to conditionalise things + * here. + * + * XXX rename these arrays to be consistent and less namespace-hostile + */ + +/* Exported for libstand */ +struct devsw *devsw[] = { +#if 0 /* XXX */ +#if defined(LOADER_CD9660_SUPPORT) + &kbootcdrom, +#endif +#if defined(LOADER_DISK_SUPPORT) + &kbootdisk, +#endif +#endif +#if defined(LOADER_NET_SUPPORT) + &netdev, +#endif + NULL +}; + +struct fs_ops *file_system[] = { +#if defined(LOADER_UFS_SUPPORT) + &ufs_fsops, +#endif +#if defined(LOADER_CD9660_SUPPORT) + &cd9660_fsops, +#endif +#if defined(LOADER_EXT2FS_SUPPORT) + &ext2fs_fsops, +#endif +#if defined(LOADER_NFS_SUPPORT) + &nfs_fsops, +#endif +#if defined(LOADER_TFTP_SUPPORT) + &tftp_fsops, +#endif +#if defined(LOADER_GZIP_SUPPORT) + &gzipfs_fsops, +#endif +#if defined(LOADER_BZIP2_SUPPORT) + &bzipfs_fsops, +#endif + NULL +}; + +extern struct netif_driver kbootnet; + +struct netif_driver *netif_drivers[] = { +#if 0 /* XXX */ +#if defined(LOADER_NET_SUPPORT) + &kbootnet, +#endif +#endif + NULL, +}; + +/* Exported for PowerPC only */ +/* + * Sort formats so that those that can detect based on arguments + * rather than reading the file go first. + */ + +extern struct file_format ppc_elf64; + +struct file_format *file_formats[] = { + &ppc_elf64, + NULL +}; + +/* + * Consoles + */ +extern struct console hostconsole; + +struct console *consoles[] = { + &hostconsole, + NULL +}; + +/* + * reloc - our load address + */ +vm_offset_t reloc = RELOC; Added: user/nwhitehorn/kboot/powerpc/kboot/help.kboot ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/help.kboot Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1 @@ +$FreeBSD: user/nwhitehorn/kboot/powerpc/kboot/help.kboot 217044 2011-01-06 04:12:29Z nwhitehorn $ Added: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,31 @@ +#include + +ENTRY(host_read) + li %r0, 3 # SYS_read + sc + blr + +ENTRY(host_write) + li %r0, 4 # SYS_write + sc + blr + +ENTRY(host_open) + li %r0, 5 # SYS_open + sc + blr + +ENTRY(host_close) + li %r0, 6 # SYS_close + sc + blr + +ENTRY(host_getmem) /* addr, size */ + li %r5, 3 # PROT_READ | PROT_WRITE + li %r6, 0x1000 # MAP_ANON + li %r7, -1 + li %r8, 0 + li %r0, 477 # SYS_mmap + sc + blr + Added: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,39 @@ +/*- + * Copyright (C) 2010 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _HOST_SYSCALL_H +#define _HOST_SYSCALL_H + +#include + +ssize_t host_read(int fd, void *buf, size_t nbyte); +ssize_t host_write(int fd, const void *buf, size_t nbyte); +int host_open(char *path, int flags, int mode); +int host_close(int fd); +void *host_getmem(void *addr, size_t len); + +#endif Added: user/nwhitehorn/kboot/powerpc/kboot/hostcons.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,88 @@ +/*- + * Copyright (C) 2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include "bootstrap.h" +#include "host_syscall.h" + +static void hostcons_probe(struct console *cp); +static int hostcons_init(int arg); +static void hostcons_putchar(int c); +static int hostcons_getchar(); +static int hostcons_poll(); + +struct console hostconsole = { + "host", + "Host Console", + 0, + hostcons_probe, + hostcons_init, + hostcons_putchar, + hostcons_getchar, + hostcons_poll, +}; + +static void +hostcons_probe(struct console *cp) +{ + + cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; +} + +static int +hostcons_init(int arg) +{ + + /* XXX: set nonblocking */ + + return (0); +} + +static void +hostcons_putchar(int c) +{ + uint8_t ch = c; + + host_write(1, &ch, 1); +} + +static int +hostcons_getchar() +{ + uint8_t ch; + + host_read(1, &ch, 1); + return (ch); +} + +static int +hostcons_poll() +{ + return (0); +} + Added: user/nwhitehorn/kboot/powerpc/kboot/ldscript.powerpc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/ldscript.powerpc Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,111 @@ +/* $FreeBSD: user/nwhitehorn/kboot/powerpc/kboot/ldscript.powerpc 272888 2014-10-10 06:24:09Z bapt $ */ + +OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", + "elf32-powerpc-freebsd") +OUTPUT_ARCH(powerpc:common) +ENTRY(_start) +SEARCH_DIR(/usr/lib); +PROVIDE (__stack = 0); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x100000; + .text : + { + *(.text) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =0 + _etext = .; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rela.text : + { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rela.data : + { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rela.rodata : + { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rela.got : { *(.rela.got) } + .rela.got1 : { *(.rela.got1) } + .rela.got2 : { *(.rela.got2) } + .rela.ctors : { *(.rela.ctors) } + .rela.dtors : { *(.rela.dtors) } + .rela.init : { *(.rela.init) } + .rela.fini : { *(.rela.fini) } + .rela.bss : { *(.rela.bss) } + .rela.plt : { *(.rela.plt) } + .rela.sbss : { *(.rela.sbss) } + .rela.sbss2 : { *(.rela.sbss2) } + .text : + { + *(.text) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =0 + _etext = .; + PROVIDE (etext = .); + .init : { *(.init) } =0 + .fini : { *(.fini) } =0 + .rodata : { *(.rodata) *(.gnu.linkonce.r*) } + .rodata1 : { *(.rodata1) } + .sbss2 : { *(.sbss2) } + /* Adjust the address for the data segment to the next page up. */ + . = ((. + 0x1000) & ~(0x1000 - 1)); + .data : + { + *(.data) + *(.gnu.linkonce.d*) + CONSTRUCTORS + } + .data1 : { *(.data1) } + .got1 : { *(.got1) } + .dynamic : { *(.dynamic) } + /* Put .ctors and .dtors next to the .got2 section, so that the pointers + get relocated with -mrelocatable. Also put in the .fixup pointers. + The current compiler no longer needs this, but keep it around for 2.7.2 */ + PROVIDE (_GOT2_START_ = .); + .got2 : { *(.got2) } + PROVIDE (__CTOR_LIST__ = .); + .ctors : { *(.ctors) } + PROVIDE (__CTOR_END__ = .); + PROVIDE (__DTOR_LIST__ = .); + .dtors : { *(.dtors) } + PROVIDE (__DTOR_END__ = .); + PROVIDE (_FIXUP_START_ = .); + .fixup : { *(.fixup) } + PROVIDE (_FIXUP_END_ = .); + PROVIDE (_GOT2_END_ = .); + PROVIDE (_GOT_START_ = .); + .got : { *(.got) } + .got.plt : { *(.got.plt) } + PROVIDE (_GOT_END_ = .); + _edata = .; + PROVIDE (edata = .); + .sbss : + { + PROVIDE (__sbss_start = .); + *(.sbss) + *(.scommon) + *(.dynsbss) + PROVIDE (__sbss_end = .); + } + .plt : { *(.plt) } + .bss : + { + PROVIDE (__bss_start = .); + *(.dynbss) + *(.bss) + *(COMMON) + } + . = ALIGN(4096); + _end = . ; + PROVIDE (end = .); +} + Added: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,186 @@ +/*- + * Copyright (C) 2010-2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#define _KERNEL +#include +#include "bootstrap.h" +#include "host_syscall.h" + +struct arch_switch archsw; +extern void *_end; + +extern char bootprog_name[]; +extern char bootprog_rev[]; +extern char bootprog_date[]; +extern char bootprog_maker[]; + +int kboot_getdev(void **vdev, const char *devspec, const char **path); +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(const int fd, vm_offset_t dest, const size_t len); +int kboot_autoload(void); +int kboot_setcurrdev(struct env_var *ev, int flags, const void *value); + +int +kboot_getdev(void **vdev, const char *devspec, const char **path) +{ + printf("Devspec: %s\n", devspec); + return (0); +} + +int +main(int argc, const char **argv) +{ + void *heapbase; + + /* + * Set the heap to one page after the end of the loader. + */ + heapbase = host_getmem(0, 0x100000); + setheap(heapbase, heapbase + 0x100000); + + /* + * Set up console. + */ + cons_probe(); + + printf("Boot device: %s\n", argv[1]); + + archsw.arch_getdev = kboot_getdev; + archsw.arch_copyin = kboot_copyin; + archsw.arch_copyout = kboot_copyout; + archsw.arch_readin = kboot_readin; + archsw.arch_autoload = kboot_autoload; + + printf("\n"); + printf("%s, Revision %s\n", bootprog_name, bootprog_rev); + printf("(%s, %s)\n", bootprog_maker, bootprog_date); + + setenv("currdev", argv[1], 1); + setenv("loaddev", argv[1], 1); + setenv("LINES", "24", 1); + + interact(NULL); /* doesn't return */ + + return (0); +} + +void +exit(int code) +{ + /* XXX: host_exit */ +} + +void +delay(int usecs) +{ + /* XXX */ +} + +int +getsecs() +{ + /* XXX */ + return (0); +} + +time_t +time(time_t *tloc) +{ + time_t rv; + + rv = getsecs(); + if (tloc != NULL) + *tloc = rv; + + return (rv); +} + +ssize_t +kboot_copyin(const void *src, vm_offset_t dest, const size_t len) +{ + bcopy(src, (void *)dest, len); + return (len); +} + +ssize_t +kboot_copyout(vm_offset_t src, void *dest, const size_t len) +{ + bcopy((void *)src, dest, len); + return (len); +} + +ssize_t +kboot_readin(const int fd, vm_offset_t dest, const size_t len) +{ + void *buf; + size_t resid, chunk, get; + ssize_t got; + vm_offset_t p; + + p = dest; + + chunk = min(PAGE_SIZE, len); + buf = malloc(chunk); + if (buf == NULL) { + printf("kboot_readin: buf malloc failed\n"); + return(0); + } + + for (resid = len; resid > 0; resid -= got, p += got) { + get = min(chunk, resid); + got = read(fd, buf, get); + if (got <= 0) { + if (got < 0) + printf("kboot_readin: read failed\n"); + break; + } + + bcopy(buf, (void *)p, got); + } + + free(buf); + return (len - resid); +} + +int +kboot_autoload(void) +{ + + return (0); +} + +void +_start(int argc, const char **argv, char **env) +{ + main(argc, argv); +} + Added: user/nwhitehorn/kboot/powerpc/kboot/metadata.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/metadata.c Sun Dec 28 16:56:52 2014 (r276331) @@ -0,0 +1,333 @@ +/*- + * Copyright (c) 1998 Michael Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: FreeBSD: src/sys/boot/sparc64/loader/metadata.c,v 1.6 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include + +#include "bootstrap.h" + +int +md_getboothowto(char *kargs) +{ + char *cp; + int howto; + int active; + int i; + + /* Parse kargs */ + howto = 0; + if (kargs != NULL) { + cp = kargs; + active = 0; + while (*cp != 0) { + if (!active && (*cp == '-')) { + active = 1; + } else if (active) + switch (*cp) { + case 'a': + howto |= RB_ASKNAME; + break; + case 'C': + howto |= RB_CDROM; + break; + case 'd': + howto |= RB_KDB; + break; + case 'D': + howto |= RB_MULTIPLE; + break; + case 'm': + howto |= RB_MUTE; + break; + case 'g': + howto |= RB_GDB; + break; + case 'h': + howto |= RB_SERIAL; + break; + case 'p': + howto |= RB_PAUSE; + break; + case 'r': + howto |= RB_DFLTROOT; + break; + case 's': + howto |= RB_SINGLE; + break; + case 'v': + howto |= RB_VERBOSE; + break; + default: + active = 0; + break; + } + cp++; + } + } + /* get equivalents from the environment */ + for (i = 0; howto_names[i].ev != NULL; i++) + if (getenv(howto_names[i].ev) != NULL) + howto |= howto_names[i].mask; + if (!strcmp(getenv("console"), "comconsole")) + howto |= RB_SERIAL; + if (!strcmp(getenv("console"), "nullconsole")) + howto |= RB_MUTE; + return(howto); +} + +/* + * Copy the environment into the load area starting at (addr). + * Each variable is formatted as =, with a single nul + * separating each variable, and a double nul terminating the environment. + */ +vm_offset_t +md_copyenv(vm_offset_t addr) +{ + struct env_var *ep; + + /* traverse the environment */ + for (ep = environ; ep != NULL; ep = ep->ev_next) { + archsw.arch_copyin(ep->ev_name, addr, strlen(ep->ev_name)); + addr += strlen(ep->ev_name); + archsw.arch_copyin("=", addr, 1); + addr++; + if (ep->ev_value != NULL) { + archsw.arch_copyin(ep->ev_value, addr, strlen(ep->ev_value)); + addr += strlen(ep->ev_value); + } + archsw.arch_copyin("", addr, 1); + addr++; + } + archsw.arch_copyin("", addr, 1); + addr++; + return(addr); +} + +/* + * Copy module-related data into the load area, where it can be + * used as a directory for loaded modules. + * + * Module data is presented in a self-describing format. Each datum + * is preceded by a 32-bit identifier and a 32-bit size field. + * + * Currently, the following data are saved: + * + * MOD_NAME (variable) module name (string) + * MOD_TYPE (variable) module type (string) + * MOD_ARGS (variable) module parameters (string) + * MOD_ADDR sizeof(vm_offset_t) module load address + * MOD_SIZE sizeof(size_t) module size + * MOD_METADATA (variable) type-specific metadata + */ + +static int align; + +#define COPY32(v, a, c) { \ + u_int32_t x = (v); \ + if (c) \ + archsw.arch_copyin(&x, a, sizeof(x)); \ + a += sizeof(x); \ +} + +#define MOD_STR(t, a, s, c) { \ + COPY32(t, a, c); \ + COPY32(strlen(s) + 1, a, c) \ + if (c) \ + archsw.arch_copyin(s, a, strlen(s) + 1);\ + a += roundup(strlen(s) + 1, align); \ +} + +#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) +#define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) +#define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) + +#define MOD_VAR(t, a, s, c) { \ + COPY32(t, a, c); \ + COPY32(sizeof(s), a, c); \ + if (c) \ + archsw.arch_copyin(&s, a, sizeof(s)); \ + a += roundup(sizeof(s), align); \ +} + +#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) +#define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) + +#define MOD_METADATA(a, mm, c) { \ + COPY32(MODINFO_METADATA | mm->md_type, a, c);\ + COPY32(mm->md_size, a, c); \ + if (c) \ + archsw.arch_copyin(mm->md_data, a, mm->md_size);\ + a += roundup(mm->md_size, align); \ +} + +#define MOD_END(a, c) { \ + COPY32(MODINFO_END, a, c); \ + COPY32(0, a, c); \ +} + +vm_offset_t +md_copymodules(vm_offset_t addr, int kern64) +{ + struct preloaded_file *fp; + struct file_metadata *md; + uint64_t scratch64; + int c; + + c = addr != 0; + /* start with the first module on the list, should be the kernel */ + for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { + + MOD_NAME(addr, fp->f_name, c); /* this field must come first */ + MOD_TYPE(addr, fp->f_type, c); + if (fp->f_args) + MOD_ARGS(addr, fp->f_args, c); + if (kern64) { + scratch64 = fp->f_addr; + MOD_ADDR(addr, scratch64, c); + scratch64 = fp->f_size; + MOD_SIZE(addr, scratch64, c); + } else { + MOD_ADDR(addr, fp->f_addr, c); + MOD_SIZE(addr, fp->f_size, c); + } + for (md = fp->f_metadata; md != NULL; md = md->md_next) { + if (!(md->md_type & MODINFOMD_NOCOPY)) { + MOD_METADATA(addr, md, c); + } + } + } + MOD_END(addr, c); + return(addr); +} + +/* + * Load the information expected by a powerpc kernel. + * + * - The 'boothowto' argument is constructed + * - The 'bootdev' argument is constructed + * - The kernel environment is copied into kernel space. + * - Module metadata are formatted and placed in kernel space. + */ +int +md_load_dual(char *args, vm_offset_t *modulep, int kern64) +{ + struct preloaded_file *kfp; + struct preloaded_file *xp; + struct file_metadata *md; + vm_offset_t kernend; + vm_offset_t addr; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sun Dec 28 17:16:42 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A1BBB94C; Sun, 28 Dec 2014 17:16:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8DE9B66125; Sun, 28 Dec 2014 17:16:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBSHGgCr065418; Sun, 28 Dec 2014 17:16:42 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBSHGgaJ065417; Sun, 28 Dec 2014 17:16:42 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412281716.sBSHGgaJ065417@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sun, 28 Dec 2014 17:16:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276332 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2014 17:16:42 -0000 Author: nwhitehorn Date: Sun Dec 28 17:16:41 2014 New Revision: 276332 URL: https://svnweb.freebsd.org/changeset/base/276332 Log: Make getdev do something. This gets me to a loader prompt without crashing. No disk IO yet. Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Sun Dec 28 16:56:52 2014 (r276331) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Sun Dec 28 17:16:41 2014 (r276332) @@ -52,8 +52,32 @@ int kboot_setcurrdev(struct env_var *ev, int kboot_getdev(void **vdev, const char *devspec, const char **path) { - printf("Devspec: %s\n", devspec); - return (0); + int i; + const char *devpath, *filepath; + struct devsw *dv; + + if (devspec[0] == '/') { + devpath = getenv("currdev"); + filepath = devspec; + } else { + devpath = devspec; + if (strchr(devspec, ':') == NULL) + filepath = NULL; + else + filepath = strchr(devspec, ':') + 1; + } + for (i = 0; (dv = devsw[i]) != NULL; i++) { + if (strncmp(dv->dv_name, devpath, strlen(dv->dv_name)) == 0) + goto found; + } + return (ENOENT); + +found: + if (path != NULL) + *path = filepath; + else if (path != NULL) + *path = strchr(devspec, ':') + 1; + *vdev = strdup(devpath); } int From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 02:13:09 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 22D23637; Mon, 29 Dec 2014 02:13:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 03ED52437; Mon, 29 Dec 2014 02:13:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBT2D8Hg024032; Mon, 29 Dec 2014 02:13:08 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBT2D7tA024021; Mon, 29 Dec 2014 02:13:07 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412290213.sBT2D7tA024021@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Mon, 29 Dec 2014 02:13:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276355 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2014 02:13:09 -0000 Author: nwhitehorn Date: Mon Dec 29 02:13:06 2014 New Revision: 276355 URL: https://svnweb.freebsd.org/changeset/base/276355 Log: Add block device support. This can't autoload the kernel for some reason, but can manually. Not sure why. Added: user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c (contents, props changed) Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile user/nwhitehorn/kboot/powerpc/kboot/conf.c user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/hostcons.c user/nwhitehorn/kboot/powerpc/kboot/main.c Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/Makefile Mon Dec 29 00:35:44 2014 (r276354) +++ user/nwhitehorn/kboot/powerpc/kboot/Makefile Mon Dec 29 02:13:06 2014 (r276355) @@ -10,7 +10,7 @@ INSTALLFLAGS= -b # Architecture-specific loader code SRCS= conf.c metadata.c vers.c main.c ppc64_elf_freebsd.c -SRCS+= host_syscall.S hostcons.c +SRCS+= host_syscall.S hostcons.c hostdisk.c SRCS+= ucmpdi2.c LOADER_DISK_SUPPORT?= yes Modified: user/nwhitehorn/kboot/powerpc/kboot/conf.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/conf.c Mon Dec 29 00:35:44 2014 (r276354) +++ user/nwhitehorn/kboot/powerpc/kboot/conf.c Mon Dec 29 02:13:06 2014 (r276355) @@ -34,8 +34,7 @@ __FBSDID("$FreeBSD$"); #include "dev_net.h" #endif -extern struct devsw kbootdisk; -extern struct devsw kbootcdrom; +extern struct devsw hostdisk; /* * We could use linker sets for some or all of these, but @@ -48,13 +47,8 @@ extern struct devsw kbootcdrom; /* Exported for libstand */ struct devsw *devsw[] = { -#if 0 /* XXX */ -#if defined(LOADER_CD9660_SUPPORT) - &kbootcdrom, -#endif -#if defined(LOADER_DISK_SUPPORT) - &kbootdisk, -#endif +#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT) + &hostdisk, #endif #if defined(LOADER_NET_SUPPORT) &netdev, Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 00:35:44 2014 (r276354) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 02:13:06 2014 (r276355) @@ -10,6 +10,11 @@ ENTRY(host_write) sc blr +ENTRY(host_seek) + li %r0, 478 # SYS_lseek + sc + blr + ENTRY(host_open) li %r0, 5 # SYS_open sc Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 00:35:44 2014 (r276354) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 02:13:06 2014 (r276355) @@ -32,6 +32,7 @@ ssize_t host_read(int fd, void *buf, size_t nbyte); ssize_t host_write(int fd, const void *buf, size_t nbyte); +ssize_t host_seek(int fd, uint64_t offset, int whence); int host_open(char *path, int flags, int mode); int host_close(int fd); void *host_getmem(void *addr, size_t len); Modified: user/nwhitehorn/kboot/powerpc/kboot/hostcons.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Mon Dec 29 00:35:44 2014 (r276354) +++ user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Mon Dec 29 02:13:06 2014 (r276355) @@ -76,7 +76,7 @@ hostcons_getchar() { uint8_t ch; - host_read(1, &ch, 1); + host_read(0, &ch, 1); return (ch); } Added: user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c Mon Dec 29 02:13:06 2014 (r276355) @@ -0,0 +1,126 @@ +/*- + * Copyright (C) 2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include "bootstrap.h" +#include "host_syscall.h" + +static int hostdisk_init(void); +static int hostdisk_strategy(void *devdata, int flag, daddr_t dblk, + size_t size, char *buf, size_t *rsize); +static int hostdisk_open(struct open_file *f, ...); +static int hostdisk_close(struct open_file *f); +static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data); +static void hostdisk_print(int verbose); + +struct devsw hostdisk = { + "a", + DEVT_DISK, + hostdisk_init, + hostdisk_strategy, + hostdisk_open, + hostdisk_close, + hostdisk_ioctl, + hostdisk_print, +}; + +static int +hostdisk_init(void) +{ + + return (0); +} + +static int +hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, + char *buf, size_t *rsize) +{ + struct devdesc *desc = devdata; + daddr_t pos; + int n; + + pos = dblk * 512; + + if (host_seek(desc->d_unit, pos, 0) < 0) + return (EIO); + n = host_read(desc->d_unit, buf, size); + + if (n < 0) + return (EIO); + + *rsize = n; + return (0); +} + +static int +hostdisk_open(struct open_file *f, ...) +{ + struct devdesc *desc; + char *path; + va_list vl; + + va_start(vl, f); + desc = va_arg(vl, struct devdesc *); + va_end(vl); + + path = malloc(strlen((char *)(desc->d_opendata)) + 6); + strcpy(path, "/dev/"); + strcat(path, (char *)(desc->d_opendata)); + + desc->d_unit = host_open(path, O_RDONLY, 0); + free(path); + + if (desc->d_unit < 0) + return (ENOENT); + + return (0); +} + +static int +hostdisk_close(struct open_file *f) +{ + struct devdesc *desc = f->f_devdata; + + host_close(desc->d_unit); + return (0); +} + +static int +hostdisk_ioctl(struct open_file *f, u_long cmd, void *data) +{ + + return (EINVAL); +} + +static void +hostdisk_print(int verbose) +{ + +} + Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 00:35:44 2014 (r276354) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 02:13:06 2014 (r276355) @@ -55,17 +55,16 @@ kboot_getdev(void **vdev, const char *de int i; const char *devpath, *filepath; struct devsw *dv; + struct devdesc *desc; - if (devspec[0] == '/') { - devpath = getenv("currdev"); - filepath = devspec; - } else { + if (strchr(devspec, ':') != NULL) { devpath = devspec; - if (strchr(devspec, ':') == NULL) - filepath = NULL; - else - filepath = strchr(devspec, ':') + 1; + filepath = strchr(devspec, ':') + 1; + } else { + devpath = getenv("currdev"); + filepath = &devspec[1]; } + for (i = 0; (dv = devsw[i]) != NULL; i++) { if (strncmp(dv->dv_name, devpath, strlen(dv->dv_name)) == 0) goto found; @@ -73,11 +72,20 @@ kboot_getdev(void **vdev, const char *de return (ENOENT); found: - if (path != NULL) + if (path != NULL && filepath != NULL) *path = filepath; else if (path != NULL) *path = strchr(devspec, ':') + 1; - *vdev = strdup(devpath); + + if (vdev != NULL) { + desc = malloc(sizeof(*desc)); + desc->d_dev = dv; + desc->d_unit = 0; + desc->d_opendata = strdup(devpath); + *vdev = desc; + } + + return (0); } int From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 14:14:42 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 026DFEB3; Mon, 29 Dec 2014 14:14:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D777E27F0; Mon, 29 Dec 2014 14:14:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBTEEftT059695; Mon, 29 Dec 2014 14:14:41 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBTEEeRK059691; Mon, 29 Dec 2014 14:14:40 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412291414.sBTEEeRK059691@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Mon, 29 Dec 2014 14:14:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276361 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2014 14:14:42 -0000 Author: nwhitehorn Date: Mon Dec 29 14:14:40 2014 New Revision: 276361 URL: https://svnweb.freebsd.org/changeset/base/276361 Log: Get the kernel loaded into some kexec_segments. The next hazard here is to write the equivalent of the kexec purgatory code to call into the kernel with useful arguments. The particular difficulty is in compiling a working device tree from the host kernel. Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/main.c user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 13:50:59 2014 (r276360) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 14:14:40 2014 (r276361) @@ -25,11 +25,7 @@ ENTRY(host_close) sc blr -ENTRY(host_getmem) /* addr, size */ - li %r5, 3 # PROT_READ | PROT_WRITE - li %r6, 0x1000 # MAP_ANON - li %r7, -1 - li %r8, 0 +ENTRY(host_mmap) li %r0, 477 # SYS_mmap sc blr Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 13:50:59 2014 (r276360) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 14:14:40 2014 (r276361) @@ -35,6 +35,7 @@ ssize_t host_write(int fd, const void *b ssize_t host_seek(int fd, uint64_t offset, int whence); int host_open(char *path, int flags, int mode); int host_close(int fd); -void *host_getmem(void *addr, size_t len); +void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t); +#define host_getmem(size) host_mmap(0, size, 3 /* RW */, 0x1000 /* ANON */, -1, 0); #endif Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 13:50:59 2014 (r276360) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 14:14:40 2014 (r276361) @@ -62,7 +62,7 @@ kboot_getdev(void **vdev, const char *de filepath = strchr(devspec, ':') + 1; } else { devpath = getenv("currdev"); - filepath = &devspec[1]; + filepath = devspec; } for (i = 0; (dv = devsw[i]) != NULL; i++) { @@ -92,12 +92,13 @@ int main(int argc, const char **argv) { void *heapbase; + const size_t heapsize = 15*1024*1024; /* * Set the heap to one page after the end of the loader. */ - heapbase = host_getmem(0, 0x100000); - setheap(heapbase, heapbase + 0x100000); + heapbase = host_getmem(heapsize); + setheap(heapbase, heapbase + heapsize); /* * Set up console. @@ -156,17 +157,76 @@ time(time_t *tloc) return (rv); } +struct kexec_segment { + void *buf; + size_t bufsz; + void *mem; + size_t memsz; +}; + +struct kexec_segment loaded_segments[128]; +int nkexec_segments = 0; + +static ssize_t +get_phys_buffer(vm_offset_t dest, const size_t len, void **buf) +{ + int i = 0; + const size_t segsize = 2*1024*1024; + + for (i = 0; i < nkexec_segments; i++) { + if (dest >= (vm_offset_t)loaded_segments[i].mem && + dest < (vm_offset_t)loaded_segments[i].mem + + loaded_segments[i].memsz) + goto out; + } + + loaded_segments[nkexec_segments].buf = host_getmem(segsize); + loaded_segments[nkexec_segments].bufsz = segsize; + loaded_segments[nkexec_segments].mem = (void *)rounddown2(dest,segsize); + loaded_segments[nkexec_segments].memsz = segsize; + i = nkexec_segments; + nkexec_segments++; + +out: + *buf = loaded_segments[i].buf + (dest - + (vm_offset_t)loaded_segments[i].mem); + return (min(len,loaded_segments[i].bufsz - (dest - + (vm_offset_t)loaded_segments[i].mem))); +} + ssize_t kboot_copyin(const void *src, vm_offset_t dest, const size_t len) { - bcopy(src, (void *)dest, len); + ssize_t segsize, remainder; + void *destbuf; + + remainder = len; + do { + segsize = get_phys_buffer(dest, remainder, &destbuf); + bcopy(src, destbuf, segsize); + remainder -= segsize; + src += segsize; + dest += segsize; + } while (remainder > 0); + return (len); } ssize_t kboot_copyout(vm_offset_t src, void *dest, const size_t len) { - bcopy((void *)src, dest, len); + ssize_t segsize, remainder; + void *srcbuf; + + remainder = len; + do { + segsize = get_phys_buffer(src, remainder, &srcbuf); + bcopy(srcbuf, dest, segsize); + remainder -= segsize; + src += segsize; + dest += segsize; + } while (remainder > 0); + return (len); } @@ -184,7 +244,7 @@ kboot_readin(const int fd, vm_offset_t d buf = malloc(chunk); if (buf == NULL) { printf("kboot_readin: buf malloc failed\n"); - return(0); + return (0); } for (resid = len; resid > 0; resid -= got, p += got) { @@ -196,10 +256,10 @@ kboot_readin(const int fd, vm_offset_t d break; } - bcopy(buf, (void *)p, got); + kboot_copyin(buf, p, got); } - free(buf); + free (buf); return (len - resid); } Modified: user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Mon Dec 29 13:50:59 2014 (r276360) +++ user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Mon Dec 29 14:14:40 2014 (r276361) @@ -52,12 +52,6 @@ ppc64_elf_loadfile(char *filename, u_int if (r != 0) return (r); - /* - * No need to sync the icache for modules: this will - * be done by the kernel after relocation. - */ - if (!strcmp((*result)->f_type, "elf kernel")) - __syncicache((void *) (*result)->f_addr, (*result)->f_size); return (0); } From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 21:43:04 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 23E109F3; Mon, 29 Dec 2014 21:43:04 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0516B177B; Mon, 29 Dec 2014 21:43:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBTLh3af073062; Mon, 29 Dec 2014 21:43:03 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBTLh3ZS073056; Mon, 29 Dec 2014 21:43:03 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412292143.sBTLh3ZS073056@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Mon, 29 Dec 2014 21:43:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276380 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2014 21:43:04 -0000 Author: nwhitehorn Date: Mon Dec 29 21:43:02 2014 New Revision: 276380 URL: https://svnweb.freebsd.org/changeset/base/276380 Log: Make countdown, and interrupting the countdown, work. Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/hostcons.c user/nwhitehorn/kboot/powerpc/kboot/main.c Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 21:38:00 2014 (r276379) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 21:43:02 2014 (r276380) @@ -30,3 +30,13 @@ ENTRY(host_mmap) sc blr +ENTRY(host_gettimeofday) + li %r0, 116 # SYS_gettimeofday + sc + blr + +ENTRY(host_select) + li %r0, 93 # SYS_select + sc + blr + Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 21:38:00 2014 (r276379) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 21:43:02 2014 (r276380) @@ -37,5 +37,12 @@ int host_open(char *path, int flags, int int host_close(int fd); void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t); #define host_getmem(size) host_mmap(0, size, 3 /* RW */, 0x1000 /* ANON */, -1, 0); +struct host_timeval { + int tv_sec; + int tv_usec; +}; +int host_gettimeofday(struct host_timeval *a, void *b); +int host_select(int nfds, long *readfds, long *writefds, long *exceptfds, + struct host_timeval *timeout); #endif Modified: user/nwhitehorn/kboot/powerpc/kboot/hostcons.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Mon Dec 29 21:38:00 2014 (r276379) +++ user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Mon Dec 29 21:43:02 2014 (r276380) @@ -75,14 +75,22 @@ static int hostcons_getchar() { uint8_t ch; + int rv; - host_read(0, &ch, 1); - return (ch); + rv = host_read(0, &ch, 1); + if (rv == 1) + return (ch); + return (-1); } static int hostcons_poll() { - return (0); + struct host_timeval tv = {0,0}; + long fds = 1 << 0; + int ret; + + ret = host_select(32, &fds, NULL, NULL, &tv); + return (ret > 0); } Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 21:38:00 2014 (r276379) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 21:43:02 2014 (r276380) @@ -135,14 +135,22 @@ exit(int code) void delay(int usecs) { - /* XXX */ + struct host_timeval tvi, tv; + uint64_t ti, t; + host_gettimeofday(&tvi, NULL); + ti = tvi.tv_sec*1000000 + tvi.tv_usec; + do { + host_gettimeofday(&tv, NULL); + t = tv.tv_sec*1000000 + tv.tv_usec; + } while (t < ti + usecs); } int getsecs() { - /* XXX */ - return (0); + struct host_timeval tv; + host_gettimeofday(&tv, NULL); + return (tv.tv_sec); } time_t From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 03:31:44 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3D98FA7C; Tue, 30 Dec 2014 03:31:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 29C0D6478F; Tue, 30 Dec 2014 03:31:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBU3Vie5039568; Tue, 30 Dec 2014 03:31:44 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBU3VhMF039566; Tue, 30 Dec 2014 03:31:43 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201412300331.sBU3VhMF039566@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Tue, 30 Dec 2014 03:31:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276399 - in user/marcel/libvdsk: bhyve bhyveload X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2014 03:31:44 -0000 Author: marcel Date: Tue Dec 30 03:31:42 2014 New Revision: 276399 URL: https://svnweb.freebsd.org/changeset/base/276399 Log: Sync with ^/head. Modified: user/marcel/libvdsk/bhyve/Makefile user/marcel/libvdsk/bhyveload/Makefile Directory Properties: user/marcel/libvdsk/bhyve/ (props changed) user/marcel/libvdsk/bhyveload/ (props changed) Modified: user/marcel/libvdsk/bhyve/Makefile ============================================================================== --- user/marcel/libvdsk/bhyve/Makefile Tue Dec 30 03:25:42 2014 (r276398) +++ user/marcel/libvdsk/bhyve/Makefile Tue Dec 30 03:31:42 2014 (r276399) @@ -4,7 +4,7 @@ PROG= bhyve -DEBUG_FLAGS= -g -O0 +DEBUG_FLAGS= -g -O0 MAN= bhyve.8 @@ -43,8 +43,7 @@ SRCS= \ .PATH: /sys/amd64/vmm SRCS+= vmm_instruction_emul.c -DPADD= ${LIBVDSK} ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD} -LDADD= -lvdsk -lvmmapi -lmd -lutil -lpthread +LIBADD= vdsk vmmapi md util pthread WARNS?= 2 Modified: user/marcel/libvdsk/bhyveload/Makefile ============================================================================== --- user/marcel/libvdsk/bhyveload/Makefile Tue Dec 30 03:25:42 2014 (r276398) +++ user/marcel/libvdsk/bhyveload/Makefile Tue Dec 30 03:31:42 2014 (r276399) @@ -4,8 +4,7 @@ PROG= bhyveload SRCS= bhyveload.c MAN= bhyveload.8 -DPADD+= ${LIBVDSK} ${LIBVMMAPI} ${LIBUTIL} -LDADD+= -lvdsk -lvmmapi -lutil +LIBADD= vdsk vmmapi util WARNS?= 3 From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 03:47:45 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 36292E29; Tue, 30 Dec 2014 03:47:45 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 22146649EB; Tue, 30 Dec 2014 03:47:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBU3lj3K045379; Tue, 30 Dec 2014 03:47:45 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBU3licu045377; Tue, 30 Dec 2014 03:47:44 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201412300347.sBU3licu045377@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Tue, 30 Dec 2014 03:47:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276401 - in user/marcel/libvdsk: bhyve bhyveload X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2014 03:47:45 -0000 Author: marcel Date: Tue Dec 30 03:47:43 2014 New Revision: 276401 URL: https://svnweb.freebsd.org/changeset/base/276401 Log: LIBADD does not work outside the source tree. Revert back to DPADD and LDADD. Modified: user/marcel/libvdsk/bhyve/Makefile user/marcel/libvdsk/bhyveload/Makefile Modified: user/marcel/libvdsk/bhyve/Makefile ============================================================================== --- user/marcel/libvdsk/bhyve/Makefile Tue Dec 30 03:35:26 2014 (r276400) +++ user/marcel/libvdsk/bhyve/Makefile Tue Dec 30 03:47:43 2014 (r276401) @@ -43,7 +43,8 @@ SRCS= \ .PATH: /sys/amd64/vmm SRCS+= vmm_instruction_emul.c -LIBADD= vdsk vmmapi md util pthread +DPADD= ${LIBVDSK} ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD} +LDADD= -lvdsk -lvmmapi -lmd -lutil -lpthread WARNS?= 2 Modified: user/marcel/libvdsk/bhyveload/Makefile ============================================================================== --- user/marcel/libvdsk/bhyveload/Makefile Tue Dec 30 03:35:26 2014 (r276400) +++ user/marcel/libvdsk/bhyveload/Makefile Tue Dec 30 03:47:43 2014 (r276401) @@ -4,7 +4,8 @@ PROG= bhyveload SRCS= bhyveload.c MAN= bhyveload.8 -LIBADD= vdsk vmmapi util +DPADD+= ${LIBVDSK} ${LIBVMMAPI} ${LIBUTIL} +LDADD+= -lvdsk -lvmmapi -lutil WARNS?= 3 From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 14:50:05 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8418DD48; Tue, 30 Dec 2014 14:50:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6526B15C9; Tue, 30 Dec 2014 14:50:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBUEo5BO074571; Tue, 30 Dec 2014 14:50:05 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBUEo4rg074564; Tue, 30 Dec 2014 14:50:04 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412301450.sBUEo4rg074564@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 30 Dec 2014 14:50:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276410 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2014 14:50:05 -0000 Author: nwhitehorn Date: Tue Dec 30 14:50:03 2014 New Revision: 276410 URL: https://svnweb.freebsd.org/changeset/base/276410 Log: Port to Linux. Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/hostcons.c user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c user/nwhitehorn/kboot/powerpc/kboot/main.c Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Tue Dec 30 12:47:44 2014 (r276409) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Tue Dec 30 14:50:03 2014 (r276410) @@ -11,13 +11,17 @@ ENTRY(host_write) blr ENTRY(host_seek) - li %r0, 478 # SYS_lseek + li %r0, 19 # SYS_lseek sc blr ENTRY(host_open) li %r0, 5 # SYS_open sc + bso 1f + blr +1: + li %r3, 0 blr ENTRY(host_close) @@ -26,17 +30,17 @@ ENTRY(host_close) blr ENTRY(host_mmap) - li %r0, 477 # SYS_mmap + li %r0, 90 # SYS_mmap sc blr ENTRY(host_gettimeofday) - li %r0, 116 # SYS_gettimeofday + li %r0, 78 # SYS_gettimeofday sc blr ENTRY(host_select) - li %r0, 93 # SYS_select + li %r0, 82 # SYS_select sc blr Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Tue Dec 30 12:47:44 2014 (r276409) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Tue Dec 30 14:50:03 2014 (r276410) @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2010 Nathan Whitehorn + * Copyright (C) 2014 Nathan Whitehorn * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,11 +32,11 @@ ssize_t host_read(int fd, void *buf, size_t nbyte); ssize_t host_write(int fd, const void *buf, size_t nbyte); -ssize_t host_seek(int fd, uint64_t offset, int whence); +ssize_t host_seek(int fd, int offset, int whence); int host_open(char *path, int flags, int mode); int host_close(int fd); -void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t); -#define host_getmem(size) host_mmap(0, size, 3 /* RW */, 0x1000 /* ANON */, -1, 0); +void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, int); +#define host_getmem(size) host_mmap(0, size, 3 /* RW */, 0x22 /* ANON */, -1, 0); struct host_timeval { int tv_sec; int tv_usec; Modified: user/nwhitehorn/kboot/powerpc/kboot/hostcons.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Tue Dec 30 12:47:44 2014 (r276409) +++ user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Tue Dec 30 14:50:03 2014 (r276410) @@ -59,6 +59,7 @@ hostcons_init(int arg) { /* XXX: set nonblocking */ + /* tcsetattr(~(ICANON | ECHO)) */ return (0); } Modified: user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c Tue Dec 30 12:47:44 2014 (r276409) +++ user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c Tue Dec 30 14:50:03 2014 (r276410) @@ -40,7 +40,7 @@ static int hostdisk_ioctl(struct open_fi static void hostdisk_print(int verbose); struct devsw hostdisk = { - "a", + "s", DEVT_DISK, hostdisk_init, hostdisk_strategy, @@ -96,7 +96,7 @@ hostdisk_open(struct open_file *f, ...) desc->d_unit = host_open(path, O_RDONLY, 0); free(path); - if (desc->d_unit < 0) + if (desc->d_unit <= 0) return (ENOENT); return (0); Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Tue Dec 30 12:47:44 2014 (r276409) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Tue Dec 30 14:50:03 2014 (r276410) @@ -93,6 +93,7 @@ main(int argc, const char **argv) { void *heapbase; const size_t heapsize = 15*1024*1024; + const char *bootdev = argv[1]; /* * Set the heap to one page after the end of the loader. @@ -105,7 +106,7 @@ main(int argc, const char **argv) */ cons_probe(); - printf("Boot device: %s\n", argv[1]); + printf("Boot device: %s\n", bootdev); archsw.arch_getdev = kboot_getdev; archsw.arch_copyin = kboot_copyin; @@ -117,8 +118,8 @@ main(int argc, const char **argv) printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); - setenv("currdev", argv[1], 1); - setenv("loaddev", argv[1], 1); + setenv("currdev", bootdev, 1); + setenv("loaddev", bootdev, 1); setenv("LINES", "24", 1); interact(NULL); /* doesn't return */ @@ -281,6 +282,7 @@ kboot_autoload(void) void _start(int argc, const char **argv, char **env) { - main(argc, argv); + register volatile void **sp asm("r1"); + main((int)sp[0], (const char **)&sp[1]); } From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 16:22:21 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A1E52496; Tue, 30 Dec 2014 16:22:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8DDDA275B; Tue, 30 Dec 2014 16:22:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBUGML4K019711; Tue, 30 Dec 2014 16:22:21 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBUGML9I019710; Tue, 30 Dec 2014 16:22:21 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412301622.sBUGML9I019710@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 30 Dec 2014 16:22:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276411 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2014 16:22:21 -0000 Author: nwhitehorn Date: Tue Dec 30 16:22:20 2014 New Revision: 276411 URL: https://svnweb.freebsd.org/changeset/base/276411 Log: Use the right syscall number for select(). Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Tue Dec 30 14:50:03 2014 (r276410) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Tue Dec 30 16:22:20 2014 (r276411) @@ -40,7 +40,7 @@ ENTRY(host_gettimeofday) blr ENTRY(host_select) - li %r0, 82 # SYS_select + li %r0, 142 # SYS_select sc blr From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 17:30:48 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CEF13D78; Tue, 30 Dec 2014 17:30:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA90F16C; Tue, 30 Dec 2014 17:30:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBUHUmeb048774; Tue, 30 Dec 2014 17:30:48 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBUHUmmo048771; Tue, 30 Dec 2014 17:30:48 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412301730.sBUHUmmo048771@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 30 Dec 2014 17:30:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276413 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2014 17:30:49 -0000 Author: nwhitehorn Date: Tue Dec 30 17:30:47 2014 New Revision: 276413 URL: https://svnweb.freebsd.org/changeset/base/276413 Log: Lay out first steps for launch trampoline. Added: user/nwhitehorn/kboot/powerpc/kboot/kerneltramp.S (contents, props changed) Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/Makefile Tue Dec 30 16:55:53 2014 (r276412) +++ user/nwhitehorn/kboot/powerpc/kboot/Makefile Tue Dec 30 17:30:47 2014 (r276413) @@ -10,7 +10,7 @@ INSTALLFLAGS= -b # Architecture-specific loader code SRCS= conf.c metadata.c vers.c main.c ppc64_elf_freebsd.c -SRCS+= host_syscall.S hostcons.c hostdisk.c +SRCS+= host_syscall.S hostcons.c hostdisk.c kerneltramp.S SRCS+= ucmpdi2.c LOADER_DISK_SUPPORT?= yes Added: user/nwhitehorn/kboot/powerpc/kboot/kerneltramp.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/kerneltramp.S Tue Dec 30 17:30:47 2014 (r276413) @@ -0,0 +1,38 @@ +/* + * This is the analog to the kexec "purgatory" code + * + * The goal here is to call the actual kernel entry point with the arguments it + * expects when kexec calls into it with no arguments. The value of the kernel + * entry point and arguments r3-r7 are copied into the trampoline text (which can + * be executed from any address) at bytes 8-32. + * + * TODO: + * - This may or may not need to relocate the kernel before executing it + * - kexec enters at address 0x60 for all APs. We need to catch these and hold + * them. + */ + +#include + + .globl CNAME(kerneltramp),CNAME(szkerneltramp) +CNAME(kerneltramp): + mflr %r9 + bl 1f + .space 24 /* branch address, r3-r7 */ +1: + mflr %r8 + mtlr %r9 + lwz %r3,0(%r8) + ld %r3,0(%r3) /* Resolve function descriptor */ + mtctr %r3 + lwz %r3,4(%r8) + lwz %r4,8(%r8) + lwz %r5,12(%r8) + lwz %r6,16(%r8) + lwz %r7,20(%r8) + bctr +endkerneltramp: + + .data +CNAME(szkerneltramp): + .long endkerneltramp - CNAME(kerneltramp) Modified: user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Tue Dec 30 16:55:53 2014 (r276412) +++ user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Tue Dec 30 17:30:47 2014 (r276413) @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); extern char end[]; extern vm_offset_t reloc; /* From /conf.c */ +extern void *kerneltramp; +extern size_t szkerneltramp; int ppc64_elf_loadfile(char *filename, u_int64_t dest, @@ -62,7 +64,7 @@ ppc64_elf_exec(struct preloaded_file *fp vm_offset_t mdp; Elf_Ehdr *e; int error; - int (*entry)(u_long, u_long, u_long, void *, u_long); + uint32_t *trampoline; if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { return(EFTYPE); @@ -70,17 +72,24 @@ ppc64_elf_exec(struct preloaded_file *fp e = (Elf_Ehdr *)&fmp->md_data; /* Handle function descriptor */ - entry = (void *)(uintptr_t)(*(uint64_t *)e->e_entry); + trampoline = malloc(szkerneltramp); + memcpy(trampoline, &kerneltramp, szkerneltramp); + trampoline[2] = e->e_entry; + trampoline[3] = 0; /* FDT */ + trampoline[4] = 0; /* Phys. mem offset */ + trampoline[5] = 0; /* OF entry point */ if ((error = md_load64(fp->f_args, &mdp)) != 0) return (error); - printf("Kernel entry at %p ...\n", entry); + trampoline[6] = mdp; + trampoline[7] = sizeof(mdp); + printf("Kernel entry at %#x ...\n", e->e_entry); dev_cleanup(); - entry(0 /* FDT */, 0 /* Phys. mem offset */, 0 /* OF entry */, - (void *)mdp, sizeof(mdp)); + archsw.arch_copyin(trampoline, 0 /* XXX */, szkerneltramp); + /* XXX kexec_load, reboot */ panic("exec returned"); } From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 20:10:41 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C6F36B97; Tue, 30 Dec 2014 20:10:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B02301C04; Tue, 30 Dec 2014 20:10:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBUKAfG1030267; Tue, 30 Dec 2014 20:10:41 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBUKAcl6030247; Tue, 30 Dec 2014 20:10:38 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201412302010.sBUKAcl6030247@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Tue, 30 Dec 2014 20:10:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276418 - in user/cperciva/freebsd-update-build/patches: 10.0-RELEASE 10.1-RELEASE 8.4-RELEASE 9.1-RELEASE 9.2-RELEASE 9.3-RELEASE X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2014 20:10:41 -0000 Author: delphij Date: Tue Dec 30 20:10:37 2014 New Revision: 276418 URL: https://svnweb.freebsd.org/changeset/base/276418 Log: Add patchset for previous batch. Added: user/cperciva/freebsd-update-build/patches/10.0-RELEASE/15-EN-14:13.freebsd-update user/cperciva/freebsd-update-build/patches/10.0-RELEASE/15-SA-14:31.ntp user/cperciva/freebsd-update-build/patches/10.1-RELEASE/3-EN-14:13.freebsd-update user/cperciva/freebsd-update-build/patches/10.1-RELEASE/3-SA-14:31.ntp user/cperciva/freebsd-update-build/patches/8.4-RELEASE/21-EN-14:13.freebsd-update user/cperciva/freebsd-update-build/patches/8.4-RELEASE/21-SA-14:31.ntp user/cperciva/freebsd-update-build/patches/9.1-RELEASE/24-EN-14:13.freebsd-update user/cperciva/freebsd-update-build/patches/9.1-RELEASE/24-SA-14:31.ntp user/cperciva/freebsd-update-build/patches/9.2-RELEASE/17-EN-14:13.freebsd-update user/cperciva/freebsd-update-build/patches/9.2-RELEASE/17-SA-14:31.ntp user/cperciva/freebsd-update-build/patches/9.3-RELEASE/7-EN-14:13.freebsd-update user/cperciva/freebsd-update-build/patches/9.3-RELEASE/7-SA-14:31.ntp Added: user/cperciva/freebsd-update-build/patches/10.0-RELEASE/15-EN-14:13.freebsd-update ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/10.0-RELEASE/15-EN-14:13.freebsd-update Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,12 @@ +Index: usr.sbin/freebsd-update/freebsd-update.sh +=================================================================== +--- usr.sbin/freebsd-update/freebsd-update.sh.orig ++++ usr.sbin/freebsd-update/freebsd-update.sh +@@ -1395,6 +1395,7 @@ + # matter, since we add a leading "/" when we use paths later. + cut -f 3- -d '|' $1 | + sed -e 's,/|d|,|d|,' | ++ sed -e 's,/|-|,|-|,' | + sort -u > $1.tmp + + # Figure out which lines to ignore and remove them. Added: user/cperciva/freebsd-update-build/patches/10.0-RELEASE/15-SA-14:31.ntp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/10.0-RELEASE/15-SA-14:31.ntp Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,145 @@ +Index: contrib/ntp/ntpd/ntp_config.c +=================================================================== +--- contrib/ntp/ntpd/ntp_config.c.orig ++++ contrib/ntp/ntpd/ntp_config.c +@@ -1887,7 +1887,7 @@ + + for (i = 0; i < 8; i++) + for (j = 1; j < 100; ++j) { +- rankey[i] = (char) (ntp_random() & 0xff); ++ rankey[i] = (char) (arc4random() & 0xff); + if (rankey[i] != 0) break; + } + rankey[8] = 0; +Index: contrib/ntp/ntpd/ntp_control.c +=================================================================== +--- contrib/ntp/ntpd/ntp_control.c.orig ++++ contrib/ntp/ntpd/ntp_control.c +@@ -24,6 +24,10 @@ + #include + #include + ++#ifndef MIN ++#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) ++#endif ++ + /* + * Structure to hold request procedure information + */ +@@ -893,6 +897,7 @@ + ) + { + int overhead; ++ unsigned int currentlen; + + overhead = 0; + if (!bin) { +@@ -916,12 +921,22 @@ + /* + * Save room for trailing junk + */ +- if (dlen + overhead + datapt > dataend) { ++ while (dlen + overhead + datapt > dataend) { + /* + * Not enough room in this one, flush it out. + */ ++ currentlen = MIN(dlen, dataend - datapt); ++ ++ memcpy(datapt, dp, currentlen); ++ ++ datapt += currentlen; ++ dp += currentlen; ++ dlen -= currentlen; ++ datalinelen += currentlen; ++ + ctl_flushpkt(CTL_MORE); + } ++ + memmove((char *)datapt, dp, (unsigned)dlen); + datapt += dlen; + datalinelen += dlen; +Index: contrib/ntp/ntpd/ntp_crypto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_crypto.c.orig ++++ contrib/ntp/ntpd/ntp_crypto.c +@@ -864,12 +864,24 @@ + * errors. + */ + if (vallen == (u_int) EVP_PKEY_size(host_pkey)) { +- RSA_private_decrypt(vallen, ++ u_int32 *cookiebuf = malloc( ++ RSA_size(host_pkey->pkey.rsa)); ++ if (cookiebuf == NULL) { ++ rval = XEVNT_CKY; ++ break; ++ } ++ if (RSA_private_decrypt(vallen, + (u_char *)ep->pkt, +- (u_char *)&temp32, ++ (u_char *)cookiebuf, + host_pkey->pkey.rsa, +- RSA_PKCS1_OAEP_PADDING); +- cookie = ntohl(temp32); ++ RSA_PKCS1_OAEP_PADDING) != 4) { ++ rval = XEVNT_CKY; ++ free(cookiebuf); ++ break; ++ } else { ++ cookie = ntohl(*cookiebuf); ++ free(cookiebuf); ++ } + } else { + rval = XEVNT_CKY; + break; +@@ -3914,7 +3926,7 @@ + rand_file); + exit (-1); + } +- get_systime(&seed); ++ arc4random_buf(&seed, sizeof(l_fp)); + RAND_seed(&seed, sizeof(l_fp)); + RAND_write_file(rand_file); + OpenSSL_add_all_algorithms(); +Index: contrib/ntp/ntpd/ntp_proto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_proto.c.orig ++++ contrib/ntp/ntpd/ntp_proto.c +@@ -649,6 +649,7 @@ + has_mac)) { + is_authentic = AUTH_ERROR; + sys_badauth++; ++ return; + } else { + is_authentic = AUTH_OK; + } +Index: contrib/ntp/util/ntp-keygen.c +=================================================================== +--- contrib/ntp/util/ntp-keygen.c.orig ++++ contrib/ntp/util/ntp-keygen.c +@@ -642,7 +642,7 @@ + for (i = 1; i <= MD5KEYS; i++) { + for (j = 0; j < 16; j++) { + while (1) { +- temp = ntp_random() & 0xff; ++ temp = arc4random() & 0xff; + if (temp == '#') + continue; + if (temp > 0x20 && temp < 0x7f) +@@ -675,7 +675,7 @@ + FILE *str; + + fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "RSA"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", +@@ -954,7 +954,7 @@ + */ + fprintf(stderr, + "Generating GQ parameters (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "GQ"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "GQ"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", Added: user/cperciva/freebsd-update-build/patches/10.1-RELEASE/3-EN-14:13.freebsd-update ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/10.1-RELEASE/3-EN-14:13.freebsd-update Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,12 @@ +Index: usr.sbin/freebsd-update/freebsd-update.sh +=================================================================== +--- usr.sbin/freebsd-update/freebsd-update.sh.orig ++++ usr.sbin/freebsd-update/freebsd-update.sh +@@ -1395,6 +1395,7 @@ + # matter, since we add a leading "/" when we use paths later. + cut -f 3- -d '|' $1 | + sed -e 's,/|d|,|d|,' | ++ sed -e 's,/|-|,|-|,' | + sort -u > $1.tmp + + # Figure out which lines to ignore and remove them. Added: user/cperciva/freebsd-update-build/patches/10.1-RELEASE/3-SA-14:31.ntp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/10.1-RELEASE/3-SA-14:31.ntp Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,145 @@ +Index: contrib/ntp/ntpd/ntp_config.c +=================================================================== +--- contrib/ntp/ntpd/ntp_config.c.orig ++++ contrib/ntp/ntpd/ntp_config.c +@@ -1887,7 +1887,7 @@ + + for (i = 0; i < 8; i++) + for (j = 1; j < 100; ++j) { +- rankey[i] = (char) (ntp_random() & 0xff); ++ rankey[i] = (char) (arc4random() & 0xff); + if (rankey[i] != 0) break; + } + rankey[8] = 0; +Index: contrib/ntp/ntpd/ntp_control.c +=================================================================== +--- contrib/ntp/ntpd/ntp_control.c.orig ++++ contrib/ntp/ntpd/ntp_control.c +@@ -24,6 +24,10 @@ + #include + #include + ++#ifndef MIN ++#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) ++#endif ++ + /* + * Structure to hold request procedure information + */ +@@ -893,6 +897,7 @@ + ) + { + int overhead; ++ unsigned int currentlen; + + overhead = 0; + if (!bin) { +@@ -916,12 +921,22 @@ + /* + * Save room for trailing junk + */ +- if (dlen + overhead + datapt > dataend) { ++ while (dlen + overhead + datapt > dataend) { + /* + * Not enough room in this one, flush it out. + */ ++ currentlen = MIN(dlen, dataend - datapt); ++ ++ memcpy(datapt, dp, currentlen); ++ ++ datapt += currentlen; ++ dp += currentlen; ++ dlen -= currentlen; ++ datalinelen += currentlen; ++ + ctl_flushpkt(CTL_MORE); + } ++ + memmove((char *)datapt, dp, (unsigned)dlen); + datapt += dlen; + datalinelen += dlen; +Index: contrib/ntp/ntpd/ntp_crypto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_crypto.c.orig ++++ contrib/ntp/ntpd/ntp_crypto.c +@@ -864,12 +864,24 @@ + * errors. + */ + if (vallen == (u_int) EVP_PKEY_size(host_pkey)) { +- RSA_private_decrypt(vallen, ++ u_int32 *cookiebuf = malloc( ++ RSA_size(host_pkey->pkey.rsa)); ++ if (cookiebuf == NULL) { ++ rval = XEVNT_CKY; ++ break; ++ } ++ if (RSA_private_decrypt(vallen, + (u_char *)ep->pkt, +- (u_char *)&temp32, ++ (u_char *)cookiebuf, + host_pkey->pkey.rsa, +- RSA_PKCS1_OAEP_PADDING); +- cookie = ntohl(temp32); ++ RSA_PKCS1_OAEP_PADDING) != 4) { ++ rval = XEVNT_CKY; ++ free(cookiebuf); ++ break; ++ } else { ++ cookie = ntohl(*cookiebuf); ++ free(cookiebuf); ++ } + } else { + rval = XEVNT_CKY; + break; +@@ -3914,7 +3926,7 @@ + rand_file); + exit (-1); + } +- get_systime(&seed); ++ arc4random_buf(&seed, sizeof(l_fp)); + RAND_seed(&seed, sizeof(l_fp)); + RAND_write_file(rand_file); + OpenSSL_add_all_algorithms(); +Index: contrib/ntp/ntpd/ntp_proto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_proto.c.orig ++++ contrib/ntp/ntpd/ntp_proto.c +@@ -649,6 +649,7 @@ + has_mac)) { + is_authentic = AUTH_ERROR; + sys_badauth++; ++ return; + } else { + is_authentic = AUTH_OK; + } +Index: contrib/ntp/util/ntp-keygen.c +=================================================================== +--- contrib/ntp/util/ntp-keygen.c.orig ++++ contrib/ntp/util/ntp-keygen.c +@@ -642,7 +642,7 @@ + for (i = 1; i <= MD5KEYS; i++) { + for (j = 0; j < 16; j++) { + while (1) { +- temp = ntp_random() & 0xff; ++ temp = arc4random() & 0xff; + if (temp == '#') + continue; + if (temp > 0x20 && temp < 0x7f) +@@ -675,7 +675,7 @@ + FILE *str; + + fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "RSA"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", +@@ -954,7 +954,7 @@ + */ + fprintf(stderr, + "Generating GQ parameters (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "GQ"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "GQ"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", Added: user/cperciva/freebsd-update-build/patches/8.4-RELEASE/21-EN-14:13.freebsd-update ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/8.4-RELEASE/21-EN-14:13.freebsd-update Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,12 @@ +Index: usr.sbin/freebsd-update/freebsd-update.sh +=================================================================== +--- usr.sbin/freebsd-update/freebsd-update.sh.orig ++++ usr.sbin/freebsd-update/freebsd-update.sh +@@ -1395,6 +1395,7 @@ + # matter, since we add a leading "/" when we use paths later. + cut -f 3- -d '|' $1 | + sed -e 's,/|d|,|d|,' | ++ sed -e 's,/|-|,|-|,' | + sort -u > $1.tmp + + # Figure out which lines to ignore and remove them. Added: user/cperciva/freebsd-update-build/patches/8.4-RELEASE/21-SA-14:31.ntp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/8.4-RELEASE/21-SA-14:31.ntp Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,145 @@ +Index: contrib/ntp/ntpd/ntp_config.c +=================================================================== +--- contrib/ntp/ntpd/ntp_config.c.orig ++++ contrib/ntp/ntpd/ntp_config.c +@@ -1887,7 +1887,7 @@ + + for (i = 0; i < 8; i++) + for (j = 1; j < 100; ++j) { +- rankey[i] = (char) (ntp_random() & 0xff); ++ rankey[i] = (char) (arc4random() & 0xff); + if (rankey[i] != 0) break; + } + rankey[8] = 0; +Index: contrib/ntp/ntpd/ntp_control.c +=================================================================== +--- contrib/ntp/ntpd/ntp_control.c.orig ++++ contrib/ntp/ntpd/ntp_control.c +@@ -24,6 +24,10 @@ + #include + #include + ++#ifndef MIN ++#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) ++#endif ++ + /* + * Structure to hold request procedure information + */ +@@ -893,6 +897,7 @@ + ) + { + int overhead; ++ unsigned int currentlen; + + overhead = 0; + if (!bin) { +@@ -916,12 +921,22 @@ + /* + * Save room for trailing junk + */ +- if (dlen + overhead + datapt > dataend) { ++ while (dlen + overhead + datapt > dataend) { + /* + * Not enough room in this one, flush it out. + */ ++ currentlen = MIN(dlen, dataend - datapt); ++ ++ memcpy(datapt, dp, currentlen); ++ ++ datapt += currentlen; ++ dp += currentlen; ++ dlen -= currentlen; ++ datalinelen += currentlen; ++ + ctl_flushpkt(CTL_MORE); + } ++ + memmove((char *)datapt, dp, (unsigned)dlen); + datapt += dlen; + datalinelen += dlen; +Index: contrib/ntp/ntpd/ntp_crypto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_crypto.c.orig ++++ contrib/ntp/ntpd/ntp_crypto.c +@@ -864,12 +864,24 @@ + * errors. + */ + if (vallen == (u_int) EVP_PKEY_size(host_pkey)) { +- RSA_private_decrypt(vallen, ++ u_int32 *cookiebuf = malloc( ++ RSA_size(host_pkey->pkey.rsa)); ++ if (cookiebuf == NULL) { ++ rval = XEVNT_CKY; ++ break; ++ } ++ if (RSA_private_decrypt(vallen, + (u_char *)ep->pkt, +- (u_char *)&temp32, ++ (u_char *)cookiebuf, + host_pkey->pkey.rsa, +- RSA_PKCS1_OAEP_PADDING); +- cookie = ntohl(temp32); ++ RSA_PKCS1_OAEP_PADDING) != 4) { ++ rval = XEVNT_CKY; ++ free(cookiebuf); ++ break; ++ } else { ++ cookie = ntohl(*cookiebuf); ++ free(cookiebuf); ++ } + } else { + rval = XEVNT_CKY; + break; +@@ -3914,7 +3926,7 @@ + rand_file); + exit (-1); + } +- get_systime(&seed); ++ arc4random_buf(&seed, sizeof(l_fp)); + RAND_seed(&seed, sizeof(l_fp)); + RAND_write_file(rand_file); + OpenSSL_add_all_algorithms(); +Index: contrib/ntp/ntpd/ntp_proto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_proto.c.orig ++++ contrib/ntp/ntpd/ntp_proto.c +@@ -649,6 +649,7 @@ + has_mac)) { + is_authentic = AUTH_ERROR; + sys_badauth++; ++ return; + } else { + is_authentic = AUTH_OK; + } +Index: contrib/ntp/util/ntp-keygen.c +=================================================================== +--- contrib/ntp/util/ntp-keygen.c.orig ++++ contrib/ntp/util/ntp-keygen.c +@@ -642,7 +642,7 @@ + for (i = 1; i <= MD5KEYS; i++) { + for (j = 0; j < 16; j++) { + while (1) { +- temp = ntp_random() & 0xff; ++ temp = arc4random() & 0xff; + if (temp == '#') + continue; + if (temp > 0x20 && temp < 0x7f) +@@ -675,7 +675,7 @@ + FILE *str; + + fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "RSA"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", +@@ -954,7 +954,7 @@ + */ + fprintf(stderr, + "Generating GQ parameters (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "GQ"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "GQ"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", Added: user/cperciva/freebsd-update-build/patches/9.1-RELEASE/24-EN-14:13.freebsd-update ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/9.1-RELEASE/24-EN-14:13.freebsd-update Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,12 @@ +Index: usr.sbin/freebsd-update/freebsd-update.sh +=================================================================== +--- usr.sbin/freebsd-update/freebsd-update.sh.orig ++++ usr.sbin/freebsd-update/freebsd-update.sh +@@ -1395,6 +1395,7 @@ + # matter, since we add a leading "/" when we use paths later. + cut -f 3- -d '|' $1 | + sed -e 's,/|d|,|d|,' | ++ sed -e 's,/|-|,|-|,' | + sort -u > $1.tmp + + # Figure out which lines to ignore and remove them. Added: user/cperciva/freebsd-update-build/patches/9.1-RELEASE/24-SA-14:31.ntp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/9.1-RELEASE/24-SA-14:31.ntp Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,145 @@ +Index: contrib/ntp/ntpd/ntp_config.c +=================================================================== +--- contrib/ntp/ntpd/ntp_config.c.orig ++++ contrib/ntp/ntpd/ntp_config.c +@@ -1887,7 +1887,7 @@ + + for (i = 0; i < 8; i++) + for (j = 1; j < 100; ++j) { +- rankey[i] = (char) (ntp_random() & 0xff); ++ rankey[i] = (char) (arc4random() & 0xff); + if (rankey[i] != 0) break; + } + rankey[8] = 0; +Index: contrib/ntp/ntpd/ntp_control.c +=================================================================== +--- contrib/ntp/ntpd/ntp_control.c.orig ++++ contrib/ntp/ntpd/ntp_control.c +@@ -24,6 +24,10 @@ + #include + #include + ++#ifndef MIN ++#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) ++#endif ++ + /* + * Structure to hold request procedure information + */ +@@ -893,6 +897,7 @@ + ) + { + int overhead; ++ unsigned int currentlen; + + overhead = 0; + if (!bin) { +@@ -916,12 +921,22 @@ + /* + * Save room for trailing junk + */ +- if (dlen + overhead + datapt > dataend) { ++ while (dlen + overhead + datapt > dataend) { + /* + * Not enough room in this one, flush it out. + */ ++ currentlen = MIN(dlen, dataend - datapt); ++ ++ memcpy(datapt, dp, currentlen); ++ ++ datapt += currentlen; ++ dp += currentlen; ++ dlen -= currentlen; ++ datalinelen += currentlen; ++ + ctl_flushpkt(CTL_MORE); + } ++ + memmove((char *)datapt, dp, (unsigned)dlen); + datapt += dlen; + datalinelen += dlen; +Index: contrib/ntp/ntpd/ntp_crypto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_crypto.c.orig ++++ contrib/ntp/ntpd/ntp_crypto.c +@@ -864,12 +864,24 @@ + * errors. + */ + if (vallen == (u_int) EVP_PKEY_size(host_pkey)) { +- RSA_private_decrypt(vallen, ++ u_int32 *cookiebuf = malloc( ++ RSA_size(host_pkey->pkey.rsa)); ++ if (cookiebuf == NULL) { ++ rval = XEVNT_CKY; ++ break; ++ } ++ if (RSA_private_decrypt(vallen, + (u_char *)ep->pkt, +- (u_char *)&temp32, ++ (u_char *)cookiebuf, + host_pkey->pkey.rsa, +- RSA_PKCS1_OAEP_PADDING); +- cookie = ntohl(temp32); ++ RSA_PKCS1_OAEP_PADDING) != 4) { ++ rval = XEVNT_CKY; ++ free(cookiebuf); ++ break; ++ } else { ++ cookie = ntohl(*cookiebuf); ++ free(cookiebuf); ++ } + } else { + rval = XEVNT_CKY; + break; +@@ -3914,7 +3926,7 @@ + rand_file); + exit (-1); + } +- get_systime(&seed); ++ arc4random_buf(&seed, sizeof(l_fp)); + RAND_seed(&seed, sizeof(l_fp)); + RAND_write_file(rand_file); + OpenSSL_add_all_algorithms(); +Index: contrib/ntp/ntpd/ntp_proto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_proto.c.orig ++++ contrib/ntp/ntpd/ntp_proto.c +@@ -649,6 +649,7 @@ + has_mac)) { + is_authentic = AUTH_ERROR; + sys_badauth++; ++ return; + } else { + is_authentic = AUTH_OK; + } +Index: contrib/ntp/util/ntp-keygen.c +=================================================================== +--- contrib/ntp/util/ntp-keygen.c.orig ++++ contrib/ntp/util/ntp-keygen.c +@@ -642,7 +642,7 @@ + for (i = 1; i <= MD5KEYS; i++) { + for (j = 0; j < 16; j++) { + while (1) { +- temp = ntp_random() & 0xff; ++ temp = arc4random() & 0xff; + if (temp == '#') + continue; + if (temp > 0x20 && temp < 0x7f) +@@ -675,7 +675,7 @@ + FILE *str; + + fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "RSA"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", +@@ -954,7 +954,7 @@ + */ + fprintf(stderr, + "Generating GQ parameters (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "GQ"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "GQ"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", Added: user/cperciva/freebsd-update-build/patches/9.2-RELEASE/17-EN-14:13.freebsd-update ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/9.2-RELEASE/17-EN-14:13.freebsd-update Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,12 @@ +Index: usr.sbin/freebsd-update/freebsd-update.sh +=================================================================== +--- usr.sbin/freebsd-update/freebsd-update.sh.orig ++++ usr.sbin/freebsd-update/freebsd-update.sh +@@ -1395,6 +1395,7 @@ + # matter, since we add a leading "/" when we use paths later. + cut -f 3- -d '|' $1 | + sed -e 's,/|d|,|d|,' | ++ sed -e 's,/|-|,|-|,' | + sort -u > $1.tmp + + # Figure out which lines to ignore and remove them. Added: user/cperciva/freebsd-update-build/patches/9.2-RELEASE/17-SA-14:31.ntp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/9.2-RELEASE/17-SA-14:31.ntp Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,145 @@ +Index: contrib/ntp/ntpd/ntp_config.c +=================================================================== +--- contrib/ntp/ntpd/ntp_config.c.orig ++++ contrib/ntp/ntpd/ntp_config.c +@@ -1887,7 +1887,7 @@ + + for (i = 0; i < 8; i++) + for (j = 1; j < 100; ++j) { +- rankey[i] = (char) (ntp_random() & 0xff); ++ rankey[i] = (char) (arc4random() & 0xff); + if (rankey[i] != 0) break; + } + rankey[8] = 0; +Index: contrib/ntp/ntpd/ntp_control.c +=================================================================== +--- contrib/ntp/ntpd/ntp_control.c.orig ++++ contrib/ntp/ntpd/ntp_control.c +@@ -24,6 +24,10 @@ + #include + #include + ++#ifndef MIN ++#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) ++#endif ++ + /* + * Structure to hold request procedure information + */ +@@ -893,6 +897,7 @@ + ) + { + int overhead; ++ unsigned int currentlen; + + overhead = 0; + if (!bin) { +@@ -916,12 +921,22 @@ + /* + * Save room for trailing junk + */ +- if (dlen + overhead + datapt > dataend) { ++ while (dlen + overhead + datapt > dataend) { + /* + * Not enough room in this one, flush it out. + */ ++ currentlen = MIN(dlen, dataend - datapt); ++ ++ memcpy(datapt, dp, currentlen); ++ ++ datapt += currentlen; ++ dp += currentlen; ++ dlen -= currentlen; ++ datalinelen += currentlen; ++ + ctl_flushpkt(CTL_MORE); + } ++ + memmove((char *)datapt, dp, (unsigned)dlen); + datapt += dlen; + datalinelen += dlen; +Index: contrib/ntp/ntpd/ntp_crypto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_crypto.c.orig ++++ contrib/ntp/ntpd/ntp_crypto.c +@@ -864,12 +864,24 @@ + * errors. + */ + if (vallen == (u_int) EVP_PKEY_size(host_pkey)) { +- RSA_private_decrypt(vallen, ++ u_int32 *cookiebuf = malloc( ++ RSA_size(host_pkey->pkey.rsa)); ++ if (cookiebuf == NULL) { ++ rval = XEVNT_CKY; ++ break; ++ } ++ if (RSA_private_decrypt(vallen, + (u_char *)ep->pkt, +- (u_char *)&temp32, ++ (u_char *)cookiebuf, + host_pkey->pkey.rsa, +- RSA_PKCS1_OAEP_PADDING); +- cookie = ntohl(temp32); ++ RSA_PKCS1_OAEP_PADDING) != 4) { ++ rval = XEVNT_CKY; ++ free(cookiebuf); ++ break; ++ } else { ++ cookie = ntohl(*cookiebuf); ++ free(cookiebuf); ++ } + } else { + rval = XEVNT_CKY; + break; +@@ -3914,7 +3926,7 @@ + rand_file); + exit (-1); + } +- get_systime(&seed); ++ arc4random_buf(&seed, sizeof(l_fp)); + RAND_seed(&seed, sizeof(l_fp)); + RAND_write_file(rand_file); + OpenSSL_add_all_algorithms(); +Index: contrib/ntp/ntpd/ntp_proto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_proto.c.orig ++++ contrib/ntp/ntpd/ntp_proto.c +@@ -649,6 +649,7 @@ + has_mac)) { + is_authentic = AUTH_ERROR; + sys_badauth++; ++ return; + } else { + is_authentic = AUTH_OK; + } +Index: contrib/ntp/util/ntp-keygen.c +=================================================================== +--- contrib/ntp/util/ntp-keygen.c.orig ++++ contrib/ntp/util/ntp-keygen.c +@@ -642,7 +642,7 @@ + for (i = 1; i <= MD5KEYS; i++) { + for (j = 0; j < 16; j++) { + while (1) { +- temp = ntp_random() & 0xff; ++ temp = arc4random() & 0xff; + if (temp == '#') + continue; + if (temp > 0x20 && temp < 0x7f) +@@ -675,7 +675,7 @@ + FILE *str; + + fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "RSA"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", +@@ -954,7 +954,7 @@ + */ + fprintf(stderr, + "Generating GQ parameters (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "GQ"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "GQ"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", Added: user/cperciva/freebsd-update-build/patches/9.3-RELEASE/7-EN-14:13.freebsd-update ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/9.3-RELEASE/7-EN-14:13.freebsd-update Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,12 @@ +Index: usr.sbin/freebsd-update/freebsd-update.sh +=================================================================== +--- usr.sbin/freebsd-update/freebsd-update.sh.orig ++++ usr.sbin/freebsd-update/freebsd-update.sh +@@ -1395,6 +1395,7 @@ + # matter, since we add a leading "/" when we use paths later. + cut -f 3- -d '|' $1 | + sed -e 's,/|d|,|d|,' | ++ sed -e 's,/|-|,|-|,' | + sort -u > $1.tmp + + # Figure out which lines to ignore and remove them. Added: user/cperciva/freebsd-update-build/patches/9.3-RELEASE/7-SA-14:31.ntp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/cperciva/freebsd-update-build/patches/9.3-RELEASE/7-SA-14:31.ntp Tue Dec 30 20:10:37 2014 (r276418) @@ -0,0 +1,145 @@ +Index: contrib/ntp/ntpd/ntp_config.c +=================================================================== +--- contrib/ntp/ntpd/ntp_config.c.orig ++++ contrib/ntp/ntpd/ntp_config.c +@@ -1887,7 +1887,7 @@ + + for (i = 0; i < 8; i++) + for (j = 1; j < 100; ++j) { +- rankey[i] = (char) (ntp_random() & 0xff); ++ rankey[i] = (char) (arc4random() & 0xff); + if (rankey[i] != 0) break; + } + rankey[8] = 0; +Index: contrib/ntp/ntpd/ntp_control.c +=================================================================== +--- contrib/ntp/ntpd/ntp_control.c.orig ++++ contrib/ntp/ntpd/ntp_control.c +@@ -24,6 +24,10 @@ + #include + #include + ++#ifndef MIN ++#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) ++#endif ++ + /* + * Structure to hold request procedure information + */ +@@ -893,6 +897,7 @@ + ) + { + int overhead; ++ unsigned int currentlen; + + overhead = 0; + if (!bin) { +@@ -916,12 +921,22 @@ + /* + * Save room for trailing junk + */ +- if (dlen + overhead + datapt > dataend) { ++ while (dlen + overhead + datapt > dataend) { + /* + * Not enough room in this one, flush it out. + */ ++ currentlen = MIN(dlen, dataend - datapt); ++ ++ memcpy(datapt, dp, currentlen); ++ ++ datapt += currentlen; ++ dp += currentlen; ++ dlen -= currentlen; ++ datalinelen += currentlen; ++ + ctl_flushpkt(CTL_MORE); + } ++ + memmove((char *)datapt, dp, (unsigned)dlen); + datapt += dlen; + datalinelen += dlen; +Index: contrib/ntp/ntpd/ntp_crypto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_crypto.c.orig ++++ contrib/ntp/ntpd/ntp_crypto.c +@@ -864,12 +864,24 @@ + * errors. + */ + if (vallen == (u_int) EVP_PKEY_size(host_pkey)) { +- RSA_private_decrypt(vallen, ++ u_int32 *cookiebuf = malloc( ++ RSA_size(host_pkey->pkey.rsa)); ++ if (cookiebuf == NULL) { ++ rval = XEVNT_CKY; ++ break; ++ } ++ if (RSA_private_decrypt(vallen, + (u_char *)ep->pkt, +- (u_char *)&temp32, ++ (u_char *)cookiebuf, + host_pkey->pkey.rsa, +- RSA_PKCS1_OAEP_PADDING); +- cookie = ntohl(temp32); ++ RSA_PKCS1_OAEP_PADDING) != 4) { ++ rval = XEVNT_CKY; ++ free(cookiebuf); ++ break; ++ } else { ++ cookie = ntohl(*cookiebuf); ++ free(cookiebuf); ++ } + } else { + rval = XEVNT_CKY; + break; +@@ -3914,7 +3926,7 @@ + rand_file); + exit (-1); + } +- get_systime(&seed); ++ arc4random_buf(&seed, sizeof(l_fp)); + RAND_seed(&seed, sizeof(l_fp)); + RAND_write_file(rand_file); + OpenSSL_add_all_algorithms(); +Index: contrib/ntp/ntpd/ntp_proto.c +=================================================================== +--- contrib/ntp/ntpd/ntp_proto.c.orig ++++ contrib/ntp/ntpd/ntp_proto.c +@@ -649,6 +649,7 @@ + has_mac)) { + is_authentic = AUTH_ERROR; + sys_badauth++; ++ return; + } else { + is_authentic = AUTH_OK; + } +Index: contrib/ntp/util/ntp-keygen.c +=================================================================== +--- contrib/ntp/util/ntp-keygen.c.orig ++++ contrib/ntp/util/ntp-keygen.c +@@ -642,7 +642,7 @@ + for (i = 1; i <= MD5KEYS; i++) { + for (j = 0; j < 16; j++) { + while (1) { +- temp = ntp_random() & 0xff; ++ temp = arc4random() & 0xff; + if (temp == '#') + continue; + if (temp > 0x20 && temp < 0x7f) +@@ -675,7 +675,7 @@ + FILE *str; + + fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "RSA"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", +@@ -954,7 +954,7 @@ + */ + fprintf(stderr, + "Generating GQ parameters (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "GQ"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "GQ"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 20:22:45 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 09EBE2FD; Tue, 30 Dec 2014 20:22:45 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E99571E9E; Tue, 30 Dec 2014 20:22:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBUKMi7m038780; Tue, 30 Dec 2014 20:22:44 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBUKMhMN038773; Tue, 30 Dec 2014 20:22:43 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412302022.sBUKMhMN038773@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Tue, 30 Dec 2014 20:22:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276420 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2014 20:22:45 -0000 Author: nwhitehorn Date: Tue Dec 30 20:22:43 2014 New Revision: 276420 URL: https://svnweb.freebsd.org/changeset/base/276420 Log: Get FreeBSD kexec'ing. The trampoline needs to relocate the kernel back to where it is supposed to be (on top of Linux, usually) for this to actually do anything useful, but we're now getting much closer. Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/main.c user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Tue Dec 30 20:20:18 2014 (r276419) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Tue Dec 30 20:22:43 2014 (r276420) @@ -44,3 +44,19 @@ ENTRY(host_select) sc blr +ENTRY(kexec_load) + lis %r4,nkexec_segments@ha + ori %r4,%r4,nkexec_segments@l + lwz %r4,0(%r4) + lis %r5,loaded_segments@ha + ori %r5,%r5,loaded_segments@l + lis %r6,21 # KEXEC_ARCH_PPC64 + li %r0,268 # __NR_kexec_load + sc + blr + +ENTRY(host_reboot) + li %r0,88 # SYS_reboot + sc + blr + Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Tue Dec 30 20:20:18 2014 (r276419) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Tue Dec 30 20:22:43 2014 (r276420) @@ -44,5 +44,7 @@ struct host_timeval { int host_gettimeofday(struct host_timeval *a, void *b); int host_select(int nfds, long *readfds, long *writefds, long *exceptfds, struct host_timeval *timeout); +int kexec_load(vm_offset_t start); +int host_reboot(int, int, int, void *); #endif Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Tue Dec 30 20:20:18 2014 (r276419) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Tue Dec 30 20:22:43 2014 (r276420) @@ -181,6 +181,7 @@ get_phys_buffer(vm_offset_t dest, const { int i = 0; const size_t segsize = 2*1024*1024; + dest += 32*1024*1024; /* XXX Make nonoverlapping somehow */ for (i = 0; i < nkexec_segments; i++) { if (dest >= (vm_offset_t)loaded_segments[i].mem && Modified: user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Tue Dec 30 20:20:18 2014 (r276419) +++ user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Tue Dec 30 20:22:43 2014 (r276420) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" +#include "host_syscall.h" extern char end[]; extern vm_offset_t reloc; /* From /conf.c */ @@ -65,6 +66,7 @@ ppc64_elf_exec(struct preloaded_file *fp Elf_Ehdr *e; int error; uint32_t *trampoline; + vm_offset_t trampolinebase = 32*1024*1024; /* XXX */ if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { return(EFTYPE); @@ -84,12 +86,21 @@ ppc64_elf_exec(struct preloaded_file *fp trampoline[6] = mdp; trampoline[7] = sizeof(mdp); - printf("Kernel entry at %#x ...\n", e->e_entry); + printf("Kernel entry at %#jx ...\n", e->e_entry); dev_cleanup(); - archsw.arch_copyin(trampoline, 0 /* XXX */, szkerneltramp); - /* XXX kexec_load, reboot */ + archsw.arch_copyin(trampoline, trampolinebase, szkerneltramp); + free(trampoline); + + error = kexec_load(trampolinebase); + if (error != 0) + panic("kexec_load returned error: %d", error); + error = host_reboot(0xfee1dead, 672274793, + 0x45584543 /* LINUX_REBOOT_CMD_KEXEC */, NULL); + if (error != 0) + panic("reboot returned error: %d", error); + while (1) {} panic("exec returned"); } From owner-svn-src-user@FreeBSD.ORG Thu Jan 1 18:07:59 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 846FA507; Thu, 1 Jan 2015 18:07:59 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 655ED6636B; Thu, 1 Jan 2015 18:07:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t01I7xoc066922; Thu, 1 Jan 2015 18:07:59 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t01I7vB5066912; Thu, 1 Jan 2015 18:07:57 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201501011807.t01I7vB5066912@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Thu, 1 Jan 2015 18:07:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276506 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jan 2015 18:07:59 -0000 Author: nwhitehorn Date: Thu Jan 1 18:07:56 2015 New Revision: 276506 URL: https://svnweb.freebsd.org/changeset/base/276506 Log: Create FDT from /proc/device-tree on Linux host. This is enough to get into KDB. Added: user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c (contents, props changed) Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/metadata.c user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/Makefile Thu Jan 1 16:56:15 2015 (r276505) +++ user/nwhitehorn/kboot/powerpc/kboot/Makefile Thu Jan 1 18:07:56 2015 (r276506) @@ -10,7 +10,7 @@ INSTALLFLAGS= -b # Architecture-specific loader code SRCS= conf.c metadata.c vers.c main.c ppc64_elf_freebsd.c -SRCS+= host_syscall.S hostcons.c hostdisk.c kerneltramp.S +SRCS+= host_syscall.S hostcons.c hostdisk.c kerneltramp.S kbootfdt.c SRCS+= ucmpdi2.c LOADER_DISK_SUPPORT?= yes @@ -21,7 +21,7 @@ LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= no LOADER_GZIP_SUPPORT?= yes -LOADER_FDT_SUPPORT?= no +LOADER_FDT_SUPPORT?= yes LOADER_BZIP2_SUPPORT?= no .if ${LOADER_DISK_SUPPORT} == "yes" @@ -54,6 +54,7 @@ CFLAGS+= -DLOADER_TFTP_SUPPORT .if ${LOADER_FDT_SUPPORT} == "yes" CFLAGS+= -I${.CURDIR}/../../fdt CFLAGS+= -I${.OBJDIR}/../../fdt +CFLAGS+= -I${.CURDIR}/../../../contrib/libfdt CFLAGS+= -DLOADER_FDT_SUPPORT LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a .endif Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Thu Jan 1 16:56:15 2015 (r276505) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Thu Jan 1 18:07:56 2015 (r276506) @@ -3,6 +3,10 @@ ENTRY(host_read) li %r0, 3 # SYS_read sc + bso 1f + blr +1: + li %r3, -1 blr ENTRY(host_write) @@ -60,3 +64,8 @@ ENTRY(host_reboot) sc blr +ENTRY(host_getdents) + li %r0,141 # SYS_getdents + sc + blr + Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Thu Jan 1 16:56:15 2015 (r276505) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Thu Jan 1 18:07:56 2015 (r276506) @@ -46,5 +46,6 @@ int host_select(int nfds, long *readfds, struct host_timeval *timeout); int kexec_load(vm_offset_t start); int host_reboot(int, int, int, void *); +int host_getdents(int fd, void *dirp, int count); #endif Added: user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Thu Jan 1 18:07:56 2015 (r276506) @@ -0,0 +1,140 @@ +/*- + * Copyright (C) 2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include "bootstrap.h" +#include "host_syscall.h" + +static void +print_fdt(void *fdtp) +{ + int offset, depth, i; + const char *compat; + + offset = fdt_path_offset(fdtp, "/"); + + for (depth = 0, offset = fdt_next_node(fdtp, offset, &depth); + offset >= 0; offset = fdt_next_node(fdtp, offset, &depth)) { + for (i = 1; i < depth; i++) printf("\t"); + printf("%d: %s",offset, fdt_get_name(fdtp, offset, NULL)); + compat = fdt_getprop(fdtp, offset, "compatible", NULL); + if (compat != NULL) + printf(" (%s)", compat); + printf("\n"); + } +} + +static void +add_node_to_fdt(void *buffer, const char *path, int fdt_offset) +{ + int child_offset, fd, pfd, error, dentsize; + char subpath[512]; + void *propbuf; + ssize_t proplen; + + struct host_dent { + unsigned long d_fileno; + unsigned long d_off; + unsigned short d_reclen; + char d_name[]; + /* uint8_t d_type; */ + }; + char dents[2048]; + struct host_dent *dent; + int d_type; + + fd = open(path, O_RDONLY); + while (1) { + dentsize = host_getdents(fd, dents, sizeof(dents)); + if (dentsize <= 0) + break; + for (dent = (struct host_dent *)dents; + (char *)dent < dents + dentsize; + dent = (struct host_dent *)((void *)dent + dent->d_reclen)) { + sprintf(subpath, "%s/%s", path, dent->d_name); + if (strcmp(dent->d_name, ".") == 0 || + strcmp(dent->d_name, "..") == 0) + continue; + d_type = *((char *)(dent) + dent->d_reclen - 1); + if (d_type == 4 /* DT_DIR */) { + child_offset = fdt_add_subnode(buffer, fdt_offset, + dent->d_name); + if (child_offset < 0) { + printf("Error %d adding node %s/%s, skipping\n", + child_offset, path, dent->d_name); + continue; + } + + add_node_to_fdt(buffer, subpath, child_offset); + } else { + pfd = open(subpath, O_RDONLY); + propbuf = malloc(1024); + proplen = read(pfd, propbuf, 1024); + if (proplen < 0) + proplen = 0; + error = fdt_setprop(buffer, fdt_offset, dent->d_name, + propbuf, proplen); + free(propbuf); + close(pfd); + if (error) + printf("Error %d adding property %s to " + "node %d\n", error, dent->d_name, + fdt_offset); + } + } + } + + close(fd); +} + +int +fdt_platform_load_dtb(void) +{ + void *buffer; + size_t buflen = 409600; + char path[255] = "/proc/device-tree"; + + buffer = malloc(buflen); + fdt_create_empty_tree(buffer, buflen); + add_node_to_fdt(buffer, path, fdt_path_offset(buffer, "/")); + fdt_pack(buffer); +printf("Device tree is %d total bytes\n", fdt_totalsize(buffer)); + + fdt_load_dtb_addr(buffer); + + return (0); +} + +void +fdt_platform_fixups(void) +{ + +} + Modified: user/nwhitehorn/kboot/powerpc/kboot/metadata.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/metadata.c Thu Jan 1 16:56:15 2015 (r276505) +++ user/nwhitehorn/kboot/powerpc/kboot/metadata.c Thu Jan 1 18:07:56 2015 (r276506) @@ -242,7 +242,7 @@ md_copymodules(vm_offset_t addr, int ker * - Module metadata are formatted and placed in kernel space. */ int -md_load_dual(char *args, vm_offset_t *modulep, int kern64) +md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64) { struct preloaded_file *kfp; struct preloaded_file *xp; @@ -250,6 +250,7 @@ md_load_dual(char *args, vm_offset_t *mo vm_offset_t kernend; vm_offset_t addr; vm_offset_t envp; + vm_offset_t fdtp; vm_offset_t size; uint64_t scratch64; char *rootdevname; @@ -285,6 +286,11 @@ md_load_dual(char *args, vm_offset_t *mo /* pad to a page boundary */ addr = roundup(addr, PAGE_SIZE); + /* Copy out FDT */ + size = fdt_copy(addr); + *dtb = fdtp = addr; + addr = roundup(addr + size, PAGE_SIZE); + kernend = 0; kfp = file_findfile(NULL, kern64 ? "elf64 kernel" : "elf32 kernel"); if (kfp == NULL) @@ -295,10 +301,13 @@ md_load_dual(char *args, vm_offset_t *mo if (kern64) { scratch64 = envp; file_addmetadata(kfp, MODINFOMD_ENVP, sizeof scratch64, &scratch64); + scratch64 = fdtp; + file_addmetadata(kfp, MODINFOMD_DTBP, sizeof scratch64, &scratch64); scratch64 = kernend; file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof scratch64, &scratch64); } else { file_addmetadata(kfp, MODINFOMD_ENVP, sizeof envp, &envp); + file_addmetadata(kfp, MODINFOMD_DTBP, sizeof fdtp, &fdtp); file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend); } @@ -320,14 +329,14 @@ md_load_dual(char *args, vm_offset_t *mo } int -md_load(char *args, vm_offset_t *modulep) +md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb) { - return (md_load_dual(args, modulep, 0)); + return (md_load_dual(args, modulep, dtb, 0)); } int -md_load64(char *args, vm_offset_t *modulep) +md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb) { - return (md_load_dual(args, modulep, 1)); + return (md_load_dual(args, modulep, dtb, 1)); } Modified: user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Thu Jan 1 16:56:15 2015 (r276505) +++ user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Thu Jan 1 18:07:56 2015 (r276506) @@ -62,7 +62,7 @@ int ppc64_elf_exec(struct preloaded_file *fp) { struct file_metadata *fmp; - vm_offset_t mdp; + vm_offset_t mdp, dtb; Elf_Ehdr *e; int error; uint32_t *trampoline; @@ -77,13 +77,13 @@ ppc64_elf_exec(struct preloaded_file *fp trampoline = malloc(szkerneltramp); memcpy(trampoline, &kerneltramp, szkerneltramp); trampoline[2] = e->e_entry; - trampoline[3] = 0; /* FDT */ trampoline[4] = 0; /* Phys. mem offset */ trampoline[5] = 0; /* OF entry point */ - if ((error = md_load64(fp->f_args, &mdp)) != 0) + if ((error = md_load64(fp->f_args, &mdp, &dtb)) != 0) return (error); + trampoline[3] = dtb; trampoline[6] = mdp; trampoline[7] = sizeof(mdp); printf("Kernel entry at %#jx ...\n", e->e_entry); From owner-svn-src-user@FreeBSD.ORG Thu Jan 1 18:12:44 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 89BA9785; Thu, 1 Jan 2015 18:12:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EAA1F66AD1; Thu, 1 Jan 2015 18:12:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t01IC5VV071080; Thu, 1 Jan 2015 18:12:05 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t01IC3mW071069; Thu, 1 Jan 2015 18:12:03 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201501011812.t01IC3mW071069@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Thu, 1 Jan 2015 18:12:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276507 - in user/nwhitehorn/kboot: fdt powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jan 2015 18:12:44 -0000 Author: nwhitehorn Date: Thu Jan 1 18:12:02 2015 New Revision: 276507 URL: https://svnweb.freebsd.org/changeset/base/276507 Log: Commit the actually correct changes to get the FDT into the kernel. Modified: user/nwhitehorn/kboot/fdt/Makefile user/nwhitehorn/kboot/powerpc/kboot/Makefile user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c user/nwhitehorn/kboot/powerpc/kboot/main.c user/nwhitehorn/kboot/powerpc/kboot/metadata.c user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Modified: user/nwhitehorn/kboot/fdt/Makefile ============================================================================== --- user/nwhitehorn/kboot/fdt/Makefile Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/fdt/Makefile Thu Jan 1 18:12:02 2015 (r276507) @@ -6,7 +6,8 @@ LIB= fdt INTERNALLIB= # Vendor sources of libfdt. -SRCS+= fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c +SRCS+= fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \ + fdt_empty_tree.c # Loader's fdt commands extension sources. SRCS+= fdt_loader_cmd.c Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/Makefile Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/Makefile Thu Jan 1 18:12:02 2015 (r276507) @@ -21,7 +21,7 @@ LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= no LOADER_GZIP_SUPPORT?= yes -LOADER_FDT_SUPPORT?= yes +LOADER_FDT_SUPPORT= yes LOADER_BZIP2_SUPPORT?= no .if ${LOADER_DISK_SUPPORT} == "yes" @@ -98,8 +98,8 @@ CFLAGS+= -Wa,-mppc64bridge LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ -DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} -LDADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} +DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} SC_DFLT_FONT=cp437 Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Thu Jan 1 18:12:02 2015 (r276507) @@ -6,9 +6,10 @@ ENTRY(host_read) bso 1f blr 1: - li %r3, -1 + li %r3, 0 blr + ENTRY(host_write) li %r0, 4 # SYS_write sc @@ -49,11 +50,6 @@ ENTRY(host_select) blr ENTRY(kexec_load) - lis %r4,nkexec_segments@ha - ori %r4,%r4,nkexec_segments@l - lwz %r4,0(%r4) - lis %r5,loaded_segments@ha - ori %r5,%r5,loaded_segments@l lis %r6,21 # KEXEC_ARCH_PPC64 li %r0,268 # __NR_kexec_load sc Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Thu Jan 1 18:12:02 2015 (r276507) @@ -44,7 +44,7 @@ struct host_timeval { int host_gettimeofday(struct host_timeval *a, void *b); int host_select(int nfds, long *readfds, long *writefds, long *exceptfds, struct host_timeval *timeout); -int kexec_load(vm_offset_t start); +int kexec_load(vm_offset_t start, int nsegs, void *segs); int host_reboot(int, int, int, void *); int host_getdents(int fd, void *dirp, int count); Modified: user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Thu Jan 1 18:12:02 2015 (r276507) @@ -33,25 +33,6 @@ __FBSDID("$FreeBSD$"); #include "host_syscall.h" static void -print_fdt(void *fdtp) -{ - int offset, depth, i; - const char *compat; - - offset = fdt_path_offset(fdtp, "/"); - - for (depth = 0, offset = fdt_next_node(fdtp, offset, &depth); - offset >= 0; offset = fdt_next_node(fdtp, offset, &depth)) { - for (i = 1; i < depth; i++) printf("\t"); - printf("%d: %s",offset, fdt_get_name(fdtp, offset, NULL)); - compat = fdt_getprop(fdtp, offset, "compatible", NULL); - if (compat != NULL) - printf(" (%s)", compat); - printf("\n"); - } -} - -static void add_node_to_fdt(void *buffer, const char *path, int fdt_offset) { int child_offset, fd, pfd, error, dentsize; @@ -70,7 +51,7 @@ add_node_to_fdt(void *buffer, const char struct host_dent *dent; int d_type; - fd = open(path, O_RDONLY); + fd = host_open(path, O_RDONLY, 0); while (1) { dentsize = host_getdents(fd, dents, sizeof(dents)); if (dentsize <= 0) @@ -94,15 +75,16 @@ add_node_to_fdt(void *buffer, const char add_node_to_fdt(buffer, subpath, child_offset); } else { - pfd = open(subpath, O_RDONLY); propbuf = malloc(1024); - proplen = read(pfd, propbuf, 1024); - if (proplen < 0) - proplen = 0; + proplen = 0; + pfd = host_open(subpath, O_RDONLY, 0); + if (pfd > 0) { + proplen = host_read(pfd, propbuf, 1024); + host_close(pfd); + } error = fdt_setprop(buffer, fdt_offset, dent->d_name, propbuf, proplen); free(propbuf); - close(pfd); if (error) printf("Error %d adding property %s to " "node %d\n", error, dent->d_name, @@ -111,7 +93,7 @@ add_node_to_fdt(void *buffer, const char } } - close(fd); + host_close(fd); } int @@ -125,7 +107,6 @@ fdt_platform_load_dtb(void) fdt_create_empty_tree(buffer, buflen); add_node_to_fdt(buffer, path, fdt_path_offset(buffer, "/")); fdt_pack(buffer); -printf("Device tree is %d total bytes\n", fdt_totalsize(buffer)); fdt_load_dtb_addr(buffer); Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Thu Jan 1 18:12:02 2015 (r276507) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #define _KERNEL #include @@ -49,6 +50,8 @@ ssize_t kboot_readin(const int fd, vm_of int kboot_autoload(void); int kboot_setcurrdev(struct env_var *ev, int flags, const void *value); +extern int command_fdt_internal(int argc, char *argv[]); + int kboot_getdev(void **vdev, const char *devspec, const char **path) { @@ -168,9 +171,9 @@ time(time_t *tloc) struct kexec_segment { void *buf; - size_t bufsz; + int bufsz; void *mem; - size_t memsz; + int memsz; }; struct kexec_segment loaded_segments[128]; @@ -181,7 +184,6 @@ get_phys_buffer(vm_offset_t dest, const { int i = 0; const size_t segsize = 2*1024*1024; - dest += 32*1024*1024; /* XXX Make nonoverlapping somehow */ for (i = 0; i < nkexec_segments; i++) { if (dest >= (vm_offset_t)loaded_segments[i].mem && @@ -287,3 +289,18 @@ _start(int argc, const char **argv, char main((int)sp[0], (const char **)&sp[1]); } +/* + * Since proper fdt command handling function is defined in fdt_loader_cmd.c, + * and declaring it as extern is in contradiction with COMMAND_SET() macro + * (which uses static pointer), we're defining wrapper function, which + * calls the proper fdt handling routine. + */ +static int +command_fdt(int argc, char *argv[]) +{ + + return (command_fdt_internal(argc, argv)); +} + +COMMAND_SET(fdt, "fdt", "flattened device tree handling", command_fdt); + Modified: user/nwhitehorn/kboot/powerpc/kboot/metadata.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/metadata.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/metadata.c Thu Jan 1 18:12:02 2015 (r276507) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include Modified: user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Thu Jan 1 18:12:02 2015 (r276507) @@ -44,6 +44,8 @@ extern char end[]; extern vm_offset_t reloc; /* From /conf.c */ extern void *kerneltramp; extern size_t szkerneltramp; +extern int nkexec_segments; +extern void * loaded_segments; int ppc64_elf_loadfile(char *filename, u_int64_t dest, @@ -66,7 +68,7 @@ ppc64_elf_exec(struct preloaded_file *fp Elf_Ehdr *e; int error; uint32_t *trampoline; - vm_offset_t trampolinebase = 32*1024*1024; /* XXX */ + vm_offset_t trampolinebase = 16*1024*1024; /* XXX */ if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { return(EFTYPE); @@ -93,7 +95,7 @@ ppc64_elf_exec(struct preloaded_file *fp archsw.arch_copyin(trampoline, trampolinebase, szkerneltramp); free(trampoline); - error = kexec_load(trampolinebase); + error = kexec_load(trampolinebase, nkexec_segments, &loaded_segments); if (error != 0) panic("kexec_load returned error: %d", error); error = host_reboot(0xfee1dead, 672274793, From owner-svn-src-user@FreeBSD.ORG Thu Jan 1 22:18:28 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 761F8C9E; Thu, 1 Jan 2015 22:18:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48C4D645C0; Thu, 1 Jan 2015 22:18:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t01MIS85087450; Thu, 1 Jan 2015 22:18:28 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t01MISV8087449; Thu, 1 Jan 2015 22:18:28 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201501012218.t01MISV8087449@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Thu, 1 Jan 2015 22:18:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276513 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jan 2015 22:18:28 -0000 Author: nwhitehorn Date: Thu Jan 1 22:18:27 2015 New Revision: 276513 URL: https://svnweb.freebsd.org/changeset/base/276513 Log: Add some fixups for what you get out of /proc/device-tree, which is not *quite* a transcription of the FDT as far as phandles are concerned. Modified: user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Modified: user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Thu Jan 1 20:53:38 2015 (r276512) +++ user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Thu Jan 1 22:18:27 2015 (r276513) @@ -96,19 +96,62 @@ add_node_to_fdt(void *buffer, const char host_close(fd); } +/* Fix up wrong values added to the device tree by prom_init() in Linux */ + +static void +fdt_linux_fixups(void *fdtp) +{ + int offset, len; + const void *prop; + + /* + * Remove /memory/available properties, which reflect long-gone OF + * state + */ + + offset = fdt_path_offset(fdtp, "/memory@0"); + if (offset > 0) { + fdt_delprop(fdtp, offset, "available"); + /* + * XXX: add real available properties to reflect RTAS, etc. + * reservations? + */ + } + + /* + * Patch up /chosen nodes so that the stored handles mean something, + * where possible. + */ + offset = fdt_path_offset(fdtp, "/chosen"); + if (offset > 0) { + fdt_delprop(fdtp, offset, "cpu"); /* This node not meaningful */ + + offset = fdt_path_offset(fdtp, "/chosen"); + prop = fdt_getprop(fdtp, offset, "linux,stdout-package", &len); + if (prop != NULL) { + fdt_setprop(fdtp, offset, "stdout", prop, len); + offset = fdt_path_offset(fdtp, "/chosen"); + fdt_setprop(fdtp, offset, "stdin", prop, len); + } + } +} + int fdt_platform_load_dtb(void) { void *buffer; size_t buflen = 409600; - char path[255] = "/proc/device-tree"; buffer = malloc(buflen); fdt_create_empty_tree(buffer, buflen); - add_node_to_fdt(buffer, path, fdt_path_offset(buffer, "/")); + add_node_to_fdt(buffer, "/proc/device-tree", + fdt_path_offset(buffer, "/")); + fdt_linux_fixups(buffer); + fdt_pack(buffer); fdt_load_dtb_addr(buffer); + free(buffer); return (0); } From owner-svn-src-user@FreeBSD.ORG Fri Jan 2 21:08:35 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DADA171C; Fri, 2 Jan 2015 21:08:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7F791532; Fri, 2 Jan 2015 21:08:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t02L8Z8c048155; Fri, 2 Jan 2015 21:08:35 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t02L8ZwQ048154; Fri, 2 Jan 2015 21:08:35 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201501022108.t02L8ZwQ048154@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 2 Jan 2015 21:08:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276572 - user/pho/stress2 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jan 2015 21:08:36 -0000 Author: pho Date: Fri Jan 2 21:08:34 2015 New Revision: 276572 URL: https://svnweb.freebsd.org/changeset/base/276572 Log: Added information for running the regression tests. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/README Modified: user/pho/stress2/README ============================================================================== --- user/pho/stress2/README Fri Jan 2 21:02:41 2015 (r276571) +++ user/pho/stress2/README Fri Jan 2 21:08:34 2015 (r276572) @@ -35,6 +35,9 @@ The following sub-directories exists: ./testcases Test programs ./tools Supplementary tools used in stress testing +These days most test development occur is stress2/misc, where the regression tests reside. +To run all of these tests once, type "./all.sh -o" in the stress2/misc directory. + The name stress2 indicates that this is the second generation of the Kernel Stress Test Suite. The first version (stress) was based mostly on scripts. From owner-svn-src-user@FreeBSD.ORG Fri Jan 2 21:13:34 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 17DE1BA4; Fri, 2 Jan 2015 21:13:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 043BE16BB; Fri, 2 Jan 2015 21:13:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t02LDXSc052716; Fri, 2 Jan 2015 21:13:33 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t02LDXg5052715; Fri, 2 Jan 2015 21:13:33 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201501022113.t02LDXg5052715@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 2 Jan 2015 21:13:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276575 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jan 2015 21:13:34 -0000 Author: pho Date: Fri Jan 2 21:13:32 2015 New Revision: 276575 URL: https://svnweb.freebsd.org/changeset/base/276575 Log: Replaced ps by pgrep. Added missing "wait". Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/fork.sh Modified: user/pho/stress2/misc/fork.sh ============================================================================== --- user/pho/stress2/misc/fork.sh Fri Jan 2 21:13:24 2015 (r276574) +++ user/pho/stress2/misc/fork.sh Fri Jan 2 21:13:32 2015 (r276575) @@ -42,11 +42,18 @@ cc -o fork -Wall -Wextra -O2 -g fork.c - for i in `jot 100`; do /tmp/fork & done -sleep 10 -if ps -l | grep -v grep | egrep "fork\$"; then +while ! pgrep -q fork; do + sleep .2 +done +for i in `jot 30`; do + pgrep -q fork || break + sleep 1 +done +if pgrep -q fork; then echo FAIL exit 1 fi +wait rm -f /tmp/fork /tmp/fork.c exit 0