shithub: riscv

Download patch

ref: 26008742c54f33761058ded48ae7b4b8cbf9e0cd
parent: 31c5c1ac9a99ac12c395882e25aec3d7d98de016
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Apr 7 13:45:47 EDT 2024

kernel: dont zero up->nerrlab in syscall()

up->nerrlab is initialized to zero in newproc(),
and we make sure that the syscall handler returns
with up->nerrlan == 0 as well.

If we are paranoid, we can put a check in kenter().

--- a/sys/src/9/arm64/trap.c
+++ b/sys/src/9/arm64/trap.c
@@ -206,7 +206,6 @@
 	up->scallnr = scallnr = ureg->r0;
 	spllo();
 	
-	up->nerrlab = 0;
 	startns = 0;
 	ret = -1;
 	if(!waserror()){
--- a/sys/src/9/cycv/trap.c
+++ b/sys/src/9/cycv/trap.c
@@ -219,7 +219,6 @@
 
 	spllo();
 	
-	up->nerrlab = 0;
 	ret = -1;
 	if(!waserror()){
 		if(sp < USTKTOP - BY2PG || sp > USTKTOP - sizeof(Sargs) - BY2WD){
--- a/sys/src/9/mtx/trap.c
+++ b/sys/src/9/mtx/trap.c
@@ -610,7 +610,6 @@
 	spllo();
 
 	sp = ureg->usp;
-	up->nerrlab = 0;
 	ret = -1;
 	if(!waserror()){
 		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs)-BY2WD))
--- a/sys/src/9/pc/trap.c
+++ b/sys/src/9/pc/trap.c
@@ -480,7 +480,6 @@
 
 	spllo();
 
-	up->nerrlab = 0;
 	ret = -1;
 	if(!waserror()){
 		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs)-BY2WD))
--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -456,7 +456,6 @@
 
 	ret = -1;
 	startns = 0;
-	up->nerrlab = 0;
 	if(!waserror()){
 		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs)-BY2WD))
 			validaddr(sp, sizeof(Sargs)+BY2WD, 0);
--- a/sys/src/9/ppc/trap.c
+++ b/sys/src/9/ppc/trap.c
@@ -594,7 +594,6 @@
 	spllo();
 
 	sp = ureg->usp;
-	up->nerrlab = 0;
 	ret = -1;
 	if(!waserror()){
 		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs)-BY2WD))
--- a/sys/src/9/sgi/trap.c
+++ b/sys/src/9/sgi/trap.c
@@ -645,7 +645,6 @@
 	/* no fpu, so no fp state to save */
 	spllo();
 
-	up->nerrlab = 0;
 	ret = -1;
 	if(!waserror()) {
 		if(sp & (BY2WD-1)){
--- a/sys/src/9/xen/trap.c
+++ b/sys/src/9/xen/trap.c
@@ -401,7 +401,6 @@
 	spllo();
 
 	sp = ureg->usp;
-	up->nerrlab = 0;
 	ret = -1;
 	if(!waserror()){
 		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs)-BY2WD))
--- a/sys/src/9/zynq/trap.c
+++ b/sys/src/9/zynq/trap.c
@@ -219,7 +219,6 @@
 
 	spllo();
 	
-	up->nerrlab = 0;
 	ret = -1;
 	if(!waserror()){
 		if(sp < USTKTOP - BY2PG || sp > USTKTOP - sizeof(Sargs) - BY2WD){