diff options
author | 2014-10-27 21:56:57 +0000 | |
---|---|---|
committer | 2014-10-27 21:56:57 +0000 | |
commit | ff429d491cb23711a06d341e7609be7bc6805fef (patch) | |
tree | 45a865fdd2cb997a8e82fa351f0499f5cd63bae6 | |
parent | Fixup incorrect expansion of the networking mask for dynamic interface (diff) | |
download | wireguard-openbsd-ff429d491cb23711a06d341e7609be7bc6805fef.tar.xz wireguard-openbsd-ff429d491cb23711a06d341e7609be7bc6805fef.zip |
Remove the spilling code for IBAT register and set up the first IBAT register
to cover the first 8 MB of memory such that it covers kernel .text and not
much else. This is a first step towards W^X in the kernel for machines
with G4 and older processors.
ok mpi@
-rw-r--r-- | sys/arch/macppc/macppc/locore.S | 23 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/machdep.c | 28 | ||||
-rw-r--r-- | sys/arch/powerpc/include/bat.h | 17 | ||||
-rw-r--r-- | sys/arch/socppc/socppc/locore.S | 23 | ||||
-rw-r--r-- | sys/arch/socppc/socppc/machdep.c | 33 |
5 files changed, 46 insertions, 78 deletions
diff --git a/sys/arch/macppc/macppc/locore.S b/sys/arch/macppc/macppc/locore.S index 49f4b291eb3..c738d339720 100644 --- a/sys/arch/macppc/macppc/locore.S +++ b/sys/arch/macppc/macppc/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.47 2014/10/18 22:36:36 kettenis Exp $ */ +/* $OpenBSD: locore.S,v 1.48 2014/10/27 21:56:57 kettenis Exp $ */ /* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */ /* @@ -417,26 +417,6 @@ nop32_4e: mfcr %r29 /* save CR */ mfsrr1 %r31 /* test kernel mode */ mfsprg %r1,1 /* restore SP */ -nop64_2s: - mtcr %r31 - bc 12,17,1f /* branch if PSL_PR is set */ - mfsrr0 %r31 /* get fault address */ - rlwinm %r31,%r31,7,25,28 /* get segment * 8 */ - addis %r31,%r31,_C_LABEL(battable)@ha - lwz %r30,_C_LABEL(battable)@l(%r31) /* get batu */ - mtcr %r30 - bc 4,30,1f /* branch if supervisor valid is false */ - mtibatu 3,%r30 - lwz %r30,_C_LABEL(battable)+4@l(%r31) /* get batl */ - mtibatl 3,%r30 - mtcr %r29 /* restore CR */ - mtsprg 1,%r1 - GET_CPUINFO(%r1) - lmw %r28,CI_DISISAVE(%r1) /* restore r28-r31 */ - mfsprg %r1,1 - rfi /* return to trapped code */ -1: -nop64_2e: bla s_isitrap _C_LABEL(isisize) = .-_C_LABEL(isitrap) @@ -1355,7 +1335,6 @@ _C_LABEL(rfi_start): .globl _C_LABEL(nop64_start) _C_LABEL(nop64_start): .long nop64_1s, nop64_1e - .long nop64_2s, nop64_2e .long 0, 0 .globl _C_LABEL(nop32_start) diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c index 6d5ac8fd694..69d0672e128 100644 --- a/sys/arch/macppc/macppc/machdep.c +++ b/sys/arch/macppc/macppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.162 2014/09/19 17:34:05 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.163 2014/10/27 21:56:57 kettenis Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -195,7 +195,7 @@ initppc(startkernel, endkernel, args) * Set up initial BAT table to only map the lowest 256 MB area */ battable[0].batl = BATL(0x00000000, BAT_M); - battable[0].batu = BATU(0x00000000); + battable[0].batu = BATU(0x00000000, BAT_BL_256M); /* * Now setup fixed bat registers @@ -203,14 +203,14 @@ initppc(startkernel, endkernel, args) * Note that we still run in real mode, and the BAT * registers were cleared above. */ - /* IBAT0 used for initial 256 MB segment */ - ppc_mtibat0l(battable[0].batl); - ppc_mtibat0u(battable[0].batu); - - /* DBAT0 used similar */ + /* DBAT0 used for initial 256 MB segment */ ppc_mtdbat0l(battable[0].batl); ppc_mtdbat0u(battable[0].batu); + /* IBAT0 only covering the kernel .text */ + ppc_mtibat0l(battable[0].batl); + ppc_mtibat0u(BATU(0x00000000, BAT_BL_8M)); + /* * Set up trap vectors */ @@ -281,31 +281,31 @@ initppc(startkernel, endkernel, args) /* now that we know physmem size, map physical memory with BATs */ if (physmem > atop(0x10000000)) { battable[0x1].batl = BATL(0x10000000, BAT_M); - battable[0x1].batu = BATU(0x10000000); + battable[0x1].batu = BATU(0x10000000, BAT_BL_256M); } if (physmem > atop(0x20000000)) { battable[0x2].batl = BATL(0x20000000, BAT_M); - battable[0x2].batu = BATU(0x20000000); + battable[0x2].batu = BATU(0x20000000, BAT_BL_256M); } if (physmem > atop(0x30000000)) { battable[0x3].batl = BATL(0x30000000, BAT_M); - battable[0x3].batu = BATU(0x30000000); + battable[0x3].batu = BATU(0x30000000, BAT_BL_256M); } if (physmem > atop(0x40000000)) { battable[0x4].batl = BATL(0x40000000, BAT_M); - battable[0x4].batu = BATU(0x40000000); + battable[0x4].batu = BATU(0x40000000, BAT_BL_256M); } if (physmem > atop(0x50000000)) { battable[0x5].batl = BATL(0x50000000, BAT_M); - battable[0x5].batu = BATU(0x50000000); + battable[0x5].batu = BATU(0x50000000, BAT_BL_256M); } if (physmem > atop(0x60000000)) { battable[0x6].batl = BATL(0x60000000, BAT_M); - battable[0x6].batu = BATU(0x60000000); + battable[0x6].batu = BATU(0x60000000, BAT_BL_256M); } if (physmem > atop(0x70000000)) { battable[0x7].batl = BATL(0x70000000, BAT_M); - battable[0x7].batu = BATU(0x70000000); + battable[0x7].batu = BATU(0x70000000, BAT_BL_256M); } /* diff --git a/sys/arch/powerpc/include/bat.h b/sys/arch/powerpc/include/bat.h index 0979388d76b..d2601d9a2bd 100644 --- a/sys/arch/powerpc/include/bat.h +++ b/sys/arch/powerpc/include/bat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bat.h,v 1.4 2001/09/01 15:49:05 drahn Exp $ */ +/* $OpenBSD: bat.h,v 1.5 2014/10/27 21:56:57 kettenis Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -39,7 +39,7 @@ struct bat { u_int32_t batl; }; -#define BATU(vaddr) (((vaddr)&0xf0000000)|0x1ffe) +#define BATU(vaddr,len) (((vaddr)&0xf0000000)|(len)|0x2) #define BATL(raddr,wimg) (((raddr)&0xf0000000)|(wimg)|0x2) #define BAT_W 0x40 @@ -47,6 +47,19 @@ struct bat { #define BAT_M 0x10 #define BAT_G 0x08 +#define BAT_BL_128K 0x00000000 +#define BAT_BL_256K 0x00000004 +#define BAT_BL_512K 0x0000000c +#define BAT_BL_1M 0x0000001c +#define BAT_BL_2M 0x0000003c +#define BAT_BL_4M 0x0000007c +#define BAT_BL_8M 0x000000fc +#define BAT_BL_16M 0x000001fc +#define BAT_BL_32M 0x000003fc +#define BAT_BL_64M 0x000007fc +#define BAT_BL_128M 0x00000ffc +#define BAT_BL_256M 0x00001ffc + #ifdef _KERNEL extern struct bat battable[16]; #endif diff --git a/sys/arch/socppc/socppc/locore.S b/sys/arch/socppc/socppc/locore.S index bee05821cb8..603634f27f4 100644 --- a/sys/arch/socppc/socppc/locore.S +++ b/sys/arch/socppc/socppc/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.14 2014/10/18 22:36:36 kettenis Exp $ */ +/* $OpenBSD: locore.S,v 1.15 2014/10/27 21:56:57 kettenis Exp $ */ /* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */ /* @@ -436,26 +436,6 @@ nop32_4e: mfcr %r29 /* save CR */ mfsrr1 %r31 /* test kernel mode */ mfsprg %r1,1 /* restore SP */ -nop64_2s: - mtcr %r31 - bc 12,17,1f /* branch if PSL_PR is set */ - mfsrr0 %r31 /* get fault address */ - rlwinm %r31,%r31,7,25,28 /* get segment * 8 */ - addis %r31,%r31,_C_LABEL(battable)@ha - lwz %r30,_C_LABEL(battable)@l(%r31) /* get batu */ - mtcr %r30 - bc 4,30,1f /* branch if supervisor valid is false */ - mtibatu 3,%r30 - lwz %r30,_C_LABEL(battable)+4@l(%r31) /* get batl */ - mtibatl 3,%r30 - mtcr %r29 /* restore CR */ - mtsprg 1,%r1 - GET_CPUINFO(%r1) - lmw %r28,CI_DISISAVE(%r1) /* restore r28-r31 */ - mfsprg %r1,1 - rfi /* return to trapped code */ -1: -nop64_2e: bla s_isitrap _C_LABEL(isisize) = .-_C_LABEL(isitrap) @@ -1374,7 +1354,6 @@ _C_LABEL(rfi_start): .globl _C_LABEL(nop64_start) _C_LABEL(nop64_start): .long nop64_1s, nop64_1e - .long nop64_2s, nop64_2e .long 0, 0 .globl _C_LABEL(nop32_start) diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c index dbf893adffc..08bccc29d09 100644 --- a/sys/arch/socppc/socppc/machdep.c +++ b/sys/arch/socppc/socppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.57 2014/09/19 17:34:05 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.58 2014/10/27 21:56:57 kettenis Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -254,11 +254,8 @@ initppc(u_int startkernel, u_int endkernel, char *args) * Set up initial BAT table to only map the lowest 256 MB area */ battable[0].batl = BATL(0x00000000, BAT_M); -#if 0 - battable[0].batu = BATU(0x00000000); -#else - battable[0].batu = 0x0ffe; /* XXX only map 128MB for now */ -#endif + /* XXX only map 128MB for now */ + battable[0].batu = BATU(0x00000000, BAT_BL_128M); /* * Now setup fixed bat registers @@ -266,14 +263,14 @@ initppc(u_int startkernel, u_int endkernel, char *args) * Note that we still run in real mode, and the BAT * registers were cleared above. */ - /* IBAT0 used for initial 256 MB segment */ - ppc_mtibat0l(battable[0].batl); - ppc_mtibat0u(battable[0].batu); - - /* DBAT0 used similar */ + /* DBAT0 used for initial 256 MB segment */ ppc_mtdbat0l(battable[0].batl); ppc_mtdbat0u(battable[0].batu); + /* IBAT0 only covering the kernel .text */ + ppc_mtibat0l(battable[0].batl); + ppc_mtibat0u(BATU(0x00000000, BAT_BL_8M)); + /* * Set up trap vectors */ @@ -330,31 +327,31 @@ initppc(u_int startkernel, u_int endkernel, char *args) /* now that we know physmem size, map physical memory with BATs */ if (physmem > atop(0x10000000)) { battable[0x1].batl = BATL(0x10000000, BAT_M); - battable[0x1].batu = BATU(0x10000000); + battable[0x1].batu = BATU(0x10000000, BAT_BL_256M); } if (physmem > atop(0x20000000)) { battable[0x2].batl = BATL(0x20000000, BAT_M); - battable[0x2].batu = BATU(0x20000000); + battable[0x2].batu = BATU(0x20000000, BAT_BL_256M); } if (physmem > atop(0x30000000)) { battable[0x3].batl = BATL(0x30000000, BAT_M); - battable[0x3].batu = BATU(0x30000000); + battable[0x3].batu = BATU(0x30000000, BAT_BL_256M); } if (physmem > atop(0x40000000)) { battable[0x4].batl = BATL(0x40000000, BAT_M); - battable[0x4].batu = BATU(0x40000000); + battable[0x4].batu = BATU(0x40000000, BAT_BL_256M); } if (physmem > atop(0x50000000)) { battable[0x5].batl = BATL(0x50000000, BAT_M); - battable[0x5].batu = BATU(0x50000000); + battable[0x5].batu = BATU(0x50000000, BAT_BL_256M); } if (physmem > atop(0x60000000)) { battable[0x6].batl = BATL(0x60000000, BAT_M); - battable[0x6].batu = BATU(0x60000000); + battable[0x6].batu = BATU(0x60000000, BAT_BL_256M); } if (physmem > atop(0x70000000)) { battable[0x7].batl = BATL(0x70000000, BAT_M); - battable[0x7].batu = BATU(0x70000000); + battable[0x7].batu = BATU(0x70000000, BAT_BL_256M); } /* |