OK, turing.

<- leave blank

Sat Nov 21 13:33:10 EST 2020

rioback 777777
back ffffff
high cccccc
border 999999
text 000000
htext 000000
title 55aaaa
ltitle 9eeeee
hold 000099
lhold 005dbb
palehold 4993dd
paletext 666666
size ff0000
menubar 448844
menuback eaffea
menuhigh 448844
menubord 88cc88
menutext 000000
menuhtext eaffea


Sat Nov 21 13:28:43 EST 2020
diff -r 3d85f589531a sys/src/9/pc/ether8169.c
--- a/sys/src/9/pc/ether8169.c Sat Nov 21 16:26:46 2020 +0100
+++ b/sys/src/9/pc/ether8169.c Sat Nov 21 19:28:42 2020 +0100
@@ -615,6 +615,8 @@
 rtl8169halt(Ctlr* ctlr)
 {
	csr8w(ctlr, Cr, 0);
+
+ ctlr->imr = 0;
	csr16w(ctlr, Imr, 0);
	csr16w(ctlr, Isr, ~0);
 }
@@ -782,53 +784,52 @@
	}
 }

+static void rtl8169interrupt(Ureg*, void* arg);
+
 static void
 rtl8169attach(Ether* edev)
 {
- int timeo;
	Ctlr *ctlr;

	ctlr = edev->ctlr;
	qlock(&ctlr->alock);
- if(!ctlr->init){
- ctlr->ntd = Ntd;
- ctlr->nrd = Nrd;
- ctlr->tb = malloc(ctlr->ntd*sizeof(Block*));
- ctlr->rb = malloc(ctlr->nrd*sizeof(Block*));
- ctlr->td = mallocalign(sizeof(D)*ctlr->ntd, 256, 0, 0);
- ctlr->rd = mallocalign(sizeof(D)*ctlr->nrd, 256, 0, 0);
- ctlr->dtcc = mallocalign(sizeof(Dtcc), 64, 0, 0);
- if(ctlr->rb == nil || ctlr->rb == nil ||
- ctlr->rd == nil || ctlr->rd == nil || ctlr->dtcc == nil){
- free(ctlr->tb);
- ctlr->tb = nil;
- free(ctlr->rb);
- ctlr->rb = nil;
- free(ctlr->td);
- ctlr->td = nil;
- free(ctlr->rd);
- ctlr->rd = nil;
- free(ctlr->dtcc);
- ctlr->dtcc = nil;
- qunlock(&ctlr->alock);
- error(Enomem);
- }
- ctlr->init = 1;
- kproc("rtl8169", rtl8169reseter, edev);
+ if(ctlr->init){
+ qunlock(&ctlr->alock);
+ return;
+ }
+ if(waserror()){
+ qunlock(&ctlr->alock);
+ nexterror();
+ }
+ ctlr->ntd = Ntd;
+ ctlr->nrd = Nrd;
+ ctlr->tb = malloc(ctlr->ntd*sizeof(Block*));
+ ctlr->rb = malloc(ctlr->nrd*sizeof(Block*));
+ ctlr->td = mallocalign(sizeof(D)*ctlr->ntd, 256, 0, 0);
+ ctlr->rd = mallocalign(sizeof(D)*ctlr->nrd, 256, 0, 0);
+ ctlr->dtcc = mallocalign(sizeof(Dtcc), 64, 0, 0);
+ if(ctlr->rb == nil || ctlr->rb == nil ||
+ ctlr->rd == nil || ctlr->rd == nil || ctlr->dtcc == nil){
+ free(ctlr->tb);
+ ctlr->tb = nil;
+ free(ctlr->rb);
+ ctlr->rb = nil;
+ free(ctlr->td);
+ ctlr->td = nil;
+ free(ctlr->rd);
+ ctlr->rd = nil;
+ free(ctlr->dtcc);
+ ctlr->dtcc = nil;
+ error(Enomem);
+ }
+ ctlr->init = 1;
+ pcisetbme(ctlr->pcidev);
+ intrenable(edev->irq, rtl8169interrupt, edev, edev->tbdf, edev->name);

- /* rtl8169reseter() does qunlock(&ctlr->alock) when complete */
- qlock(&ctlr->alock);
- }
- qunlock(&ctlr->alock);
+ kproc("rtl8169", rtl8169reseter, edev);

- /*
- * Wait for link to be ready.
- */
- for(timeo = 0; timeo < 35; timeo++){
- if(miistatus(ctlr->mii) == 0)
- break;
- delay(100); /* print fewer miistatus messages */
- }
+ /* reseter unlocks ctlr->alock */
+ poperror();
 }

 static void
@@ -990,7 +991,6 @@
 static void
 rtl8169restart(Ctlr *ctlr)
 {
- ctlr->imr = 0;
	rtl8169halt(ctlr);
	wakeup(&ctlr->reset);
 }
@@ -1037,6 +1037,14 @@
	}
 }

+static void
+rtl8169shutdown(Ether *edev)
+{
+ Ctlr *ctlr = edev->ctlr;
+
+ rtl8169halt(ctlr);
+}
+
 int
 vetmacv(Ctlr *ctlr, uint *macv)
 {
@@ -1144,8 +1152,6 @@

		rtl8169mii(ctlr);

- pcisetbme(p);
-
		if(rtl8169ctlrhead != nil)
			rtl8169ctlrtail->next = ctlr;
		else
@@ -1208,6 +1214,7 @@
	edev->attach = rtl8169attach;
	edev->transmit = rtl8169transmit;
	edev->ifstat = rtl8169ifstat;
+ edev->shutdown = rtl8169shutdown;

	edev->arg = edev;
	edev->promiscuous = rtl8169promiscuous;
@@ -1215,8 +1222,6 @@

	rtl8169link(edev);

- intrenable(edev->irq, rtl8169interrupt, edev, edev->tbdf, edev->name);
-
	return 0;
 }



Sat Nov 21 13:10:15 EST 2020
diff -r 3d85f589531a sys/src/9/pc/ether8169.c
--- a/sys/src/9/pc/ether8169.c Sat Nov 21 16:26:46 2020 +0100
+++ b/sys/src/9/pc/ether8169.c Sat Nov 21 19:10:15 2020 +0100
@@ -814,6 +814,10 @@
			error(Enomem);
		}
		ctlr->init = 1;
+
+ pcisetbme(ctlr->pcidev);
+ intrenable(edev->irq, rtl8169interrupt, edev, edev->tbdf, edev->name);
+
		kproc("rtl8169", rtl8169reseter, edev);

		/* rtl8169reseter() does qunlock(&ctlr->alock) when complete */
@@ -988,6 +992,15 @@
 }

 static void
+rtl8169shutdown(Ether *edev)
+{
+ Ctlr *ctlr = edev->ctlr;
+
+ ctlr->imr = 0;
+ rtl8169halt(ctlr);
+}
+
+static void
 rtl8169restart(Ctlr *ctlr)
 {
	ctlr->imr = 0;
@@ -1144,8 +1157,6 @@

		rtl8169mii(ctlr);

- pcisetbme(p);
-
		if(rtl8169ctlrhead != nil)
			rtl8169ctlrtail->next = ctlr;
		else
@@ -1208,6 +1219,7 @@
	edev->attach = rtl8169attach;
	edev->transmit = rtl8169transmit;
	edev->ifstat = rtl8169ifstat;
+ edev->shutdown = rtl8169shutdown;

	edev->arg = edev;
	edev->promiscuous = rtl8169promiscuous;
@@ -1215,8 +1227,6 @@

	rtl8169link(edev);

- intrenable(edev->irq, rtl8169interrupt, edev, edev->tbdf, edev->name);
-
	return 0;
 }



Sat Nov 21 12:41:32 EST 2020
diff -r 3d85f589531a sys/src/9/pc/ether8169.c
--- a/sys/src/9/pc/ether8169.c Sat Nov 21 16:26:46 2020 +0100
+++ b/sys/src/9/pc/ether8169.c Sat Nov 21 18:41:32 2020 +0100
@@ -988,6 +988,15 @@
 }

 static void
+rtl8169shutdown(Ether *edev)
+{
+ Ctlr *ctlr = edev->ctlr;
+
+ ctlr->imr = 0;
+ rtl8169halt(ctlr);
+}
+
+static void
 rtl8169restart(Ctlr *ctlr)
 {
	ctlr->imr = 0;
@@ -1208,6 +1217,7 @@
	edev->attach = rtl8169attach;
	edev->transmit = rtl8169transmit;
	edev->ifstat = rtl8169ifstat;
+ edev->shutdown = rtl8169shutdown;

	edev->arg = edev;
	edev->promiscuous = rtl8169promiscuous;


Sat Nov 21 11:47:59 EST 2020
cpu% ktrace -i /amd64/9pc64 0xffffffff80116e73 0xffffffff8001f8c0
src(0xffffffff80116e73); // dumpstack+0x10
// data at 0xffffffff8001f8d0?  8016a3b2
src(0xffffffff8016a3b2); // panic+0xeb
// data at 0xffffffff8001fa20?  80117216
src(0xffffffff80117216); // faultamd64+0xba
// data at 0xffffffff8001faf8?  80116522
src(0xffffffff80116522); // trap+0x12c
// data at 0xffffffff8001fbe8?  801106d1
src(0xffffffff801106d1); // _intrr
//passing interrupt frame; last pc found at sp=0xffffffff8001fbe8
// data at 0xffffffff8001fc88?  8013492b
src(0xffffffff8013492b); // rtl8169receive+0x114
// data at 0xffffffff8001fcc8?  80214d44
src(0xffffffff80214d44); // timerintr+0x8d
// data at 0xffffffff8001fd18?  0
//didn't find pc at sp=0xffffffff8001fd18, last pc found at sp=0xffffffff8001fcc8


Fri Nov 20 19:00:34 EST 2020


				     ,,oooooooooo,..
				,,ooo08888*""""**88ooooo..
			   ,,o880" , , ,'.`.  . ."""*888.
			,o8888" ,;;;_;_,;;__;;_;;_`,_,, "8888
		     ,o88888888888888888888888888888888[ 888888o
		   ,o888888888888888888888*";;;";""8888[ "888888o.
		  ,o888888";";;;;:;;;;;;;;;;;;;;;;;;;;;;,;;,""*88o
		 ,88888";;;;;;;;;;;: ::::o;;;oooo;;;;;;;;; ::;;`88o
		,888";;;;;;:;',:::::::o;88o8;;8;@8oo::::::::::: `"8
	       /88";;;;;;;;;:,::: ::::::88;8;88;o8;o8oo;:::::: | `
	       |8" :,.:::::::,,,, :::;: : :: :: ::: ::: :: ::;;; \_
	       /" : :::::::::::::;,;;:::::::::: :: :: : : :;;;; \ -
	       \| : .:::::;;; 88 #@@$//))8@(\ \@@@\";";;;;;;,:,::/|
		| . :'' ' ,,,, \|;88 ;; ,- " ";;,;;,;;/ |\___,
		, : :.::::..  ..  _\/| ;;; | / ,,:;; ..  ,;;,;;/ |\\==
	     __,/ : ::::<#( ' )#> | |;;;; : ;'o@{ ' }>;;;;; |`\_--
	     ==// :::::::: :: :: ::: ':: \ :::'::::::,:,, \`-
	     _,/// : :;:: : :: ::;;:: ; ::: . ; o,, ::;; ;;;,, ||\
	     =// /' ; ;;;;;;; : :;8: ' ;; . ::.8b;,: ::;;,,',, \ ;
	      /// :.  ; ;;;;;;;;;;;;8; .;;; \ :;:8;;;;\ :,;;,' \ \;
		  :: ; ;;;:;;;::; :88; ;;;; \\ :::::::;: :::::,\\;;
		  :: ; ;;;:;;;:; :88;; ;;;; \\ o::::::: ;: :,;,;;;;
		  :::; ,;;;;;;; ;888:; / ;;;;',`# "8o;::: ,',','.  ; ;'
		  ':; ;:;;;;; :8" /.\';;;@@;;o\ ;8o::::::',,'.;;;;
		   ;' ;;;;; ::: \""\\ ::::/=/ ':";;;;; ;;,'.;;;
		    ;;;;;; ,',;;; / , . ;""...  : 'o;::; ,::;'; ;;
		    ;;;;;; ;;;;o8 ,'.'.'o'',";',', \8o,/ ::: ,,;;
		    ; ;;:;; ; o88/ ,' '.:o.'.o',','.  "; /::,:,' ;
		    ; ;;;;; d8; . .',";:8' ;8,,::,: \;; :;:,:',;
		    ';;;;;;; ;8/.  ,; ,.  ;: ' ; ,:,', ':; ;;;,;,:
		     ;.;';;; |8| ;.  _._===-===_=__'_' 8' ,,';,;
		      :..  ::.  8 : ``-==****,*** ,; 8", :,';;'
		       ':.  .` o8: :::';';':;::;'; /": ;;,:;'
			':.  ::\::;:.  ':::::::::::;; , :;; :;;'
			   ':'..'.:;;:':':::':':,: ;; ,;,'
			     `\.::::;: ,:"" ''"":: ,;;'
				`: ::,: :::"::'":::' ;,;
				 `\::;:.  ::::_"::;:: ,,
				    ' -- _ -___;,';'




Fri Nov 20 18:47:29 EST 2020
cpu% cat fd
/usr/mischief/code/ports
  0 r M 15069 (0000000000000001 0 00) 8192 1140 /dev/cons
  1 w M 15069 (0000000000000001 0 00) 8192 3232791 /dev/cons
  2 w M 15069 (0000000000000001 0 00) 8192 3232791 /dev/cons
  3 r c 0 (0000000000000001 0 00) 0 0 /dev/bintime
  4 rw | 0 (0000000000168a01 0 00) 65536 389 #|/data
  5 w M 14864 (00000000001145d7 1225 00) 8192 0
  /usr/mischief/code/ports/build/work/git9/image/tmp/mk_install.log
  6 rw | 0 (0000000000181242 0 00) 65536 20526056 #|/data1
  7 r M 14864 (0000000000016006 146 00) 8192 0 /mnt/union.170291.0/bin/mk
  8 r c 0 (0000000000000001 0 00) 0 0 /mnt/union.170291.0/dev/bintime
  9 r M 14864 (00000000000eb517 94 00) 8192 0 /mnt/union.170291.0/bin/rc
 10 r M 14864 (000000000000853b 1 00) 8192 0 /mnt/union.170291.0/rc/lib/rcmain
 11 r c 0 (0000000000000001 0 00) 0 0 /mnt/union.170291.0/dev/bintime
 12 r M 14864 (000000000000853b 1 00) 8192 0 /mnt/union.170291.0/rc/lib/rcmain
 13 r M 14864 (000000000000853b 1 00) 8192 0 /mnt/union.170291.0/rc/lib/rcmain
 14 r M 14864 (000000000000847a 1 00) 8192 0 /mnt/union.170291.0/bin/dircp
 15 r M 14864 (0000000000015586 107 00) 8192 0 /mnt/union.170291.0/bin/tar
 16 r M 15069 (0000000000000001 0 00) 8192 1140 /dev/cons
cpu% stk 170292
/proc/170292/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
$home/lib/acid
acid: pread(a0=0x10)+0xe /sys/src/libc/9syscall/pread.s:6
fsread(r=0x40ea90)+0x80 /usr/mischief/src/unionfs/unionfs.c:533
sread(srv=0x400360,r=0x40ea90)+0x16a /sys/src/lib9p/srv.c:528
srvwork()+0x1f6 /sys/src/lib9p/srv.c:767
	srv=0x400360
	r=0x40ea90
srv(srv=0x400360)+0x13c /sys/src/lib9p/srv.c:847
postproc()+0x34 /sys/src/lib9p/post.c:16
	s=0x400360
rforker(fn=0x20d1d0,arg=0x400360,flag=0x9)+0x30 /sys/src/lib9p/rfork.c:17
postsrv(s=0x400360,name=0x0)+0x148 /sys/src/lib9p/post.c:44
	fd=0x600000005
	buf=0x200224
	cfd=0x5ffffffff
_postmountsrv(s=0x400360,name=0x0,mtpt=0x7fffffffef85,flag=0x4)+0x18
/sys/src/lib9p/post.c:58
postmountsrv(name=0x0,mtpt=0x7fffffffef85,flag=0x4)+0x32 /sys/src/lib9p/rfork.c:32
main(argv=0x7fffffffef60,argc=0x2)+0x193 /usr/mischief/src/unionfs/unionfs.c:686
	c=0x20190d00000000
	mflag=0x100000004
	mtpt=0x7fffffffef85
	srvname=0x0
	stdio=0x400000000
	_argc=0x6d
	_args=0x405b81
	i=0x1
	branch=0x406cd8
	p=0x406cd8
_main+0x40 /sys/src/libc/amd64/main9.s:15
acid:
echo kill > /proc/170292/ctl


Fri Nov 20 17:58:04 EST 2020
mischief 168252 0:00 0:00 228K Await run
mischief 168272 0:00 0:00 228K Await run
mischief 168279 0:00 0:00 228K Await run
mischief 168283 0:01 0:04 444K Pread unionfs
mischief 168285 0:00 0:00 328K Await mk
mischief 168286 0:00 0:00 264K Await rc
mischief 168649 0:00 0:00 324K Await mk
mischief 168650 0:00 0:00 264K Await rc
mischief 168654 0:00 0:00 260K Await dircp
mischief 168655 0:00 0:00 260K Await dircp
mischief 168656 0:00 0:00 76K Create tar
mischief 168657 0:00 0:00 76K Pread tar
mischief 168685 0:00 0:00 0K Wakeme closeproc
mischief 168700 0:00 0:00 112K Pread ps
cpu% acid -k 168656
/amd64/9pc64:amd64 plan 9 boot image
/sys/lib/acid/port
/sys/lib/acid/amd64
$home/lib/acid
acid: stk()
sleep(r=0xffffffff80a4b320,arg=0xffffffff8098c248,f=0xffffffff80184a1e)+0x138
/sys/src/9/port/proc.c:760
mountio(m=0xffffffff81ddec78,r=0xffffffff8098c248)+0x336
/sys/src/9/port/devmnt.c:1064
mountrpc(r=0xffffffff8098c248,m=0xffffffff81ddec78)+0x28
/sys/src/9/port/devmnt.c:989
mntwalk(c=0xffffffff82cd1d08,nc=0xffffffff81cba4f8,nname=0xffffffff00000001,name=0xffffffff830c2348)+0x1a3
/sys/src/9/port/devmnt.c:428
ewalk(c=0xffffffff82cd1d08,nc=0x0,name=0xffffffff830c2348,nname=0xffffffff00000001)+0x4e
/sys/src/9/port/chan.c:943
walk(cp=0xffffffff82db4328,nnames=0xffffffff00000001,nerror=0xffffffff82db430c,names=0xffffffff830c2348,nomount=0x0)+0x1aa
/sys/src/9/port/chan.c:1014
namec(aname=0xffffffff82ee7e98,amode=0xffffffff00000005,perm=0xffffffff000001b6,omode=0xffffffff00000001)+0x295
/sys/src/9/port/chan.c:1394
syscreate()+0x30 /sys/src/9/port/sysfile.c:1162
syscall(ureg=0xffffffff80110655)+0x1e4 /sys/src/9/pc64/trap.c:785
forkret()+0x0 /sys/src/9/pc64/l.s:904
0xffffffff82db4420 ?file?:0


Fri Nov 20 10:07:12 EST 2020
DNS over HTTPS (DoH)

Fri Nov 20 08:10:22 EST 2020

patch to read plan9.ini/kernel from the same partition that bootx64.efi was loaded
from,
rather than whatever other random fs has a plan9.ini.

diff --git a/sys/src/boot/efi/efi.h b/sys/src/boot/efi/efi.h
--- a/sys/src/boot/efi/efi.h
+++ b/sys/src/boot/efi/efi.h
@@ -49,6 +49,22 @@ typedef struct {
 } EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;

 typedef struct {
+ UINT32 Revision;
+ EFI_HANDLE ParentHandle;
+ void *SystemTable;
+ EFI_HANDLE DeviceHandle;
+ void *FilePath;
+ void *Reserved;
+ UINT32 LoadOptionsSize;
+ void *LoadOptions;
+ void *ImageBase;
+ UINT64 ImageSize;
+ UINT32 ImageCodeType;
+ UINT32 ImageDataType;
+ void *Unload;
+} EFI_LOADED_IMAGE_PROTOCOL;
+
+typedef struct {
	UINT32 RedMask;
	UINT32 GreenMask;
	UINT32 BlueMask;
diff --git a/sys/src/boot/efi/fs.c b/sys/src/boot/efi/fs.c
--- a/sys/src/boot/efi/fs.c
+++ b/sys/src/boot/efi/fs.c
@@ -32,6 +32,12 @@ EFI_GUID EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
	0xc9, 0x69, 0x72, 0x3b,
 };

+static EFI_GUID EFI_LOADED_IMAGE_PROTOCOL_GUID = {
+ 0x5b1b31a1, 0x9562, 0x11d2,
+ 0x8e, 0x3f, 0x00, 0xa0,
+ 0xc9, 0x69, 0x72, 0x3b,
+};
+
 static
 EFI_FILE_PROTOCOL *fsroot;

@@ -87,12 +93,37 @@ int
 fsinit(void **pf)
 {
	EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs;
+ EFI_LOADED_IMAGE_PROTOCOL *image;
	EFI_FILE_PROTOCOL *root;
	EFI_HANDLE *Handles;
	void *f;
	UINTN Count;
	int i;

+ image = nil;
+
+ /* locate kernel and plan9.ini by deriving a fs protocol
+ * from the device the loader was read from.
+ * if that fails, fall back to old method.
+ */
+ if(eficall(ST->BootServices->HandleProtocol, IH,
+ &EFI_LOADED_IMAGE_PROTOCOL_GUID, &image) == 0 &&
+ eficall(ST->BootServices->HandleProtocol, image->DeviceHandle,
+ &EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, &fs) == 0 &&
+ eficall(fs->OpenVolume, fs, &root) == 0){
+
+ fsroot = root;
+ f = fsopen("/plan9.ini");
+ if(f != nil){
+ if(pf != nil)
+ *pf = f;
+ else
+ fsclose(f);
+
+ goto gotit;
+ }
+ }
+
	Count = 0;
	Handles = nil;
	if(eficall(ST->BootServices->LocateHandleBuffer,
@@ -126,6 +157,7 @@ fsinit(void **pf)
	if(fsroot == nil)
		return -1;

+gotit:
	read = fsread;
	close = fsclose;
	open = fsopen;


Fri Nov 20 07:05:16 EST 2020
diff -r 27e5e30d3c30 sys/include/ape/string.h
--- a/sys/include/ape/string.h Wed Nov 18 20:14:26 2020 +0100
+++ b/sys/include/ape/string.h Fri Nov 20 09:19:00 2020 +0300
@@ -19,6 +19,7 @@
 extern int strcmp(const char *, const char *);
 extern int strcoll(const char *, const char *);
 extern char *strdup(char*);
+extern char *strndup(char*, size_t);
 extern int strncmp(const char *, const char *, size_t);
 extern size_t strxfrm(char *, const char *, size_t);
 extern void *memchr(const void *, int, size_t);
diff -r 27e5e30d3c30 sys/src/ape/lib/ap/gen/mkfile
--- a/sys/src/ape/lib/ap/gen/mkfile Wed Nov 18 20:14:26 2020 +0100
+++ b/sys/src/ape/lib/ap/gen/mkfile Fri Nov 20 09:19:00 2020 +0300
@@ -44,6 +44,7 @@
	strncat.$O\
	strncmp.$O\
	strncpy.$O\
+ strndup.$O\
	strnlen.$O\
	strpbrk.$O\
	strrchr.$O\
diff -r 27e5e30d3c30 sys/src/ape/lib/ap/gen/strndup.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/src/ape/lib/ap/gen/strndup.c Fri Nov 20 09:19:00 2020 +0300
@@ -0,0 +1,14 @@
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+char*
+strndup(char *p, size_t len)
+{
+ char *np;
+
+ np = malloc(len+1);
+ if(np)
+ memmove(np, p, len+1);
+ return np;
+}


prev | next