Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Sep 2013 18:06:24 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 730135 for review
Message-ID:  <201309161806.r8GI6OSg078198@skunkworks.freebsd.org>

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

Change 730135 by rwatson@rwatson_zenith_cl_cam_ac_uk on 2013/09/16 18:05:52

	Rework a number of sealing/unsealing/call/return assembly macros
	in CheriBSD:
	
	- Add missing CHERI_CSEALCODE() macro.
	- Do use memory clobbers for $c0 sealing/unsealing.
	- Do use memory clobbers for CCALL, CRETURN.

Affected files ...

.. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#22 edit

Differences ...

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

@@ -149,29 +149,47 @@
 } while (0)
 
 /*
- * Instructions to seal and unseal capabilities.
+ * Instructions relating to capability invocation, return, sealing, and
+ * unsealing.  Memory clobbers are required for register manipulation when
+ * targeting $c0.  They are also required for both CCall and CReturn to ensure
+ * that any memory write-back is done before invocation.
+ *
+ * XXXRW: Is the latter class of cases required?
  */
+#define	CHERI_CSEALCODE(cd, cs) do {					\
+	if ((cd) == 0)							\
+		__asm__ __volatile__ ("csealcode $c%0, $c%1" : :	\
+		    "i" (cd), "i" (cs) : "memory");			\
+	else								\
+		__asm__ __volatile__ ("csealcode $c%0, $c%1" : :	\
+		    "i" (cd), "i" (cs));				\
+} while (0)
+
 #define CHERI_CSEALDATA(cd, cs, ct) do {				\
-	__asm__ __volatile__ ("csealdata $c%0, $c%1, $c%2" : :		\
+	if ((cd) == 0)							\
+		__asm__ __volatile__ ("csealdata $c%0, $c%1, $c%2" : :	\
+		    "i" (cd), "i" (cs), "i" (ct) : "memory");		\
+	else								\
+		__asm__ __volatile__ ("csealdata $c%0, $c%1, $c%2" : :	\
 		    "i" (cd), "i" (cs), "i" (ct));			\
 } while (0)
 
-#define CHERI_CUNSEAL(cd, cs, ct) do {					\
-	__asm__ __volatile__ ("cunseal $c%0, $c%1, $c%2" : :		\
-		    "i" (cd), "i" (cs), "i" (ct));			\
+#define CHERI_CUNSEAL(cd, cb, ct) do {					\
+	if ((cd) == 0)							\
+		__asm__ __volatile__ ("cunseal $c%0, $c%1, $c%2" : :	\
+		    "i" (cd), "i" (cb), "i" (ct) : "memory");		\
+	else								\
+		__asm__ __volatile__ ("cunseal $c%0, $c%1, $c%2" : :	\
+		    "i" (cd), "i" (cb), "i" (ct));			\
 } while (0)
 
-/*
- * Routines associated with CHERI object-capability invocation; currently we
- * believe these require no clobbers, as they don't directly replace c0.
- */
 #define	CHERI_CCALL(cs, cb) do {					\
 	__asm__ __volatile__ ("ccall $c%0, $c%1" : :			\
-	    "i" (cs), "i" (cb));					\
+	    "i" (cs), "i" (cb) : "memory");				\
 } while (0)
 
 #define	CHERI_CRETURN() do {						\
-	__asm__ __volatile__ ("creturn");				\
+	__asm__ __volatile__ ("creturn" : : : "memory");		\
 } while (0)
 
 /*



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