Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions disasm/isa_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
extension_table[EXT_SMEPMP] = true;
} else if (ext_str == "smstateen") {
extension_table[EXT_SMSTATEEN] = true;
} else if (ext_str == "smpmpmt") {
extension_table[EXT_SMPMPMT] = true;
} else if (ext_str == "smrnmi") {
extension_table[EXT_SMRNMI] = true;
} else if (ext_str == "sscofpmf") {
Expand Down
8 changes: 7 additions & 1 deletion riscv/csrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ bool pmpcfg_csr_t::unlogged_write(const reg_t val) noexcept {
if (i < proc->n_pmp) {
const bool locked = (state->pmpaddr[i]->cfg & PMP_L);
if (rlb || !locked) {
uint8_t cfg = (val >> (8 * (i - i0))) & (PMP_R | PMP_W | PMP_X | PMP_A | PMP_L);
uint8_t all_cfg_fields = (PMP_R | PMP_W | PMP_X | PMP_A |
(proc->extension_enabled(EXT_SMPMPMT) ? PMP_MT : 0) |
PMP_L);
uint8_t cfg = (val >> (8 * (i - i0))) & all_cfg_fields;
// Drop R=0 W=1 when MML = 0
// Remove the restriction when MML = 1
if (!mml) {
Expand All @@ -258,6 +261,9 @@ bool pmpcfg_csr_t::unlogged_write(const reg_t val) noexcept {
// Disallow A=NA4 when granularity > 4
if (proc->lg_pmp_granularity != PMP_SHIFT && (cfg & PMP_A) == PMP_NA4)
cfg |= PMP_NAPOT;
// MT value 0x3 is reserved
if (get_field(cfg, PMP_MT) == 0x3)
cfg = set_field(cfg, PMP_MT, 0);
/*
* Adding a rule with executable privileges that either is M-mode-only or a locked Shared-Region
* is not possible and such pmpcfg writes are ignored, leaving pmpcfg unchanged.
Expand Down
3 changes: 2 additions & 1 deletion riscv/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/*
* This file is auto-generated by running 'make' in
* https://github.com/riscv/riscv-opcodes (26e2c04)
* https://github.com/riscv/riscv-opcodes (56f9011)
*/

#ifndef RISCV_CSR_ENCODING_H
Expand Down Expand Up @@ -375,6 +375,7 @@
#define PMP_W 0x02
#define PMP_X 0x04
#define PMP_A 0x18
#define PMP_MT 0x60
#define PMP_L 0x80
#define PMP_SHIFT 2

Expand Down
1 change: 1 addition & 0 deletions riscv/isa_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef enum {
EXT_ZVFOFP8MIN,
EXT_SMEPMP,
EXT_SMSTATEEN,
EXT_SMPMPMT,
EXT_SMRNMI,
EXT_SSCOFPMF,
EXT_SVADU,
Expand Down
Loading