svn commit: r342783 - in stable/12: stand stand/powerpc/uboot stand/uboot/common sys/powerpc/aim sys/powerpc/booke sys/powerpc/include sys/powerpc/mpc85xx sys/powerpc/powerpc
Justin Hibbits
jhibbits at FreeBSD.org
Sat Jan 5 05:20:40 UTC 2019
Author: jhibbits
Date: Sat Jan 5 05:20:36 2019
New Revision: 342783
URL: https://svnweb.freebsd.org/changeset/base/342783
Log:
MFC r341101-r341103, r341148, r341391, r341422-r341423, r341454, r341780-r341781, r341805, r342026
Make powerpc booke kernels boot from ubldr.
r341101: powerpcspe: Don't crash the loader on ubldr with SPE instructions.
r341102: powerpc: Prepare Book-E kernels for KERNBASE != run base
r341103: powerpc: Fix the powerpc64 build post-r341102
r341148: powerpc: Don't include KERNBASE in genassym, it's unnecessary
r341391: ubldr: Force 'usefdt' variable to 1 for powerpc
r341422: powerpc/booke: Check for the metadata address by physical address
r341423: powerpc: Check for a fdt in the metadata if it doesn't already exist
r341454: powerpc: preload_addr_relocate is no longer necessary for booke
r341780: powerpc/ubldr: Teach powerpc's ubldr to boot 64-bit kernels
r341781: powerpc/booke: Replace a logical equivalent of pmap_kextract() with a
real call
r341805: powerpc/booke: Don't get and use the load offset for TOC on APs
r342026: powerpc/booke: Change KERNBASE to be physical load address
Added:
stable/12/stand/powerpc/uboot/ppc64_elf_freebsd.c
- copied unchanged from r341781, head/stand/powerpc/uboot/ppc64_elf_freebsd.c
Modified:
stable/12/stand/defs.mk
stable/12/stand/powerpc/uboot/Makefile
stable/12/stand/powerpc/uboot/conf.c
stable/12/stand/uboot/common/main.c
stable/12/sys/powerpc/aim/locore32.S
stable/12/sys/powerpc/aim/locore64.S
stable/12/sys/powerpc/booke/booke_machdep.c
stable/12/sys/powerpc/booke/locore.S
stable/12/sys/powerpc/booke/pmap.c
stable/12/sys/powerpc/include/vmparam.h
stable/12/sys/powerpc/mpc85xx/platform_mpc85xx.c
stable/12/sys/powerpc/powerpc/genassym.c
stable/12/sys/powerpc/powerpc/machdep.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/stand/defs.mk
==============================================================================
--- stable/12/stand/defs.mk Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/stand/defs.mk Sat Jan 5 05:20:36 2019 (r342783)
@@ -115,6 +115,11 @@ CFLAGS+= -march=rv64imac -mabi=lp64
CFLAGS+= -msoft-float
.endif
+# -msoft-float seems to be insufficient for powerpcspe
+.if ${MACHINE_ARCH} == "powerpcspe"
+CFLAGS+= -mno-spe
+.endif
+
.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1)
CFLAGS+= -march=i386
CFLAGS.gcc+= -mpreferred-stack-boundary=2
Modified: stable/12/stand/powerpc/uboot/Makefile
==============================================================================
--- stable/12/stand/powerpc/uboot/Makefile Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/stand/powerpc/uboot/Makefile Sat Jan 5 05:20:36 2019 (r342783)
@@ -16,7 +16,7 @@ NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH}
INSTALLFLAGS= -b
# Architecture-specific loader code
-SRCS= start.S conf.c vers.c
+SRCS= start.S conf.c vers.c ppc64_elf_freebsd.c
SRCS+= ucmpdi2.c
# Always add MI sources
Modified: stable/12/stand/powerpc/uboot/conf.c
==============================================================================
--- stable/12/stand/powerpc/uboot/conf.c Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/stand/powerpc/uboot/conf.c Sat Jan 5 05:20:36 2019 (r342783)
@@ -95,9 +95,11 @@ struct netif_driver *netif_drivers[] = {
* Sort formats so that those that can detect based on arguments
* rather than reading the file go first.
*/
+extern struct file_format uboot_elf64;
struct file_format *file_formats[] = {
&uboot_elf,
+ &uboot_elf64,
NULL
};
Copied: stable/12/stand/powerpc/uboot/ppc64_elf_freebsd.c (from r341781, head/stand/powerpc/uboot/ppc64_elf_freebsd.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/12/stand/powerpc/uboot/ppc64_elf_freebsd.c Sat Jan 5 05:20:36 2019 (r342783, copy of r341781, head/stand/powerpc/uboot/ppc64_elf_freebsd.c)
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 2001 Benno Rice <benno at FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define __ELF_WORD_SIZE 64
+
+#include <sys/param.h>
+#include <sys/linker.h>
+
+#include <machine/metadata.h>
+#include <machine/elf.h>
+#include <machine/md_var.h>
+
+#include <stand.h>
+
+#include "bootstrap.h"
+#include "libuboot.h"
+
+vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
+extern char end[];
+extern vm_offset_t reloc; /* From <arch>/conf.c */
+
+int
+ppc64_uboot_elf_loadfile(char *filename, uint64_t dest,
+ struct preloaded_file **result)
+{
+ int r;
+
+ r = __elfN(loadfile)(filename, dest, result);
+ 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);
+}
+
+int
+ppc64_uboot_elf_exec(struct preloaded_file *fp)
+{
+ struct file_metadata *fmp;
+ vm_offset_t mdp, dtbp;
+ Elf_Ehdr *e;
+ int error;
+ void (*entry)(void *);
+
+ if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) {
+ return(EFTYPE);
+ }
+ e = (Elf_Ehdr *)&fmp->md_data;
+
+ /* Handle function descriptor for ELFv1 kernels */
+ if ((e->e_flags & 3) == 2)
+ entry = (void (*)(void*))(intptr_t)e->e_entry;
+ else
+ entry = *(void (*)(void*))(uint64_t *)(intptr_t)e->e_entry;
+
+ if ((error = md_load64(fp->f_args, &mdp, &dtbp)) != 0)
+ return (error);
+
+ dev_cleanup();
+ printf("Kernel args: %s\n", fp->f_args);
+
+ (*entry)((void *)mdp);
+ panic("exec returned");
+}
+
+struct file_format uboot_elf64 =
+{
+ ppc64_uboot_elf_loadfile,
+ ppc64_uboot_elf_exec
+};
Modified: stable/12/stand/uboot/common/main.c
==============================================================================
--- stable/12/stand/uboot/common/main.c Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/stand/uboot/common/main.c Sat Jan 5 05:20:36 2019 (r342783)
@@ -497,6 +497,9 @@ main(int argc, char **argv)
do_interact:
setenv("LINES", "24", 1); /* optional */
setenv("prompt", "loader>", 1);
+#ifdef __powerpc__
+ setenv("usefdt", "1", 1);
+#endif
archsw.arch_loadaddr = uboot_loadaddr;
archsw.arch_getdev = uboot_getdev;
Modified: stable/12/sys/powerpc/aim/locore32.S
==============================================================================
--- stable/12/sys/powerpc/aim/locore32.S Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/aim/locore32.S Sat Jan 5 05:20:36 2019 (r342783)
@@ -33,6 +33,7 @@
#include <machine/param.h>
#include <machine/spr.h>
#include <machine/asm.h>
+#include <machine/vmparam.h>
#include "opt_platform.h"
/* Locate the per-CPU data structure */
Modified: stable/12/sys/powerpc/aim/locore64.S
==============================================================================
--- stable/12/sys/powerpc/aim/locore64.S Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/aim/locore64.S Sat Jan 5 05:20:36 2019 (r342783)
@@ -35,6 +35,7 @@
#include <machine/param.h>
#include <machine/spr.h>
#include <machine/asm.h>
+#include <machine/vmparam.h>
#ifdef _CALL_ELF
.abiversion _CALL_ELF
Modified: stable/12/sys/powerpc/booke/booke_machdep.c
==============================================================================
--- stable/12/sys/powerpc/booke/booke_machdep.c Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/booke/booke_machdep.c Sat Jan 5 05:20:36 2019 (r342783)
@@ -158,6 +158,7 @@ extern unsigned char __sbss_start[];
extern unsigned char __sbss_end[];
extern unsigned char _end[];
extern vm_offset_t __endkernel;
+extern vm_paddr_t kernload;
/*
* Bootinfo is passed to us by legacy loaders. Save the address of the
@@ -350,7 +351,7 @@ booke_init(u_long arg1, u_long arg2)
end += fdt_totalsize((void *)dtbp);
__endkernel = end;
mdp = NULL;
- } else if (arg1 > (uintptr_t)btext) /* FreeBSD loader */
+ } else if (arg1 > (uintptr_t)kernload) /* FreeBSD loader */
mdp = (void *)arg1;
else /* U-Boot */
mdp = NULL;
Modified: stable/12/sys/powerpc/booke/locore.S
==============================================================================
--- stable/12/sys/powerpc/booke/locore.S Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/booke/locore.S Sat Jan 5 05:20:36 2019 (r342783)
@@ -113,7 +113,7 @@ __start:
* - Create temp entry in the second AS (make sure it's not TLB[1])
* - Switch to temp mapping
* - Map 64MB of RAM in TLB1[1]
- * - Use AS=1, set EPN to KERNBASE and RPN to kernel load address
+ * - Use AS=0, set EPN to VM_MIN_KERNEL_ADDRESS and RPN to kernel load address
* - Switch to TLB1[1] mapping
* - Invalidate temp mapping
*
@@ -238,7 +238,7 @@ __start:
mtspr SPR_MAS1, %r3 /* note TS was not filled, so it's TS=0 */
isync
- LOAD_ADDR(%r3, KERNBASE)
+ LOAD_ADDR(%r3, VM_MIN_KERNEL_ADDRESS)
ori %r3, %r3, (_TLB_ENTRY_SHARED | MAS2_M)@l /* WIMGE = 0b00100 */
mtspr SPR_MAS2, %r3
isync
@@ -471,7 +471,7 @@ bp_kernload:
mtspr SPR_MAS1, %r3 /* note TS was not filled, so it's TS=0 */
isync
- LOAD_ADDR(%r3, KERNBASE)
+ LOAD_ADDR(%r3, VM_MIN_KERNEL_ADDRESS)
ori %r3, %r3, (_TLB_ENTRY_SHARED | MAS2_M)@l /* WIMGE = 0b00100 */
mtspr SPR_MAS2, %r3
isync
@@ -526,8 +526,8 @@ bp_kernload:
7:
/*
- * At this point we're running at virtual addresses KERNBASE and beyond so
- * it's allowed to directly access all locations the kernel was linked
+ * At this point we're running at virtual addresses VM_MIN_KERNEL_ADDRESS and
+ * beyond so it's allowed to directly access all locations the kernel was linked
* against.
*/
@@ -549,14 +549,9 @@ bp_kernload:
add %r2,%r1,%r2
mtspr SPR_SPRG8, %r2
- /* Get load offset */
- ld %r31,-0x8000(%r2) /* First TOC entry is TOC base */
- subf %r31,%r31,%r2 /* Subtract from real TOC base to get base */
-
/* Set up the stack pointer */
ld %r1,TOC_REF(tmpstack)(%r2)
addi %r1,%r1,TMPSTACKSZ-96
- add %r1,%r1,%r31
#else
/*
* Setup a temporary stack
Modified: stable/12/sys/powerpc/booke/pmap.c
==============================================================================
--- stable/12/sys/powerpc/booke/pmap.c Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/booke/pmap.c Sat Jan 5 05:20:36 2019 (r342783)
@@ -1748,13 +1748,6 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_o
data_start = round_page(kernelend);
data_end = data_start;
- /*
- * Addresses of preloaded modules (like file systems) use
- * physical addresses. Make sure we relocate those into
- * virtual addresses.
- */
- preload_addr_relocate = kernstart - kernload;
-
/* Allocate the dynamic per-cpu area. */
dpcpu = (void *)data_end;
data_end += DPCPU_SIZE;
Modified: stable/12/sys/powerpc/include/vmparam.h
==============================================================================
--- stable/12/sys/powerpc/include/vmparam.h Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/include/vmparam.h Sat Jan 5 05:20:36 2019 (r342783)
@@ -106,13 +106,18 @@
#define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE
#ifdef __powerpc64__
+#ifndef LOCORE
#define VM_MIN_KERNEL_ADDRESS 0xe000000000000000UL
#define VM_MAX_KERNEL_ADDRESS 0xe0000007ffffffffUL
+#else
+#define VM_MIN_KERNEL_ADDRESS 0xe000000000000000
+#define VM_MAX_KERNEL_ADDRESS 0xe0000007ffffffff
+#endif
#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
#endif
#ifdef AIM
-#define KERNBASE 0x00100100UL /* start of kernel virtual */
+#define KERNBASE 0x00100100 /* start of kernel virtual */
#ifndef __powerpc64__
#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
@@ -128,16 +133,9 @@
#else /* Book-E */
-#ifdef __powerpc64__
-#ifndef LOCORE
-#define KERNBASE 0xe000000000000100UL /* start of kernel virtual */
-#else
-#define KERNBASE 0xe000000000000100 /* start of kernel virtual */
-#endif
-#else
-#define KERNBASE 0xc0000000 /* start of kernel virtual */
-
-#define VM_MIN_KERNEL_ADDRESS KERNBASE
+#define KERNBASE 0x04000100 /* start of kernel physical */
+#ifndef __powerpc64__
+#define VM_MIN_KERNEL_ADDRESS 0xc0000000
#define VM_MAX_KERNEL_ADDRESS 0xffffefff
#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
#endif
Modified: stable/12/sys/powerpc/mpc85xx/platform_mpc85xx.c
==============================================================================
--- stable/12/sys/powerpc/mpc85xx/platform_mpc85xx.c Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/mpc85xx/platform_mpc85xx.c Sat Jan 5 05:20:36 2019 (r342783)
@@ -68,6 +68,7 @@ extern void *ap_pcpu;
extern vm_paddr_t kernload; /* Kernel physical load address */
extern uint8_t __boot_page[]; /* Boot page body */
extern uint32_t bp_kernload;
+extern vm_offset_t __startkernel;
struct cpu_release {
uint32_t entry_h;
@@ -346,7 +347,7 @@ mpc85xx_smp_start_cpu_epapr(platform_t plat, struct pc
rel_va = rel_page + (rel_pa & PAGE_MASK);
pmap_kenter(rel_page, rel_pa & ~PAGE_MASK);
rel = (struct cpu_release *)rel_va;
- bptr = ((vm_paddr_t)(uintptr_t)__boot_page - KERNBASE) + kernload;
+ bptr = pmap_kextract((uintptr_t)__boot_page);
cpu_flush_dcache(__DEVOLATILE(struct cpu_release *,rel), sizeof(*rel));
rel->pir = pc->pc_cpuid; __asm __volatile("sync");
rel->entry_h = (bptr >> 32);
@@ -415,7 +416,7 @@ mpc85xx_smp_start_cpu(platform_t plat, struct pcpu *pc
/* Flush caches to have our changes hit DRAM. */
cpu_flush_dcache(__boot_page, 4096);
- bptr = ((vm_paddr_t)(uintptr_t)__boot_page - KERNBASE) + kernload;
+ bptr = pmap_kextract((uintptr_t)__boot_page);
KASSERT((bptr & 0xfff) == 0,
("%s: boot page is not aligned (%#jx)", __func__, (uintmax_t)bptr));
if (mpc85xx_is_qoriq()) {
Modified: stable/12/sys/powerpc/powerpc/genassym.c
==============================================================================
--- stable/12/sys/powerpc/powerpc/genassym.c Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/powerpc/genassym.c Sat Jan 5 05:20:36 2019 (r342783)
@@ -225,7 +225,6 @@ ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED);
ASSYM(SF_UC, offsetof(struct sigframe, sf_uc));
-ASSYM(KERNBASE, KERNBASE);
ASSYM(DMAP_BASE_ADDRESS, DMAP_BASE_ADDRESS);
ASSYM(MAXCOMLEN, MAXCOMLEN);
Modified: stable/12/sys/powerpc/powerpc/machdep.c
==============================================================================
--- stable/12/sys/powerpc/powerpc/machdep.c Sat Jan 5 04:43:22 2019 (r342782)
+++ stable/12/sys/powerpc/powerpc/machdep.c Sat Jan 5 05:20:36 2019 (r342783)
@@ -137,6 +137,10 @@ int cacheline_size = 32;
#endif
int hw_direct_map = 1;
+#ifdef BOOKE
+extern vm_paddr_t kernload;
+#endif
+
extern void *ap_pcpu;
struct pcpu __pcpu[MAXCPU];
@@ -295,6 +299,8 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs
#ifdef AIM
if ((uintptr_t)&powerpc_init > DMAP_BASE_ADDRESS)
md_offset = DMAP_BASE_ADDRESS;
+#else /* BOOKE */
+ md_offset = VM_MIN_KERNEL_ADDRESS - kernload;
#endif
preload_metadata = mdp;
@@ -309,6 +315,11 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs
if (envp != NULL)
envp += md_offset;
init_static_kenv(envp, 0);
+ if (fdt == 0) {
+ fdt = MD_FETCH(kmdp, MODINFOMD_DTBP, uintptr_t);
+ if (fdt != 0)
+ fdt += md_offset;
+ }
kernelendphys = MD_FETCH(kmdp, MODINFOMD_KERNEND,
vm_offset_t);
if (kernelendphys != 0)
More information about the svn-src-all
mailing list