Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Nov 2012 16:13:24 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 219623 for review
Message-ID:  <201211061613.qA6GDO7A058482@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@219623?ac=10

Change 219623 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/11/06 16:12:31

	When toasting a process with SIGPROT, print out some MIPS trap
	frame information, and the CHERI cause register.  In the future
	we will also want to print out some capability register
	information as well.

Affected files ...

.. //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cheri.c#5 edit
.. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#11 edit
.. //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/trap.c#9 edit

Differences ...

==== //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cheri.c#5 (text+ko) ====

@@ -238,6 +238,19 @@
 	cheri_capability_set_user(&cfp->cf_pcc);
 }
 
+void
+cheri_log_exception(struct trapframe *frame, int trap_type)
+{
+	register_t cause;
+
+#ifdef SMP
+	printf("cpuid = %d\n", PCPU_GET(cpuid));
+#endif
+	CHERI_CGETCAUSE(cause);
+	printf("CHERI cause: ExcCode: %02x RegNum: %02x\n",
+	    (uint8_t)((cause >> 8) & 0xff), (uint8_t)(cause & 0x1f));
+}
+
 #ifdef DDB
 #define	DB_CHERI_REG_PRINT_NUM(crn, num) do {				\
 	struct chericap c;						\

==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#11 (text+ko) ====

@@ -300,6 +300,7 @@
 void	cheri_context_copy(struct cheri_frame *cf_destp,
 	    struct cheri_frame *cf_srcp);
 void	cheri_exec_setregs(struct thread *td);
+void	cheri_log_exception(struct trapframe *frame, int trap_type);
 #endif
 
 #endif /* _MIPS_INCLUDE_CHERI_H_ */

==== //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/trap.c#9 (text+ko) ====

@@ -129,6 +129,7 @@
 
 static void log_illegal_instruction(const char *, struct trapframe *);
 static void log_bad_page_fault(char *, struct trapframe *, int);
+static void log_c2e_exception(const char *, struct trapframe *, int);
 static void log_frame_dump(struct trapframe *frame);
 static void get_mapping_info(vm_offset_t, pd_entry_t **, pt_entry_t **);
 
@@ -911,10 +912,8 @@
 		break;
 
 	case T_C2E + T_USER:
-		/*
-		 * XXXRW: Eventually, do much, much more here.
-		 * log_cheri_exception("C2E", trapframe);
-		 */
+		msg = "USER_CHERI_EXCEPTION";
+		log_c2e_exception(msg, trapframe, type);
 		i = SIGPROT;
 		addr = trapframe->pc;
 		break;
@@ -1540,6 +1539,24 @@
 	    (intmax_t)frame->badvaddr, (void *)(intptr_t)*pdep, (uintmax_t)(ptep ? *ptep : 0));
 }
 
+#ifdef CPU_CHERI
+/*
+ * XXXRW: Possibly this should actually be a CHERI-independent logging
+ * function, in which case only the CHERI-specific parts should be ifdef'd.
+ */
+static void
+log_c2e_exception(const char *msg, struct trapframe *frame, int trap_type)
+{
+
+#ifdef SMP
+	printf("cpuid = %d\n", PCPU_GET(cpuid));
+#endif
+
+	/* log registers in trap frame */
+	log_frame_dump(frame);
+	cheri_log_exception(frame, trap_type);
+}
+#endif
 
 /*
  * Unaligned load/store emulation



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