-
Machine Security Configuration (mseccfg) is a new RW Machine mode CSR, used for configuring various security mechanisms present on the hart, and only accessible to Machine mode. It is 64 bits wide, and is at address 0x747 on RV64 and 0x747 (low 32bits), 0x757 (high 32bits) on RV32. All mseccfg fields defined on this proposal are WARL, and the remaining bits are reserved for future standard use and should always read zero. The reset value of mseccfg is implementation-specific, otherwise if backwards compatibility is a requirement it should reset to zero on hard reset.
-
On
mseccfg
we introduce a field on bit 2 called Rule Locking Bypass (mseccfg.RLB) with the following functionality:-
When
mseccfg.RLB
is 1 locked PMP rules may be removed/modified and locked PMP entries may be edited. -
When
mseccfg.RLB
is 0 andpmpcfg.L
is 1 in any rule or entry (including disabled entries), thenmseccfg.RLB
remains 0 and any further modifications tomseccfg.RLB
are ignored until a PMP reset.CautionNote that this feature is intended to be used as a debug mechanism, or as a temporary workaround during the boot process for simplifying software, and optimizing the allocation of memory and PMP rules. Using this functionality under normal operation, after the boot process is completed, should be avoided since it weakens the protection of M-mode-only rules. Vendors who don’t need this functionality may hardwire this field to 0.
-
-
On
mseccfg
we introduce a field in bit 1 called Machine Mode Whitelist Policy (mseccfg.MMWP). This is a sticky bit, meaning that once set it cannot be unset until a PMP reset. When set it changes the default PMP policy for M-mode when accessing memory regions that don’t have a matching PMP rule, to denied instead of ignored. -
On
mseccfg
we introduce a field in bit 0 called Machine Mode Lockdown (mseccfg.MML). This is a sticky bit, meaning that once set it cannot be unset until a PMP reset. Whenmseccfg.MML
is set the system’s behavior changes in the following way:-
The meaning of
pmpcfg.L
changes: Instead of marking a rule as locked and enforced in all modes, it now marks a rule as M-mode-only when set and S/U-mode-only when unset. The formerly reserved encoding ofpmpcfg.RW=01
, and the encodingpmpcfg.LRWX=1111
, now encode a Shared-Region.An M-mode-only rule is enforced on Machine mode and denied in Supervisor or User mode. It also remains locked so that any further modifications to its associated configuration or address registers are ignored until a PMP reset, unless
mseccfg.RLB
is set.An S/U-mode-only rule is enforced on Supervisor and User modes and denied on Machine mode.
A Shared-Region rule is enforced on all modes, with restrictions depending on the
pmpcfg.L
andpmpcfg.X
bits:-
A Shared-Region rule where
pmpcfg.L
is not set can be used for sharing data between M-mode and S/U-mode, so is not executable. M-mode has read/write access to that region, and S/U-mode has read access ifpmpcfg.X
is not set, or read/write access ifpmpcfg.X
is set. -
A Shared-Region rule where
pmpcfg.L
is set can be used for sharing code between M-mode and S/U-mode, so is not writeable. Both M-mode and S/U-mode have execute access on the region, and M-mode also has read access ifpmpcfg.X
is set. The rule remains locked so that any further modifications to its associated configuration or address registers are ignored until a PMP reset, unlessmseccfg.RLB
is set. -
The encoding
pmpcfg.LRWX=1111
can be used for sharing data between M-mode and S/U mode, where both modes only have read-only access to the region. The rule remains locked so that any further modifications to its associated configuration or address registers are ignored until a PMP reset, unlessmseccfg.RLB
is set.
-
-
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, leavingpmpcfg
unchanged. This restriction can be temporarily lifted by settingmseccfg.RLB
e.g. during the boot process. -
Executing code with Machine mode privileges is only possible from memory regions with a matching M-mode-only rule or a locked Shared-Region rule with executable privileges. Executing code from a region without a matching rule or with a matching S/U-mode-only rule is denied.
-
If
mseccfg.MML
is not set, the combination ofpmpcfg.RW=01
remains reserved for future standard use.
-
Bits on pmpcfg register | Result | ||||
---|---|---|---|---|---|
L |
R |
W |
X |
M Mode |
S/U Mode |
0 |
0 |
0 |
0 |
Inaccessible region (Access Exception) |
|
0 |
0 |
0 |
1 |
Access Exception |
Execute-only region |
0 |
0 |
1 |
0 |
Shared data region: Read/write on M mode, read-only on S/U mode |
|
0 |
0 |
1 |
1 |
Shared data region: Read/write for both M and S/U mode |
|
0 |
1 |
0 |
0 |
Access Exception |
Read-only region |
0 |
1 |
0 |
1 |
Access Exception |
Read/Execute region |
0 |
1 |
1 |
0 |
Access Exception |
Read/Write region |
0 |
1 |
1 |
1 |
Access Exception |
Read/Write/Execute region |
1 |
0 |
0 |
0 |
Locked inaccessible region* (Access Exception) |
|
1 |
0 |
0 |
1 |
Locked Execute-only region* |
Access Exception |
1 |
0 |
1 |
0 |
Locked Shared code region: Execute only on both M and S/U mode.* |
|
1 |
0 |
1 |
1 |
Locked Shared code region: Execute only on S/U mode, read/execute on M mode.* |
|
1 |
1 |
0 |
0 |
Locked Read-only region* |
Access Exception |
1 |
1 |
0 |
1 |
Locked Read/Execute region* |
Access Exception |
1 |
1 |
1 |
0 |
Locked Read/Write region* |
Access Exception |
1 |
1 |
1 |
1 |
Locked Shared data region: Read only on both M and S/U mode.* |
: *Locked rules cannot be removed or modified until a PMP reset, unless mseccfg.RLB
is set.
Since all fields defined on mseccfg
as part of this proposal are locked when set (MMWP
/MML
) or locked when cleared (RLB
), software can’t poll them for determining the presence of Smepmp. It is expected that BootROM will set mseccfg.MMWP
and/or mseccfg.MML
during early boot, before jumping to the firmware, so that the firmware will be able to determine the presence of Smepmp by reading mseccfg
and checking the state of mseccfg.MMWP
and mseccfg.MML
.