Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Sep 2013 21:29:29 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 719157 for review
Message-ID:  <201309152129.r8FLTThp072194@skunkworks.freebsd.org>

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

Change 719157 by rwatson@rwatson_zenith_cl_cam_ac_uk on 2013/09/15 21:28:53

	Begin to flesh out the framing around a software CCall/CReturn
	path: branch from a low-level exception handler in the vector
	table to one of two higher-level paths: CHERICCall and
	CHERICReturn.  Select the path based on the cause register.
	Many more assertions required here -- and this is still just an
	(increasingly complicated) NOP.

Affected files ...

.. //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/ccall.S#4 edit

Differences ...

==== //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/ccall.S#4 (text+ko) ====

@@ -43,17 +43,80 @@
 
 #include "assym.s"
 
+/*
+ * Software implementations of CCall, CReturn handlers for CHERI.
+ *
+ * The low-level CHERICCallVector exception handler, which has been relocated
+ * to the MIPS exception vector table, jumps to either CHERICCall or
+ * CHERICReturn running in the normal kernel address space.
+ *
+ * Notice that 'j' is used, implying that the kernel is in the 32-bit kernel
+ * segment so that the target fits in the available immediate -- this is also
+ * true of other FreeBSD exception handlers.
+ */
+
 	.set noreorder	/* Preserve nops, allow instructions in b-d slots. */
 
 /*
- * Software implementations of CCall, CReturn handlers for CHERI.
+ * CCall/CReturn low-level exception handler; this code must be position-
+ * independent, as it will be relocated into the vector table.
+ */
+VECTOR(CHERICCallVector, unknown)
+        .set push
+        .set noat
+        CHERI_EXCEPTION_ENTER(k0)
+
+	/*
+	 * Determine whether this is a CCall or CReturn instruction.
+	 *
+	 * XXXRW: Panic if CGetCause returns something other than CALL/RETURN.
+	 *
+	 * XXXRW: Panic if not entering from userspace.
+	 */
+	CGetCause	k0
+	andi		k0, k0, 0x1	/* CALL is odd; RETURN is even. */
+	beqz		k0, CReturn_label
+	nop		/* Branch-delay slot. */
+
+	j		CHERICCall
+	nop		/* Branch-delay slot. */
+
+CReturn_label:
+	j		CHERICReturn
+	nop		/* Branch-delay slot. */
+
+        .set pop
+VECTOR_END(CHERICCallVector)
+
+/*
+ * Software implementation of CCall; this code does not need to be position-
+ * independent.
+ *
+ * XXXRW: Gubbins missing.
+ */
+CHERICCall:
+        .set push
+        .set noat
+
+	/* XXXRW: For now, increment PC as though it were a no-op. */
+        MFC0	k0, MIPS_COP_0_EXC_PC
+	PTR_ADDU	k0, 4
+	MTC0	k0, MIPS_COP_0_EXC_PC
+	COP0_SYNC
+
+	CHERI_EXCEPTION_RETURN(k0)
+	eret
+        .set pop
+
+/*
+ * Software implementation of CReturn; this code does not need to be position-
+ * independent.
  *
  * XXXRW: Gubbins missing.
  */
-VECTOR(CHERICCallVector, unknown)
+CHERICReturn:
         .set push
         .set noat
-        CHERI_EXCEPTION_ENTER(k0)
 
 	/* XXXRW: For now, increment PC as though it were a no-op. */
         MFC0	k0, MIPS_COP_0_EXC_PC
@@ -64,4 +127,3 @@
 	CHERI_EXCEPTION_RETURN(k0)
 	eret
         .set pop
-VECTOR_END(CHERICCallVector)



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