diff options
author | 2011-11-19 20:40:10 +0000 | |
---|---|---|
committer | 2011-11-19 20:40:10 +0000 | |
commit | 0bf31b4e7767bd69e3f65880ef8d60b994bdfdea (patch) | |
tree | 1241c9f748efb9d31d7956e00d0d217cfdc53ecd | |
parent | the Sierra Wireless MC8755 entry was added to the list of "possibly (diff) | |
download | wireguard-openbsd-0bf31b4e7767bd69e3f65880ef8d60b994bdfdea.tar.xz wireguard-openbsd-0bf31b4e7767bd69e3f65880ef8d60b994bdfdea.zip |
Make sure %cr17 points to a valid cpu_info struct before attempting to do the
first few printfs (which happen before we have figured out which exact cpu
we are running on). Found the hard way by aoyama@ on luna88k, and we probably
have just been lucky on other platforms.
-rw-r--r-- | sys/arch/aviion/aviion/locore.S | 24 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/locore.S | 41 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/locore.S | 24 |
3 files changed, 65 insertions, 24 deletions
diff --git a/sys/arch/aviion/aviion/locore.S b/sys/arch/aviion/aviion/locore.S index 28ed5b28887..9f109844c1f 100644 --- a/sys/arch/aviion/aviion/locore.S +++ b/sys/arch/aviion/aviion/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.15 2011/10/09 17:01:32 miod Exp $ */ +/* $OpenBSD: locore.S,v 1.16 2011/11/19 20:40:10 miod Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -130,17 +130,17 @@ ASLOCAL(main_start) stcr r0, VBR FLUSH_PIPELINE -#ifdef MULTIPROCESSOR /* * Have curcpu() point at the dummy cpuinfo structure, - * so that cpu_number() does not dereference random memory. - * This is necessary for early spl usage, despite the fact that - * interrupts are disabled... + * and initialize cr17. + * This is necessary for early spl*() usage, as well as + * mutex diagnostic code. */ or.u r11, r0, hi16(_ASM_LABEL(dummy_cpu)) or r11, r11, lo16(_ASM_LABEL(dummy_cpu)) stcr r11, CPU +#ifdef MULTIPROCESSOR /* * SCM PROM idles all secondary MPUs upon startup, so at this point * we do not have to compete with them. @@ -237,9 +237,9 @@ GLOBAL(secondary_start) /* * Have curcpu() point at the dummy cpuinfo structure, - * so that cpu_number() does not dereference random memory. - * This is necessary for early spl usage, despite the fact that - * interrupts are disabled... + * and initialize cr17. + * This is necessary for early spl*() usage, as well as + * mutex diagnostic code. */ or.u r11, r0, hi16(_ASM_LABEL(dummy_cpu)) or r11, r11, lo16(_ASM_LABEL(dummy_cpu)) @@ -319,7 +319,6 @@ ASLOCAL(u0) GLOBAL(proc0paddr) word _ASM_LABEL(u0) /* KVA of proc0 uarea */ -#ifdef MULTIPROCESSOR /* Dummy cpuinfo structure, for cpu_number() to work early. */ ASLOCAL(dummy_cpu) word 3 /* CIF_PRIMARY | CIF_ALIVE */ /* ci_alive */ @@ -327,11 +326,14 @@ ASLOCAL(dummy_cpu) word 0 /* ci_curpcb */ word 0 /* ci_curpmap */ word 0 /* ci_cpuid */ +#ifdef MULTIPROCESSOR word _ASM_LABEL(dummy_mplock) /* ci_mp_atomic_begin */ word _ASM_LABEL(dummy_mplock) /* ci_mp_atomic_end */ - +#else + word 0 + word 0 +#endif space CPU_INFO_SIZEOF - 7 * 4 -#endif /* MULTIPROCESSOR */ #if defined(DDB) || NKSYMS > 0 GLOBAL(esym) diff --git a/sys/arch/luna88k/luna88k/locore.S b/sys/arch/luna88k/luna88k/locore.S index 4f814a05920..43209809346 100644 --- a/sys/arch/luna88k/luna88k/locore.S +++ b/sys/arch/luna88k/luna88k/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.21 2010/12/23 20:05:08 miod Exp $ */ +/* $OpenBSD: locore.S,v 1.22 2011/11/19 20:40:10 miod Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -147,6 +147,16 @@ ASLOCAL(main_start) * Main processor specific initialization (with cpu_mutex held). */ ASLOCAL(main_init) + /* + * Have curcpu() point to the dummy cpuinfo structure, + * and initialize cr17. + * This is necessary for early spl*() usage, as well as + * mutex diagnostic code. + */ + or.u r11, r0, hi16(_ASM_LABEL(dummy_cpu)) + or r11, r11, lo16(_ASM_LABEL(dummy_cpu)) + stcr r11, CPU + /* Switch to startup stack */ or.u r31, r0, hi16(_ASM_LABEL(initstack_end)) or r31, r31, lo16(_ASM_LABEL(initstack_end)) @@ -230,6 +240,17 @@ ASLOCAL(main_panic) ASLOCAL(secondary_init) #ifdef MULTIPROCESSOR /* + * Have curcpu() point to the dummy cpuinfo structure, + * and initialize cr17. + * This is necessary for early spl*() usage, as well as + * mutex diagnostic code. + */ + or.u r11, r0, hi16(_ASM_LABEL(dummy_cpu)) + or r11, r11, lo16(_ASM_LABEL(dummy_cpu)) + st r0, r11, CI_FLAGS /* reset CIF_PRIMARY */ + stcr r11, CPU + + /* * While holding the cpu_mutex, the secondary cpu can use the slavestack * to call secondary_pre_main() to determine its cpu number. * After that, however, it should allocate its own stack and switch @@ -304,10 +325,26 @@ ASLOCAL(u0) GLOBAL(proc0paddr) word _ASM_LABEL(u0) /* KVA of proc0 uarea */ -/* The first processor that XMEMs this becomes the master */ +/* The first processor to XMEM this becomes the master */ ASLOCAL(master_mpu) word 0 +/* Dummy cpuinfo structure, for early bootstrap */ +ASLOCAL(dummy_cpu) + word 3 /* CIF_ALIVE | CIF_PRIMARY */ /* ci_flags */ + word 0 /* ci_curproc */ + word 0 /* ci_curpcb */ + word 0 /* ci_curpmap */ + word 0 /* ci_cpuid */ +#ifdef MULTIPROCESSOR + word _ASM_LABEL(dummy_mplock) /* ci_mp_atomic_begin */ + word _ASM_LABEL(dummy_mplock) /* ci_mp_atomic_end */ +#else + word 0 + word 0 +#endif + space CPU_INFO_SIZEOF - 7 * 4 + #if defined(DDB) || NKSYMS > 0 GLOBAL(esym) word 0 diff --git a/sys/arch/mvme88k/mvme88k/locore.S b/sys/arch/mvme88k/mvme88k/locore.S index d43d1aaea27..d8e8e9d71d8 100644 --- a/sys/arch/mvme88k/mvme88k/locore.S +++ b/sys/arch/mvme88k/mvme88k/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.68 2011/10/09 17:01:34 miod Exp $ */ +/* $OpenBSD: locore.S,v 1.69 2011/11/19 20:40:10 miod Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -156,17 +156,17 @@ ASLOCAL(main_start) bsr.n _ASM_LABEL(setup_psr) st r8, r13, lo16(_C_LABEL(cputyp)) -#ifdef MULTIPROCESSOR /* * Have curcpu() point at the dummy cpuinfo structure, - * so that cpu_number() does not dereference random memory. - * This is necessary for early spl usage, despite the fact that - * interrupts are disabled... + * and initialize cr17. + * This is necessary for early spl*() usage, as well as + * mutex diagnostic code. */ or.u r11, r0, hi16(_ASM_LABEL(dummy_cpu)) or r11, r11, lo16(_ASM_LABEL(dummy_cpu)) stcr r11, CPU +#ifdef MULTIPROCESSOR /* * MVME BUG idles all secondary MPUs upon startup, so at this point * we do not have to compete with them. @@ -236,9 +236,9 @@ GLOBAL(secondary_start) /* * Have curcpu() point at the dummy cpuinfo structure, - * so that cpu_number() does not dereference random memory. - * This is necessary for early spl usage, despite the fact that - * interrupts are disabled... + * and initialize cr17. + * This is necessary for early spl*() usage, as well as + * mutex diagnostic code. */ or.u r11, r0, hi16(_ASM_LABEL(dummy_cpu)) or r11, r11, lo16(_ASM_LABEL(dummy_cpu)) @@ -382,7 +382,6 @@ ASLOCAL(u0) GLOBAL(proc0paddr) word _ASM_LABEL(u0) /* KVA of proc0 uarea */ -#ifdef MULTIPROCESSOR /* Dummy cpuinfo structure, for cpu_number() to work early. */ ASLOCAL(dummy_cpu) word 3 /* CIF_ALIVE | CIF_PRIMARY */ /* ci_flags */ @@ -390,11 +389,14 @@ ASLOCAL(dummy_cpu) word 0 /* ci_curpcb */ word 0 /* ci_curpmap */ word 0 /* ci_cpuid */ +#ifdef MULTIPROCESSOR word _ASM_LABEL(dummy_mplock) /* ci_mp_atomic_begin */ word _ASM_LABEL(dummy_mplock) /* ci_mp_atomic_end */ - - space CPU_INFO_SIZEOF - 7 * 4 +#else + word 0 + word 0 #endif /* MULTIPROCESSOR */ + space CPU_INFO_SIZEOF - 7 * 4 #if defined(DDB) || NKSYMS > 0 GLOBAL(esym) |