PERFORCE change 219580 for review
Robert Watson
rwatson at FreeBSD.org
Mon Nov 5 00:05:29 UTC 2012
http://p4web.freebsd.org/@@219580?ac=10
Change 219580 by rwatson at rwatson_svr_ctsrd_mipsbuild on 2012/11/05 00:05:07
Trim the set of registers printed by "cheritest listregs" to omit
kernel-reserved registers (which are no longer accessible), and
add a new "overrun" command that intentionally exceeds the length
of memory capability during a store operation. Also print out tag
information for capabilities when listing them.
Affected files ...
.. //depot/projects/ctsrd/cheribsd/src/bin/cheritest/cheritest.c#4 edit
Differences ...
==== //depot/projects/ctsrd/cheribsd/src/bin/cheritest/cheritest.c#4 (text+ko) ====
@@ -40,13 +40,21 @@
#include <unistd.h>
#define CHERI_CAPREG_PRINT(crn) do { \
- struct chericap c; \
+ register_t c_tag; \
+ register_t c_unsealed, c_perms, c_otype, c_base, c_length; \
+ \
+ CHERI_CGETTAG(c_tag, (crn)); \
+ CHERI_CGETUNSEALED(c_unsealed, (crn)); \
+ CHERI_CGETPERM(c_perms, (crn)); \
+ CHERI_CGETBASE(c_base, (crn)); \
+ CHERI_CGETTYPE(c_otype, (crn)); \
+ CHERI_CGETLEN(c_length, (crn)); \
\
- CHERI_GETCAPREG((crn), c); \
- printf("C%u perms %04jx type %016jx\n", crn, \
- (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); \
+ printf("C%u tag %u u %u perms %04jx type %016jx\n", crn, \
+ (u_int)c_tag, (u_int)c_unsealed, \
+ (uintmax_t)c_perms, (uintmax_t)c_otype); \
+ printf("\tbase %016jx length %016jx\n", (uintmax_t)c_base, \
+ (uintmax_t)c_length); \
} while (0)
static void
@@ -55,11 +63,26 @@
fprintf(stderr, "cheritest copyregs\n");
fprintf(stderr, "cheritest listregs\n");
+ fprintf(stderr, "cheritest overrun\n");
fprintf(stderr, "cheritest sleep\n");
exit(EX_USAGE);
}
static void
+cheritest_overrun(void)
+{
+
+ /* Move a copy of $c0 into $c1. */
+ CHERI_CMOVE(1, 0);
+
+ /* Restrict segment length to 0. */
+ CHERI_CSETLEN(1, 1, 0);
+
+ /* Perform a byte store operation via $c1. */
+ CHERI_CSB(0, 0, 0, 1);
+}
+
+static void
cheritest_copyregs(void)
{
@@ -108,11 +131,6 @@
CHERI_CAPREG_PRINT(24);
CHERI_CAPREG_PRINT(25);
CHERI_CAPREG_PRINT(26);
- CHERI_CAPREG_PRINT(27);
- CHERI_CAPREG_PRINT(28);
- CHERI_CAPREG_PRINT(29);
- CHERI_CAPREG_PRINT(30);
- CHERI_CAPREG_PRINT(31);
}
int
@@ -136,6 +154,8 @@
cheritest_listregs();
else if (strcmp(argv[0], "copyregs") == 0)
cheritest_copyregs();
+ else if (strcmp(argv[0], "overrun") == 0)
+ cheritest_overrun();
else if (strcmp(argv[0], "sleep") == 0)
sleep(10);
else
More information about the p4-projects
mailing list