changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: bcm: use extended small pages so XN bit can work

changeset 7484: cc5c37116d5e
parent 7483: 26b187835048
child 7485: 50813cd186d3
author: cinap_lenrek@felloff.net
date: Wed, 04 Dec 2019 22:02:51 +0100
files: sys/src/9/bcm/archbcm.c sys/src/9/bcm/archbcm2.c sys/src/9/bcm/arm.h sys/src/9/bcm/armv6.s sys/src/9/bcm/fns.h sys/src/9/bcm/mkfile sys/src/9/bcm/mmu.c
description: bcm: use extended small pages so XN bit can work

the change to support no-execute bits broke the original
raspberry pi1, as it uses backwards compatible page table
format.

to use the XN bit, subpage AP bits have to be disabled
using the XP bit in CP15 Control Register c1 Bit 23.
     1.1--- a/sys/src/9/bcm/archbcm.c
     1.2+++ b/sys/src/9/bcm/archbcm.c
     1.3@@ -116,12 +116,6 @@ archbcmlink(void)
     1.4 }
     1.5 
     1.6 int
     1.7-l2ap(int ap)
     1.8-{
     1.9-	return (AP(3, (ap))|AP(2, (ap))|AP(1, (ap))|AP(0, (ap)));
    1.10-}
    1.11-
    1.12-int
    1.13 cmpswap(long *addr, long old, long new)
    1.14 {
    1.15 	return cas32(addr, old, new);
     2.1--- a/sys/src/9/bcm/archbcm2.c
     2.2+++ b/sys/src/9/bcm/archbcm2.c
     2.3@@ -221,12 +221,6 @@ archbcm2link(void)
     2.4 	addclock0link(wdogfeed, HZ);
     2.5 }
     2.6 
     2.7-int
     2.8-l2ap(int ap)
     2.9-{
    2.10-	return (AP(0, (ap)));
    2.11-}
    2.12-
    2.13 void
    2.14 cpustart(int cpu)
    2.15 {
     3.1--- a/sys/src/9/bcm/arm.h
     3.2+++ b/sys/src/9/bcm/arm.h
     3.3@@ -123,6 +123,7 @@
     3.4 #define CpCha		(1<<17)		/* HA: hw access flag enable */
     3.5 #define CpCdz		(1<<19)		/* DZ: divide by zero fault enable */
     3.6 #define CpCfi		(1<<21)		/* FI: fast intrs */
     3.7+#define CpCxp		(1<<23)		/* XP: subpage AP bits disabled */
     3.8 #define CpCve		(1<<24)		/* VE: intr vectors enable */
     3.9 #define CpCee		(1<<25)		/* EE: exception endianness */
    3.10 #define CpCnmfi		(1<<27)		/* NMFI: non-maskable fast intrs. */
    3.11@@ -309,8 +310,8 @@
    3.12 
    3.13 #define F(v, o, w)	(((v) & ((1<<(w))-1))<<(o))
    3.14 #define AP(n, v)	F((v), ((n)*2)+4, 2)
    3.15-#define L1AP(ap)	(AP(3, (ap)))
    3.16-/* L2AP differs between armv6 and armv7 -- see l2ap in arch*.c */
    3.17+#define L1AP(ap)	AP(3, (ap))
    3.18+#define L2AP(ap)	AP(0, (ap))
    3.19 #define DAC(n, v)	F((v), (n)*2, 2)
    3.20 
    3.21 #define HVECTORS	0xffff0000
     4.1--- a/sys/src/9/bcm/armv6.s
     4.2+++ b/sys/src/9/bcm/armv6.s
     4.3@@ -57,7 +57,7 @@ TEXT armstart(SB), 1, $-4
     4.4 	 * enable caches, mmu, and high vectors
     4.5 	 */
     4.6 	MRC	CpSC, 0, R0, C(CpCONTROL), C(0), CpMainctl
     4.7-	ORR	$(CpChv|CpCdcache|CpCicache|CpCpredict|CpCmmu), R0
     4.8+	ORR	$(CpCxp|CpChv|CpCdcache|CpCicache|CpCpredict|CpCmmu), R0
     4.9 	MCR	CpSC, 0, R0, C(CpCONTROL), C(0), CpMainctl
    4.10 	ISB
    4.11 
     5.1--- a/sys/src/9/bcm/fns.h
     5.2+++ b/sys/src/9/bcm/fns.h
     5.3@@ -99,7 +99,6 @@ extern void wdogoff(void);
     5.4 extern void wdogfeed(void);
     5.5 extern void writeconf(void);
     5.6 extern void vtable(void);
     5.7-extern int l2ap(int);
     5.8 extern uint getcputemp(void);
     5.9 extern char *cputype2name(char *buf, int size);
    5.10 extern uint getboardrev(void);
     6.1--- a/sys/src/9/bcm/mkfile
     6.2+++ b/sys/src/9/bcm/mkfile
     6.3@@ -112,6 +112,7 @@ armv7.$O: cache.v7.s
     6.4 main.$O: errstr.h init.h reboot.h
     6.5 devmouse.$O mouse.$O screen.$O: screen.h
     6.6 usbdwc.$O: dwcotg.h ../port/usb.h
     6.7+arch.$O archbcm.$O archbcm2.$O clock.$O coproc.$O fpiarn.$O mmu.$O trap.$O vfp3.$O: arm.h mem.h
     6.8 
     6.9 init.h:D:	../port/initcode.c init9.s
    6.10 	$CC ../port/initcode.c
     7.1--- a/sys/src/9/bcm/mmu.c
     7.2+++ b/sys/src/9/bcm/mmu.c
     7.3@@ -9,7 +9,6 @@
     7.4 #define FEXT(d, o, w)	(((d)>>(o)) & ((1<<(w))-1))
     7.5 #define L1X(va)		FEXT((va), 20, 12)
     7.6 #define L2X(va)		FEXT((va), 12, 8)
     7.7-#define L2AP(ap)	l2ap(ap)
     7.8 #define L1ptedramattrs	soc.l1ptedramattrs
     7.9 #define L2ptedramattrs	soc.l2ptedramattrs
    7.10 #define PTEDRAM		(PHYSDRAM|Dom0|L1AP(Krw)|Section|L1ptedramattrs)