From: visa Date: Tue, 6 Jun 2017 14:35:53 +0000 (+0000) Subject: Implement startup smashing in C. The code should be moved X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=97ee410f21483da75c533fa5dc7e87abc48507bd;p=openbsd Implement startup smashing in C. The code should be moved under arch/mips64 once loongson and sgi have gap.o. Discussed with deraadt@ --- 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. * @@ -32,6 +32,17 @@ char bootdev[16]; 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) { @@ -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) @@ -121,17 +121,6 @@ locore_start: blt t0, t1, 1b 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. */