PERFORCE change 219642 for review

Robert Watson rwatson at FreeBSD.org
Wed Nov 7 05:45:00 UTC 2012


http://p4web.freebsd.org/@@219642?ac=10

Change 219642 by rwatson at rwatson_svr_ctsrd_mipsbuild on 2012/11/07 05:44:49

	When a capability exception is thrown in userspace, display some
	additional information on the state of CHERI's capability registers.

Affected files ...

.. //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cheri.c#6 edit

Differences ...

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

@@ -238,17 +238,49 @@
 	cheri_capability_set_user(&cfp->cf_pcc);
 }
 
+#define	CHERI_REG_PRINT(c, ctag, num) do {				\
+	printf("C%u t: %u u: %u perms %04jx otype %016jx\n", num,	\
+	    ctag, c.c_unsealed, (uintmax_t)c.c_perms,			\
+	    (uintmax_t)c.c_otype);					\
+	printf("\tbase %016jx length %016jx\n", (uintmax_t)c.c_base,	\
+	    (uintmax_t)c.c_length);					\
+} while (0)
+
 void
 cheri_log_exception(struct trapframe *frame, int trap_type)
 {
+	struct cheri_frame *cheriframe;
+	struct chericap c;
 	register_t cause;
+	u_int ctag;
+	uint8_t exccode, regnum;
 
 #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));
+	exccode = (cause >> 8) & 0xff;
+	regnum = cause & 0x1f;
+	printf("CHERI cause: ExcCode: %02x RegNum: %02x\n", exccode, regnum);
+
+	/* XXXRW: awkward and unmaintainable pointer construction. */
+	cheriframe = &(((struct pcb *)frame)->pcb_cheriframe);
+
+	/* C0 */
+	intr_disable();
+	CHERI_CLC(CHERI_CR_KR1C, CHERI_CR_KDC, &cheriframe->cf_c0, 0);
+	CHERI_GETCAPREG(CHERI_CR_KR1C, c);
+	CHERI_CGETTAG(ctag, 0);
+	intr_enable();
+	CHERI_REG_PRINT(c, ctag, 0);
+
+	/* EPCC */
+	intr_disable();
+	CHERI_CLC(CHERI_CR_KR1C, CHERI_CR_KDC, &cheriframe->cf_pcc, 0);
+	CHERI_GETCAPREG(CHERI_CR_KR1C, c);
+	CHERI_CGETTAG(ctag, 31);
+	intr_enable();
+	CHERI_REG_PRINT(c, ctag, 31);
 }
 
 #ifdef DDB


More information about the p4-projects mailing list