Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2020 21:40:04 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r363460 - head/sys/arm64/arm64
Message-ID:  <202007232140.06NLe4UW083960@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Jul 23 21:40:03 2020
New Revision: 363460
URL: https://svnweb.freebsd.org/changeset/base/363460

Log:
  Set si_trapno to the exception code from esr.
  
  Reviewed by:	kib
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D25771

Modified:
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/trap.c
==============================================================================
--- head/sys/arm64/arm64/trap.c	Thu Jul 23 21:33:10 2020	(r363459)
+++ head/sys/arm64/arm64/trap.c	Thu Jul 23 21:40:03 2020	(r363460)
@@ -104,7 +104,7 @@ static abort_handler *abort_handlers[] = {
 };
 
 static __inline void
-call_trapsignal(struct thread *td, int sig, int code, void *addr)
+call_trapsignal(struct thread *td, int sig, int code, void *addr, int trapno)
 {
 	ksiginfo_t ksi;
 
@@ -112,6 +112,7 @@ call_trapsignal(struct thread *td, int sig, int code, 
 	ksi.ksi_signo = sig;
 	ksi.ksi_code = code;
 	ksi.ksi_addr = addr;
+	ksi.ksi_trapno = trapno;
 	trapsignal(td, &ksi);
 }
 
@@ -161,7 +162,8 @@ svc_handler(struct thread *td, struct trapframe *frame
 		syscallenter(td);
 		syscallret(td);
 	} else {
-		call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr);
+		call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr,
+		    ESR_ELx_EXCEPTION(frame->tf_esr));
 		userret(td, frame);
 	}
 }
@@ -177,7 +179,8 @@ align_abort(struct thread *td, struct trapframe *frame
 		panic("Misaligned access from kernel space!");
 	}
 
-	call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr);
+	call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr,
+	    ESR_ELx_EXCEPTION(frame->tf_esr));
 	userret(td, frame);
 }
 
@@ -261,7 +264,8 @@ data_abort(struct thread *td, struct trapframe *frame,
 	error = vm_fault_trap(map, far, ftype, VM_FAULT_NORMAL, &sig, &ucode);
 	if (error != KERN_SUCCESS) {
 		if (lower) {
-			call_trapsignal(td, sig, ucode, (void *)far);
+			call_trapsignal(td, sig, ucode, (void *)far,
+			    ESR_ELx_EXCEPTION(esr));
 		} else {
 			if (td->td_intr_nesting_level == 0 &&
 			    pcb->pcb_onfault != 0) {
@@ -483,24 +487,29 @@ do_el0_sync(struct thread *td, struct trapframe *frame
 		break;
 	case EXCP_UNKNOWN:
 		if (!undef_insn(0, frame))
-			call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)far);
+			call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)far,
+			    exception);
 		userret(td, frame);
 		break;
 	case EXCP_SP_ALIGN:
-		call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_sp);
+		call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_sp,
+		    exception);
 		userret(td, frame);
 		break;
 	case EXCP_PC_ALIGN:
-		call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr);
+		call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr,
+		    exception);
 		userret(td, frame);
 		break;
 	case EXCP_BRKPT_EL0:
 	case EXCP_BRK:
-		call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_elr);
+		call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_elr,
+		    exception);
 		userret(td, frame);
 		break;
 	case EXCP_MSR:
-		call_trapsignal(td, SIGILL, ILL_PRVOPC, (void *)frame->tf_elr); 
+		call_trapsignal(td, SIGILL, ILL_PRVOPC, (void *)frame->tf_elr,
+		    exception);
 		userret(td, frame);
 		break;
 	case EXCP_SOFTSTP_EL0:
@@ -509,11 +518,12 @@ do_el0_sync(struct thread *td, struct trapframe *frame
 		WRITE_SPECIALREG(mdscr_el1,
 		    READ_SPECIALREG(mdscr_el1) & ~DBG_MDSCR_SS);
 		call_trapsignal(td, SIGTRAP, TRAP_TRACE,
-		    (void *)frame->tf_elr);
+		    (void *)frame->tf_elr, exception);
 		userret(td, frame);
 		break;
 	default:
-		call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)frame->tf_elr);
+		call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)frame->tf_elr,
+		    exception);
 		userret(td, frame);
 		break;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007232140.06NLe4UW083960>