PERFORCE change 730135 for review
Robert Watson
rwatson at FreeBSD.org
Mon Sep 16 18:06:25 UTC 2013
http://p4web.freebsd.org/@@730135?ac=10
Change 730135 by rwatson at 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)
/*
More information about the p4-projects
mailing list