From 33354ddaa8bf067b86e283814fc3f03a02b1dfe5 Mon Sep 17 00:00:00 2001 From: Xiang Wang Date: Thu, 30 Aug 2018 13:47:12 +0800 Subject: [PATCH] riscv: Add DEFINE_MPRV_READ_MXR to read execution-only page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/28394 Tested-by: build bot (Jenkins) Reviewed-by: Jonathan Neuschäfer --- src/arch/riscv/include/vm.h | 19 ++++++++++++++++--- 1 file 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