aboutsummaryrefslogtreecommitdiff
path: root/pk/pcr.h
diff options
context:
space:
mode:
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