ref: f42e53655e9a2a1b516326f6522fba88db59a81c
parent: 78c7cd0c010c1c90dbc3358c2710bddaed379ce9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Jun 14 06:28:30 EDT 2019
bcm64: implement dtracy support
--- a/sys/src/9/bcm64/l.s
+++ b/sys/src/9/bcm64/l.s
@@ -658,3 +658,16 @@
ORR $(3<<32), R0 // type
_vserrpatch:
B _vserrpatch // branch to vtrapX() patched in
+
+/* fault-proof memcpy */
+TEXT peek(SB), 1, $-4
+ MOV R0, R1
+ MOV dst+8(FP), R2
+ MOVWU len+16(FP), R0
+TEXT _peekinst(SB), 1, $-4
+_peekloop:
+ MOVBU (R1)1!, R3
+ MOVBU R3, (R2)1!
+ SUBS $1, R0
+ BNE _peekloop
+ RETURN
--- a/sys/src/9/bcm64/mkfile
+++ b/sys/src/9/bcm64/mkfile
@@ -65,6 +65,7 @@
/$objtype/lib/libsec.a\
/$objtype/lib/libmp.a\
/$objtype/lib/libc.a\
+ /$objtype/lib/libdtracy.a\
9:V: $p$CONF s$p$CONF
--- a/sys/src/9/bcm64/pi3
+++ b/sys/src/9/bcm64/pi3
@@ -21,6 +21,7 @@
# gpio gpio
sd
usb
+ dtracy
link
loopbackmedium
@@ -42,6 +43,9 @@
sdmmc emmc
dma
vcore
+
+ dtracysys
+ dtracytimer
port
int cpuserver = 0;
--- a/sys/src/9/bcm64/trap.c
+++ b/sys/src/9/bcm64/trap.c
@@ -442,13 +442,22 @@
insyscall = up->insyscall;
up->insyscall = 1;
- if(!userureg(ureg) && waserror()){
- if(up->nerrlab == 0){
- pprint("suicide: sys: %s\n", up->errstr);
- pexit(up->errstr, 1);
+ if(!userureg(ureg)){
+ extern void _peekinst(void);
+
+ if(ureg->pc == (uintptr)_peekinst){
+ ureg->pc = ureg->link;
+ goto out;
}
- up->insyscall = insyscall;
- nexterror();
+
+ if(waserror()){
+ if(up->nerrlab == 0){
+ pprint("suicide: sys: %s\n", up->errstr);
+ pexit(up->errstr, 1);
+ }
+ up->insyscall = insyscall;
+ nexterror();
+ }
}
addr = getfar();
@@ -486,6 +495,7 @@
if(!userureg(ureg))
poperror();
+out:
up->insyscall = insyscall;
}