svn commit: r350013 - in head/sys: amd64/amd64 amd64/ia32 arm/arm arm64/arm64 i386/i386 kern mips/mips powerpc/powerpc riscv/riscv sparc64/sparc64

John Baldwin jhb at FreeBSD.org
Mon Jul 15 21:25:20 UTC 2019


Author: jhb
Date: Mon Jul 15 21:25:16 2019
New Revision: 350013
URL: https://svnweb.freebsd.org/changeset/base/350013

Log:
  Don't pass error from syscallenter() to syscallret().
  
  syscallret() doesn't use error anymore.  Fix a few other places to permit
  removing the return value from syscallenter() entirely.
  - Remove a duplicated assertion from arm's syscall().
  - Use td_errno for amd64_syscall_ret_flush_l1d.
  
  Reviewed by:	kib
  MFC after:	1 month
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D2090

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/amd64/ia32/ia32_syscall.c
  head/sys/arm/arm/syscall.c
  head/sys/arm64/arm64/trap.c
  head/sys/i386/i386/trap.c
  head/sys/kern/subr_syscall.c
  head/sys/mips/mips/trap.c
  head/sys/powerpc/powerpc/trap.c
  head/sys/riscv/riscv/trap.c
  head/sys/sparc64/sparc64/trap.c

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/amd64/amd64/trap.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -1169,7 +1169,6 @@ SYSCTL_PROC(_machdep, OID_AUTO, syscall_ret_flush_l1d,
 void
 amd64_syscall(struct thread *td, int traced)
 {
-	int error;
 	ksiginfo_t ksi;
 
 #ifdef DIAGNOSTIC
@@ -1178,7 +1177,7 @@ amd64_syscall(struct thread *td, int traced)
 		/* NOT REACHED */
 	}
 #endif
-	error = syscallenter(td);
+	syscallenter(td);
 
 	/*
 	 * Traced syscall.
@@ -1203,7 +1202,7 @@ amd64_syscall(struct thread *td, int traced)
 	    syscallname(td->td_proc, td->td_sa.code),
 	    td->td_md.md_invl_gen.gen));
 
-	syscallret(td, error);
+	syscallret(td);
 
 	/*
 	 * If the user-supplied value of %rip is not a canonical
@@ -1216,5 +1215,5 @@ amd64_syscall(struct thread *td, int traced)
 	if (__predict_false(td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS))
 		set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
 
-	amd64_syscall_ret_flush_l1d_inline(error);
+	amd64_syscall_ret_flush_l1d_inline(td->td_errno);
 }

Modified: head/sys/amd64/ia32/ia32_syscall.c
==============================================================================
--- head/sys/amd64/ia32/ia32_syscall.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/amd64/ia32/ia32_syscall.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -207,14 +207,13 @@ ia32_syscall(struct trapframe *frame)
 {
 	struct thread *td;
 	register_t orig_tf_rflags;
-	int error;
 	ksiginfo_t ksi;
 
 	orig_tf_rflags = frame->tf_rflags;
 	td = curthread;
 	td->td_frame = frame;
 
-	error = syscallenter(td);
+	syscallenter(td);
 
 	/*
 	 * Traced syscall.
@@ -228,8 +227,8 @@ ia32_syscall(struct trapframe *frame)
 		trapsignal(td, &ksi);
 	}
 
-	syscallret(td, error);
-	amd64_syscall_ret_flush_l1d(error);
+	syscallret(td);
+	amd64_syscall_ret_flush_l1d(td->td_errno);
 }
 
 static void

Modified: head/sys/arm/arm/syscall.c
==============================================================================
--- head/sys/arm/arm/syscall.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/arm/arm/syscall.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -141,14 +141,10 @@ cpu_fetch_syscall_args(struct thread *td)
 static void
 syscall(struct thread *td, struct trapframe *frame)
 {
-	int error;
 
 	td->td_sa.nap = 4;
-
-	error = syscallenter(td);
-	KASSERT(error != 0 || td->td_ar == NULL,
-	    ("returning from syscall with td_ar set!"));
-	syscallret(td, error);
+	syscallenter(td);
+	syscallret(td);
 }
 
 void

Modified: head/sys/arm64/arm64/trap.c
==============================================================================
--- head/sys/arm64/arm64/trap.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/arm64/arm64/trap.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -137,11 +137,10 @@ cpu_fetch_syscall_args(struct thread *td)
 static void
 svc_handler(struct thread *td, struct trapframe *frame)
 {
-	int error;
 
 	if ((frame->tf_esr & ESR_ELx_ISS_MASK) == 0) {
-		error = syscallenter(td);
-		syscallret(td, error);
+		syscallenter(td);
+		syscallret(td);
 	} else {
 		call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr);
 		userret(td, frame);

Modified: head/sys/i386/i386/trap.c
==============================================================================
--- head/sys/i386/i386/trap.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/i386/i386/trap.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -1142,7 +1142,6 @@ syscall(struct trapframe *frame)
 {
 	struct thread *td;
 	register_t orig_tf_eflags;
-	int error;
 	ksiginfo_t ksi;
 
 #ifdef DIAGNOSTIC
@@ -1157,7 +1156,7 @@ syscall(struct trapframe *frame)
 	td = curthread;
 	td->td_frame = frame;
 
-	error = syscallenter(td);
+	syscallenter(td);
 
 	/*
 	 * Traced syscall.
@@ -1178,5 +1177,5 @@ syscall(struct trapframe *frame)
 	    ("System call %s returning with mangled pcb_save",
 	     syscallname(td->td_proc, td->td_sa.code)));
 
-	syscallret(td, error);
+	syscallret(td);
 }

Modified: head/sys/kern/subr_syscall.c
==============================================================================
--- head/sys/kern/subr_syscall.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/kern/subr_syscall.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$");
 #endif
 #include <security/audit/audit.h>
 
-static inline int
+static inline void
 syscallenter(struct thread *td)
 {
 	struct proc *p;
@@ -167,11 +167,10 @@ syscallenter(struct thread *td)
 		PROC_UNLOCK(p);
 	}
 	(p->p_sysent->sv_set_syscall_retval)(td, error);
-	return (error);
 }
 
 static inline void
-syscallret(struct thread *td, int error __unused)
+syscallret(struct thread *td)
 {
 	struct proc *p;
 	struct syscall_args *sa;

Modified: head/sys/mips/mips/trap.c
==============================================================================
--- head/sys/mips/mips/trap.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/mips/mips/trap.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -787,10 +787,8 @@ dofault:
 
 	case T_SYSCALL + T_USER:
 		{
-			int error;
-
 			td->td_sa.trapframe = trapframe;
-			error = syscallenter(td);
+			syscallenter(td);
 
 #if !defined(SMP) && (defined(DDB) || defined(DEBUG))
 			if (trp == trapdebug)
@@ -806,7 +804,7 @@ dofault:
 			 * instead of being done here under a special check
 			 * for SYS_ptrace().
 			 */
-			syscallret(td, error);
+			syscallret(td);
 			return (trapframe->pc);
 		}
 

Modified: head/sys/powerpc/powerpc/trap.c
==============================================================================
--- head/sys/powerpc/powerpc/trap.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/powerpc/powerpc/trap.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -700,7 +700,6 @@ void
 syscall(struct trapframe *frame)
 {
 	struct thread *td;
-	int error;
 
 	td = curthread;
 	td->td_frame = frame;
@@ -715,8 +714,8 @@ syscall(struct trapframe *frame)
 		    "r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
 #endif
 
-	error = syscallenter(td);
-	syscallret(td, error);
+	syscallenter(td);
+	syscallret(td);
 }
 
 static int

Modified: head/sys/riscv/riscv/trap.c
==============================================================================
--- head/sys/riscv/riscv/trap.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/riscv/riscv/trap.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -156,13 +156,12 @@ static void
 svc_handler(struct trapframe *frame)
 {
 	struct thread *td;
-	int error;
 
 	td = curthread;
 	td->td_frame = frame;
 
-	error = syscallenter(td);
-	syscallret(td, error);
+	syscallenter(td);
+	syscallret(td);
 }
 
 static void

Modified: head/sys/sparc64/sparc64/trap.c
==============================================================================
--- head/sys/sparc64/sparc64/trap.c	Mon Jul 15 21:16:01 2019	(r350012)
+++ head/sys/sparc64/sparc64/trap.c	Mon Jul 15 21:25:16 2019	(r350013)
@@ -593,7 +593,6 @@ void
 syscall(struct trapframe *tf)
 {
 	struct thread *td;
-	int error;
 
 	td = curthread;
 	td->td_frame = tf;
@@ -608,6 +607,6 @@ syscall(struct trapframe *tf)
 	td->td_pcb->pcb_tpc = tf->tf_tpc;
 	TF_DONE(tf);
 
-	error = syscallenter(td);
-	syscallret(td, error);
+	syscallenter(td);
+	syscallret(td);
 }


More information about the svn-src-head mailing list