aboutsummaryrefslogtreecommitdiff
path: root/pk/pcr.h
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2013-07-13 21:43:57 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2013-07-13 21:44:16 -0700
commitcc72987e655578b0529b6c3c8084e810cf40b358 (patch)
treea7a99a9406dfef2d4103e85bc0976cb8d039d7e7 /pk/pcr.h
parent0bdb8c84092bf7c5eb4c981c620997a5893bfb70 (diff)
downloadpk-cc72987e655578b0529b6c3c8084e810cf40b358.zip
pk-cc72987e655578b0529b6c3c8084e810cf40b358.tar.gz
pk-cc72987e655578b0529b6c3c8084e810cf40b358.tar.bz2
Support Linux ABI and (optionally) virtual memory
Diffstat (limited to 'pk/pcr.h')
-rw-r--r--pk/pcr.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/pk/pcr.h b/pk/pcr.h
index cc78f2f..9fea232 100644
--- a/pk/pcr.h
+++ b/pk/pcr.h
@@ -64,6 +64,16 @@
#ifdef __riscv
+#ifdef __riscv64
+# define RISCV_PGLEVELS 3
+# define RISCV_PGSHIFT 13
+#else
+# define RISCV_PGLEVELS 2
+# define RISCV_PGSHIFT 12
+#endif
+#define RISCV_PGLEVEL_BITS 10
+#define RISCV_PGSIZE (1 << RISCV_PGSHIFT)
+
#define ASM_CR(r) _ASM_CR(r)
#define _ASM_CR(r) cr##r
@@ -85,6 +95,10 @@
asm volatile ("clearpcr %0,cr%2,%1" : "=r"(__tmp) : "i"(val), "i"(reg)); \
__tmp; })
+#define rdcycle() ({ unsigned long __tmp; \
+ asm volatile ("rdcycle %0" : "=r"(__tmp)); \
+ __tmp; })
+
#endif
#endif