Patrick Georgi merged this change.

View Change

Approvals: build bot (Jenkins): Verified Jonathan Neuschäfer: Looks good to me, approved
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>
---
M src/arch/riscv/include/vm.h
1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/arch/riscv/include/vm.h b/src/arch/riscv/include/vm.h
index a30d6bb..749c9c8 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 @@
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_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_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

To view, visit change 28394. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I19519782fe791982a8fbd48ef33b5a92a3c48bfc
Gerrit-Change-Number: 28394
Gerrit-PatchSet: 4
Gerrit-Owner: Xiang Wang <wxjstz@126.com>
Gerrit-Reviewer: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: Philipp Hug <philipp@hug.cx>
Gerrit-Reviewer: Shawn Chang <citypw@gmail.com>
Gerrit-Reviewer: Xiang Wang <wxjstz@126.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>