summaryrefslogtreecommitdiff
path: root/src/arch/riscv/include
diff options
context:
space:
mode:
authorXiang Wang <wxjstz@126.com>2018-08-30 13:47:12 +0800
committerPatrick Georgi <pgeorgi@google.com>2018-09-04 12:35:29 +0000
commit33354ddaa8bf067b86e283814fc3f03a02b1dfe5 (patch)
tree7ef0c162169e5c146a44265d7a87bf5a1e94d472 /src/arch/riscv/include
parentfb758d420bb96f01fd818ea77975cfedb933114e (diff)
downloadcoreboot-33354ddaa8bf067b86e283814fc3f03a02b1dfe5.tar.xz
riscv: Add DEFINE_MPRV_READ_MXR to read execution-only page
Must to set MXR, when needs to read the page which is execution-only. So make this change. Change-Id: I19519782fe791982a8fbd48ef33b5a92a3c48bfc Signed-off-by: Xiang Wang <wxjstz@126.com> Reviewed-on: https://review.coreboot.org/28394 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Diffstat (limited to 'src/arch/riscv/include')
-rw-r--r--src/arch/riscv/include/vm.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/arch/riscv/include/vm.h b/src/arch/riscv/include/vm.h
index a30d6bbdd5..749c9c86bf 100644
--- a/src/arch/riscv/include/vm.h
+++ b/src/arch/riscv/include/vm.h
@@ -38,11 +38,11 @@
void mstatus_init(void); // need to setup mstatus so we know we have virtual memory
-#define DEFINE_MPRV_READ(name, type, insn) \
+#define DEFINE_MPRV_READ_FLAGS(name, type, insn, flags) \
static inline type name(type *p); \
static inline type name(type *p) \
{ \
- size_t mprv = MSTATUS_MPRV; \
+ size_t mprv = flags; \
type value; \
asm ( \
"csrs mstatus, %1\n" \
@@ -53,6 +53,12 @@ void mstatus_init(void); // need to setup mstatus so we know we have virtual mem
return value; \
}
+#define DEFINE_MPRV_READ(name, type, insn) \
+ DEFINE_MPRV_READ_FLAGS(name, type, insn, MSTATUS_MPRV)
+
+#define DEFINE_MPRV_READ_MXR(name, type, insn) \
+ DEFINE_MPRV_READ_FLAGS(name, type, insn, MSTATUS_MPRV | MSTATUS_MXR)
+
#define DEFINE_MPRV_WRITE(name, type, insn) \
static inline void name(type *p, type value); \
static inline void name(type *p, type value) \
@@ -83,6 +89,12 @@ DEFINE_MPRV_READ(mprv_read_u32, uint32_t, lwu)
DEFINE_MPRV_READ(mprv_read_u64, uint64_t, ld)
DEFINE_MPRV_READ(mprv_read_long, long, ld)
DEFINE_MPRV_READ(mprv_read_ulong, unsigned long, ld)
+DEFINE_MPRV_READ_MXR(mprv_read_mxr_u8, uint8_t, lbu)
+DEFINE_MPRV_READ_MXR(mprv_read_mxr_u16, uint16_t, lhu)
+DEFINE_MPRV_READ_MXR(mprv_read_mxr_u32, uint32_t, lwu)
+DEFINE_MPRV_READ_MXR(mprv_read_mxr_u64, uint64_t, ld)
+DEFINE_MPRV_READ_MXR(mprv_read_mxr_long, long, ld)
+DEFINE_MPRV_READ_MXR(mprv_read_mxr_ulong, unsigned long, ld)
DEFINE_MPRV_WRITE(mprv_write_u8, uint8_t, sb)
DEFINE_MPRV_WRITE(mprv_write_u16, uint16_t, sh)
DEFINE_MPRV_WRITE(mprv_write_u32, uint32_t, sw)
@@ -90,8 +102,9 @@ DEFINE_MPRV_WRITE(mprv_write_u64, uint64_t, sd)
DEFINE_MPRV_WRITE(mprv_write_long, long, sd)
DEFINE_MPRV_WRITE(mprv_write_ulong, unsigned long, sd)
+#undef DEFINE_MPRV_READ_FLAGS
#undef DEFINE_MPRV_READ
+#undef DEFINE_MPRV_READ_MXR
#undef DEFINE_MPRV_WRITE
-
#endif