Date: Fri, 29 Dec 2017 20:30:10 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327358 - in head/sys: conf powerpc/aim powerpc/include Message-ID: <201712292030.vBTKUA2V006354@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Fri Dec 29 20:30:10 2017 New Revision: 327358 URL: https://svnweb.freebsd.org/changeset/base/327358 Log: Add support for 64-bit PowerPC kernels to be directly loaded by kexec, which is used as the bootloader on a number of PPC64 platforms. This involves the following pieces: - Making the first instruction a valid kernel entry point, since kexec ignores the ELF entry value. This requires a separate section and linker magic to prevent the linker from filling the beginning of the section with stubs. - Adding an entry point at 0x60 past the first instruction for systems lacking firmware CPU shutdown support (notably PS3). - Linker script changes to support the above. MFC after: 1 month Modified: head/sys/conf/ldscript.powerpc64 head/sys/powerpc/aim/locore64.S head/sys/powerpc/include/vmparam.h Modified: head/sys/conf/ldscript.powerpc64 ============================================================================== --- head/sys/conf/ldscript.powerpc64 Fri Dec 29 20:25:15 2017 (r327357) +++ head/sys/conf/ldscript.powerpc64 Fri Dec 29 20:30:10 2017 (r327358) @@ -8,8 +8,12 @@ SEARCH_DIR(/usr/lib); PROVIDE (__stack = 0); SECTIONS { - /* Read-only sections, merged into text segment: */ + /* Low-address wrapper for bootloaders (kexec/kboot) that can't parse ELF */ + . = kernbase - 0x100; + .kboot : { *(.text.kboot) } + + /* Read-only sections, merged into text segment: */ . = kernbase; PROVIDE (begin = .); @@ -27,6 +31,9 @@ SECTIONS /* Do not emit PT_INTERP section, which confuses some loaders (kexec-lite) */ .interpX : { *(.interp) } : NONE /DISCARD/ : { *(.interp) } + + /* Also delete notes */ + /DISCARD/ : { *(.note.*) } .hash : { *(.hash) } .dynsym : { *(.dynsym) } Modified: head/sys/powerpc/aim/locore64.S ============================================================================== --- head/sys/powerpc/aim/locore64.S Fri Dec 29 20:25:15 2017 (r327357) +++ head/sys/powerpc/aim/locore64.S Fri Dec 29 20:30:10 2017 (r327358) @@ -61,6 +61,47 @@ GLOBAL(tmpstk) TOC_ENTRY(tmpstk) +/* + * Entry point for bootloaders that do not fully implement ELF and start + * at the beginning of the image (kexec, notably). In its own section so + * that it ends up before any linker-generated call stubs and actually at + * the beginning of the image. kexec on some systems also enters at + * (start of image) + 0x60, so put a spin loop there. + */ + .section ".text.kboot", "x", @progbits +kbootentry: + b __start +. = kbootentry + 0x40 /* Magic address used in platform layer */ + .global smp_spin_sem +ap_kexec_spin_sem: + .long -1 +. = kbootentry + 0x60 /* Entry point for kexec APs */ +ap_kexec_start: /* At 0x60 past start, copied to 0x60 by kexec */ + /* r3 set to CPU ID by kexec */ + + /* Invalidate icache for low-memory copy and jump there */ + li %r0,0x80 + dcbst 0,%r0 + sync + icbi 0,%r0 + isync + ba 0x78 /* Absolute branch to next inst */ + +1: or 31,31,31 /* yield */ + sync + lwz %r1,0x40(0) /* Spin on ap_kexec_spin_sem */ + cmpw %r1,%r3 /* Until it equals our CPU ID */ + bne 1b + + /* Released */ + or 2,2,2 /* unyield */ + ba EXC_RST + + +/* + * Now start the real text section + */ + .text .globl btext btext: Modified: head/sys/powerpc/include/vmparam.h ============================================================================== --- head/sys/powerpc/include/vmparam.h Fri Dec 29 20:25:15 2017 (r327357) +++ head/sys/powerpc/include/vmparam.h Fri Dec 29 20:30:10 2017 (r327358) @@ -108,7 +108,7 @@ #endif #ifdef AIM -#define KERNBASE 0x00100000UL /* start of kernel virtual */ +#define KERNBASE 0x00100100UL /* start of kernel virtual */ #ifndef __powerpc64__ #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712292030.vBTKUA2V006354>