Skip to content

Commit 9565a26

Browse files
committed
Add smpmpmt extension
Signed-off-by: Binno <[email protected]>
1 parent 217cbc5 commit 9565a26

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

disasm/isa_parser.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
251251
extension_table[EXT_SMEPMP] = true;
252252
} else if (ext_str == "smstateen") {
253253
extension_table[EXT_SMSTATEEN] = true;
254+
} else if (ext_str == "smpmpmt") {
255+
extension_table[EXT_SMPMPMT] = true;
254256
} else if (ext_str == "smrnmi") {
255257
extension_table[EXT_SMRNMI] = true;
256258
} else if (ext_str == "sscofpmf") {

riscv/csrs.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ bool pmpcfg_csr_t::unlogged_write(const reg_t val) noexcept {
249249
if (i < proc->n_pmp) {
250250
const bool locked = (state->pmpaddr[i]->cfg & PMP_L);
251251
if (rlb || !locked) {
252-
uint8_t cfg = (val >> (8 * (i - i0))) & (PMP_R | PMP_W | PMP_X | PMP_A | PMP_L);
252+
uint8_t all_cfg_fields = (PMP_R | PMP_W | PMP_X | PMP_A |
253+
(proc->extension_enabled(EXT_SMPMPMT) ? PMP_MT : 0) |
254+
PMP_L);
255+
uint8_t cfg = (val >> (8 * (i - i0))) & all_cfg_fields;
253256
// Drop R=0 W=1 when MML = 0
254257
// Remove the restriction when MML = 1
255258
if (!mml) {
@@ -258,6 +261,9 @@ bool pmpcfg_csr_t::unlogged_write(const reg_t val) noexcept {
258261
// Disallow A=NA4 when granularity > 4
259262
if (proc->lg_pmp_granularity != PMP_SHIFT && (cfg & PMP_A) == PMP_NA4)
260263
cfg |= PMP_NAPOT;
264+
// MT value 0x3 is reserved
265+
if (get_field(cfg, PMP_MT) == 0x3)
266+
cfg = set_field(cfg, PMP_MT, 0);
261267
/*
262268
* Adding a rule with executable privileges that either is M-mode-only or a locked Shared-Region
263269
* is not possible and such pmpcfg writes are ignored, leaving pmpcfg unchanged.

riscv/encoding.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

1010
#ifndef RISCV_CSR_ENCODING_H
@@ -375,6 +375,7 @@
375375
#define PMP_W 0x02
376376
#define PMP_X 0x04
377377
#define PMP_A 0x18
378+
#define PMP_MT 0x60
378379
#define PMP_L 0x80
379380
#define PMP_SHIFT 2
380381

riscv/isa_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ typedef enum {
4040
EXT_ZVFOFP8MIN,
4141
EXT_SMEPMP,
4242
EXT_SMSTATEEN,
43+
EXT_SMPMPMT,
4344
EXT_SMRNMI,
4445
EXT_SSCOFPMF,
4546
EXT_SVADU,

0 commit comments

Comments
 (0)