summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2017-06-06 14:35:53 +0000
committervisa <visa@openbsd.org>2017-06-06 14:35:53 +0000
commit97ee410f21483da75c533fa5dc7e87abc48507bd (patch)
tree60dbe2466eaae264c125caf5cd77a1b4b1a2e2df
parentstart slaacd as early as possible, right after pf and sysctl.conf are (diff)
downloadwireguard-openbsd-97ee410f21483da75c533fa5dc7e87abc48507bd.tar.xz
wireguard-openbsd-97ee410f21483da75c533fa5dc7e87abc48507bd.zip
Implement startup smashing in C. The code should be moved
under arch/mips64 once loongson and sgi have gap.o. Discussed with deraadt@
-rw-r--r--sys/arch/octeon/octeon/autoconf.c15
-rw-r--r--sys/arch/octeon/octeon/locore.S13
2 files changed, 15 insertions, 13 deletions
diff --git a/sys/arch/octeon/octeon/autoconf.c b/sys/arch/octeon/octeon/autoconf.c
index eb9fd9bc7d4..0adad7ea22a 100644
--- a/sys/arch/octeon/octeon/autoconf.c
+++ b/sys/arch/octeon/octeon/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.10 2017/04/22 12:34:44 visa Exp $ */
+/* $OpenBSD: autoconf.c,v 1.11 2017/06/06 14:35:53 visa Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
*
@@ -33,6 +33,17 @@ enum devclass bootdev_class = DV_DULL;
extern char uboot_rootdev[];
void
+unmap_startup(void)
+{
+ extern uint32_t kernel_text[], endboot[];
+ uint32_t *word = kernel_text;
+
+ /* Cannot unmap KSEG0; smash with trap. */
+ while (word < endboot)
+ *word++ = 0x00000034u; /* TEQ zero, zero */
+}
+
+void
cpu_configure(void)
{
(void)splhigh();
@@ -40,6 +51,8 @@ cpu_configure(void)
softintr_init();
(void)config_rootfound("mainbus", NULL);
+ unmap_startup();
+
splinit();
cold = 0;
}
diff --git a/sys/arch/octeon/octeon/locore.S b/sys/arch/octeon/octeon/locore.S
index 579a2ebce26..1755759df92 100644
--- a/sys/arch/octeon/octeon/locore.S
+++ b/sys/arch/octeon/octeon/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.13 2017/06/05 15:23:11 visa Exp $ */
+/* $OpenBSD: locore.S,v 1.14 2017/06/06 14:35:53 visa Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -122,17 +122,6 @@ locore_start:
sd v0, -8(t0) # store to randomdata
/*
- * Smash the very early boot code by overwriting it.
- */
- li v0, 0x00000034 # TEQ zero, zero
- LA t0, start
- LA t1, endboot
-1:
- daddu t0, t0, 4
- blt t0, t1, 1b
- sw v0, -4(t0)
-
- /*
* Initialize stack and call machine startup.
*/
LA t0, start - FRAMESZ(CF_SZ)