-
Notifications
You must be signed in to change notification settings - Fork 56
Add Smstateen/Ssstateen Extension and CSRs #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ThinkOpenly
merged 49 commits into
riscv-software-src:main
from
neverlandiz:add-smstateen-sstateen
Jun 10, 2025
Merged
Changes from 2 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
6a3c81c
add smstateen/ssstateen CSRs
neverlandiz be264c6
Merge branch 'main' into add-smstateen-sstateen
neverlandiz f981030
lots of minor fixes
neverlandiz 4348f66
merging
neverlandiz f147046
merge
neverlandiz 601efbe
lots of backticks
neverlandiz a5108d2
minor fixes
neverlandiz 8bb0d30
modified descriptions
neverlandiz 0807a91
Merge branch 'main' into add-smstateen-sstateen
neverlandiz e5fa958
remove pre-commit-config.yaml from pr
neverlandiz fffabda
remove pre-commit file changes
neverlandiz daa12b4
Merge branch 'main' into add-smstateen-sstateen
neverlandiz 354ed45
add definedBy for fields
neverlandiz 9484789
add sw_write and sw_read for alias
neverlandiz 493e97c
add long names
neverlandiz 843c1c6
structured format descriptions
neverlandiz a3f75bb
finish adding structured format
neverlandiz f4c73f3
change mstateen* reset values to 0
neverlandiz de434ae
docs(stateen): comment out Zfinx & Zdinx code + add sw_read
neverlandiz d074a3e
docs(stateen): change C field description
neverlandiz 4321a85
Merge branch 'main' into add-smstateen-sstateen
neverlandiz efc3bff
docs(stateen): fix syntax errors
neverlandiz 659aa3a
docs(stateen): syntax
neverlandiz 405103b
docs(stateen): add sw_write for sstateen CSRs
neverlandiz 240b895
docs(stateen): add sw_write for hstateen* CSRs
neverlandiz 59a027a
Merge branch 'main' into add-smstateen-sstateen
neverlandiz 838355d
docs(stateen): syntax fixes
neverlandiz eb9b003
docs(stateen): syntax fixes
neverlandiz 5d4e1be
docs(stateen): more fixes
neverlandiz 3bc9359
docs(stateen): syntax fix
neverlandiz a439395
fix
neverlandiz 7dae65a
docs(stateen): add params to zcmt
neverlandiz a0d910c
docs(stateen): update fields based on newest specs
neverlandiz a73ea8e
docs(stateen): fix sw_write
neverlandiz c14d794
docs(stateen): add params for ext files
neverlandiz 7c06ae7
docs(stateen): sw_write fixes
neverlandiz c7bba1d
docs(stateen): add definedBy for some fields
neverlandiz d565997
docs(stateen): syntax fixes
neverlandiz 5e290b6
Merge branch 'main' into add-smstateen-sstateen
neverlandiz db8de99
Merge branch 'main' into add-smstateen-sstateen
neverlandiz 0cb9aa9
docs(stateen): fix CI failures
neverlandiz cdc8c2e
Merge branch 'main' into add-smstateen-sstateen
neverlandiz 6fb0fe9
docs(mstateen0): typo fix
neverlandiz cc5c669
docs(mstateen0): typo fix
neverlandiz 780876d
docs(stateen): change MXLEN to 64
neverlandiz aef6da9
docs(stateen): fix base
neverlandiz b7e7f70
docs(zcmt): fix Zcmt typo
neverlandiz 3d63bb4
Merge branch 'main' into add-smstateen-sstateen
neverlandiz 3d57b11
fix(stateen): fix ruby code bug
neverlandiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen0 | ||
long_name: Hypervisor State Enable 0 Register | ||
address: 0x60C | ||
priv_mode: S | ||
length: 64 | ||
description: | | ||
For each hstateen CSR, bit 63 is defined to control access to the matching sstateen CSR. | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Bit 63 of hstateen0 controls access to sstateen0. | ||
|
||
With the hypervisor extension, the hstateen CSRs have identical encodings to the mstateen | ||
CSRs, except controlling accesses for a virtual machine (from VS and VU modes). | ||
|
||
For every bit in an hstateen CSR that is zero (whether read-only zero or set to zero), | ||
the same bit appears as read-only zero in sstateen when accessed in VS-mode. | ||
|
||
A bit in an hstateen CSR cannot be read-only one unless the same bit is read-only one | ||
in the matching mstateen CSR. | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
AFOliveira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Ssstateen | ||
fields: | ||
SEO: | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
location: 63 | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: | | ||
The SE0 bit in hstateen0 controls access to the sstateen0 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
ENVCFG: | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
location: 62 | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: | | ||
The ENVCFG bit in hstateen0 controls access to the senvcfg CSRs. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
CSRIND: | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
location: 60 | ||
description: | | ||
The CSRIND bit in hstateen0 controls access to the siselect and the | ||
sireg*, (really vsiselect and vsireg*) CSRs provided by the Sscsrind | ||
extensions. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
AIA: | ||
location: 59 | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: | | ||
The AIA bit in hstateen0 controls access to all state introduced by | ||
the Ssaia extension and is not controlled by either the CSRIND or the | ||
IMSIC bits of hstateen0. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
IMSIC: | ||
location: 58 | ||
description: | | ||
The IMSIC bit in hstateen0 controls access to the guest IMSIC state, | ||
including CSRs stopei (really vstopei), provided by the Ssaia extension. | ||
|
||
Setting the IMSIC bit in hstateen0 to zero prevents a virtual machine | ||
from accessing the hart’s IMSIC the same as setting `hstatus.`VGEIN = 0. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
CONTEXT: | ||
location: 57 | ||
description: | | ||
The CONTEXT bit in hstateen0 controls access to the scontext CSR provided | ||
by the Sdtrig extension. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
JVT: | ||
location: 2 | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: | | ||
The JVT bit controls access to the jvt CSR provided by the Zcmt extension. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
FCSR: | ||
location: 1 | ||
description: | | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The FCSR bit controls access to fcsr for the case when floating-point instructions | ||
operate on x registers instead of f registers as specified by the Zfinx and related | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extensions (Zdinx, etc.). Whenever misa.F = 1, FCSR bit of mstateen0 is read-only | ||
zero (and hence read-only zero in hstateen0 and sstateen0 too). For convenience, | ||
when the stateen CSRs are implemented and misa.F = 0, then if the FCSR bit of a | ||
controlling stateen0 CSR is zero, all floating-point instructions cause an illegal | ||
instruction trap (or virtual instruction trap, if relevant), as though they all access | ||
fcsr, regardless of whether they really do. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
C: | ||
location: 0 | ||
description: | | ||
The C bit controls access to any and all custom state. This bit is not custom state itself. | ||
The C bit of these registers is not custom state itself; it is a standard field of a | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
standard CSR, either mstateen0, hstateen0, or sstateen0. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL |
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen0h | ||
long_name: Upper 32 bits of Hypervisor State Enable 0 Register | ||
address: 0x61C | ||
priv_mode: S | ||
length: 32 | ||
description: | | ||
For RV64 harts, the Smstateen/Ssstateen extension adds four new 64-bit CSRs at machine level: mstateen0 (Machine State Enable 0), | ||
mstateen1, mstateen2, and mstateen3. If supervisor mode is implemented, another four CSRs are defined at | ||
supervisor level: sstateen0, sstateen1, sstateen2, and sstateen3. And if the hypervisor extension is implemented, | ||
another set of CSRs is added: hstateen0, hstateen1, hstateen2, and hstateen3. | ||
|
||
For RV32, the registers listed above are 32-bit, and for the machine-level and hypervisor CSRs there is a corresponding | ||
set of high-half CSRs for the upper 32 bits of each register: mstateen0h, mstateen1h, mstateen2h, mstateen3h, hstateen0h, | ||
hstateen1h, hstateen2h, and hstateen3h. | ||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
- Ssstateen | ||
fields: | ||
SEO: | ||
location: 31 | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: | | ||
The SE0 bit in hstateen0h controls access to the sstateen0 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
ENVCFG: | ||
location: 30 | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: | | ||
The ENVCFG bit in hstateen0h controls access to the senvcfg CSRs. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
CSRIND: | ||
location: 28 | ||
description: | | ||
The CSRIND bit in hstateen0h controls access to the siselect and the | ||
sireg*, (really vsiselect and vsireg*) CSRs provided by the Sscsrind | ||
extensions. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
AIA: | ||
location: 27 | ||
description: | | ||
The AIA bit in hstateen0h controls access to all state introduced by | ||
the Ssaia extension and is not controlled by either the CSRIND or the | ||
IMSIC bits of hstateen0. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
IMSIC: | ||
location: 26 | ||
description: | | ||
The IMSIC bit in hstateen0h controls access to the guest IMSIC state, | ||
including CSRs stopei (really vstopei), provided by the Ssaia extension. | ||
|
||
Setting the IMSIC bit in hstateen0h to zero prevents a virtual machine | ||
from accessing the hart’s IMSIC the same as setting `hstatus.`VGEIN = 0. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
CONTEXT: | ||
location: 25 | ||
description: | | ||
The CONTEXT bit in hstateen0h controls access to the scontext CSR provided | ||
by the Sdtrig extension. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen1 | ||
long_name: Hypervisor State Enable 1 Register | ||
address: 0x60D | ||
priv_mode: S | ||
length: 64 | ||
description: | | ||
For each hstateen CSR, bit 63 is defined to control access to the matching sstateen CSR. | ||
Bit 63 of hstateen1 controls access to sstateen1. | ||
|
||
With the hypervisor extension, the hstateen CSRs have identical encodings to the mstateen | ||
CSRs, except controlling accesses for a virtual machine (from VS and VU modes). | ||
|
||
For every bit in an hstateen CSR that is zero (whether read-only zero or set to zero), | ||
the same bit appears as read-only zero in sstateen when accessed in VS-mode. | ||
|
||
A bit in an hstateen CSR cannot be read-only one unless the same bit is read-only one | ||
in the matching mstateen CSR. | ||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
- Ssstateen | ||
fields: | ||
SEO: | ||
location: 63 | ||
description: | | ||
The SE0 bit in hstateen1 controls access to the sstateen1 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen1h | ||
long_name: Upper 32 bits of Hypervisor State Enable 1 Register | ||
address: 0x61D | ||
priv_mode: S | ||
length: 32 | ||
description: | | ||
For RV64 harts, the Smstateen/Ssstateen extension adds four new 64-bit CSRs at machine level: mstateen0 (Machine State Enable 0), | ||
mstateen1, mstateen2, and mstateen3. If supervisor mode is implemented, another four CSRs are defined at | ||
supervisor level: sstateen0, sstateen1, sstateen2, and sstateen3. And if the hypervisor extension is implemented, | ||
another set of CSRs is added: hstateen0, hstateen1, hstateen2, and hstateen3. | ||
|
||
For RV32, the registers listed above are 32-bit, and for the machine-level and hypervisor CSRs there is a corresponding | ||
set of high-half CSRs for the upper 32 bits of each register: mstateen0h, mstateen1h, mstateen2h, mstateen3h, hstateen0h, | ||
hstateen1h, hstateen2h, and hstateen3h. | ||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
- Ssstateen | ||
fields: | ||
SEO: | ||
location: 31 | ||
description: | | ||
The SE0 bit in hstateen1h controls access to the sstateen1 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen2 | ||
long_name: Hypervisor State Enable 2 Register | ||
address: 0x60E | ||
priv_mode: S | ||
length: 64 | ||
description: | | ||
For each hstateen CSR, bit 63 is defined to control access to the matching sstateen CSR. | ||
Bit 63 of hstateen2 controls access to sstateen2. | ||
|
||
With the hypervisor extension, the hstateen CSRs have identical encodings to the mstateen | ||
CSRs, except controlling accesses for a virtual machine (from VS and VU modes). | ||
|
||
For every bit in an hstateen CSR that is zero (whether read-only zero or set to zero), | ||
the same bit appears as read-only zero in sstateen when accessed in VS-mode. | ||
|
||
A bit in an hstateen CSR cannot be read-only one unless the same bit is read-only one | ||
in the matching mstateen CSR. | ||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
- Ssstateen | ||
fields: | ||
SEO: | ||
location: 63 | ||
description: | | ||
The SE0 bit in hstateen2 controls access to the sstateen2 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen2h | ||
long_name: Upper 32 bits of Hypervisor State Enable 2 Register | ||
address: 0x61E | ||
priv_mode: S | ||
length: 32 | ||
description: | | ||
For RV64 harts, the Smstateen/Ssstateen extension adds four new 64-bit CSRs at machine level: mstateen0 (Machine State Enable 0), | ||
mstateen1, mstateen2, and mstateen3. If supervisor mode is implemented, another four CSRs are defined at | ||
supervisor level: sstateen0, sstateen1, sstateen2, and sstateen3. And if the hypervisor extension is implemented, | ||
another set of CSRs is added: hstateen0, hstateen1, hstateen2, and hstateen3. | ||
|
||
For RV32, the registers listed above are 32-bit, and for the machine-level and hypervisor CSRs there is a corresponding | ||
set of high-half CSRs for the upper 32 bits of each register: mstateen0h, mstateen1h, mstateen2h, mstateen3h, hstateen0h, | ||
hstateen1h, hstateen2h, and hstateen3h. | ||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
- Ssstateen | ||
fields: | ||
SEO: | ||
location: 31 | ||
description: | | ||
The SE0 bit in hstateen2h controls access to the sstateen2 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen3 | ||
long_name: Hypervisor State Enable 3 Register | ||
address: 0x60F | ||
priv_mode: S | ||
length: 64 | ||
description: | | ||
For each hstateen CSR, bit 63 is defined to control access to the matching sstateen CSR. | ||
Bit 63 of hstateen3 controls access to sstateen3. | ||
|
||
With the hypervisor extension, the hstateen CSRs have identical encodings to the mstateen | ||
CSRs, except controlling accesses for a virtual machine (from VS and VU modes). | ||
|
||
For every bit in an hstateen CSR that is zero (whether read-only zero or set to zero), | ||
the same bit appears as read-only zero in sstateen when accessed in VS-mode. | ||
|
||
A bit in an hstateen CSR cannot be read-only one unless the same bit is read-only one | ||
in the matching mstateen CSR. | ||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
- Ssstateen | ||
fields: | ||
SEO: | ||
location: 63 | ||
description: | | ||
The SE0 bit in hstateen3 controls access to the sstateen3 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: hstateen3h | ||
long_name: Upper 32 bits of Hypervisor State Enable 3 Register | ||
address: 0x61F | ||
priv_mode: S | ||
length: 32 | ||
description: | | ||
For RV64 harts, the Smstateen/Ssstateen extension adds four new 64-bit CSRs at machine level: mstateen0 (Machine State Enable 0), | ||
mstateen1, mstateen2, and mstateen3. If supervisor mode is implemented, another four CSRs are defined at | ||
supervisor level: sstateen0, sstateen1, sstateen2, and sstateen3. And if the hypervisor extension is implemented, | ||
another set of CSRs is added: hstateen0, hstateen1, hstateen2, and hstateen3. | ||
|
||
For RV32, the registers listed above are 32-bit, and for the machine-level and hypervisor CSRs there is a corresponding | ||
set of high-half CSRs for the upper 32 bits of each register: mstateen0h, mstateen1h, mstateen2h, mstateen3h, hstateen0h, | ||
hstateen1h, hstateen2h, and hstateen3h. | ||
|
||
definedBy: | ||
allOf: | ||
- H | ||
- Smstateen | ||
- Ssstateen | ||
fields: | ||
SEO: | ||
location: 31 | ||
description: | | ||
The SE0 bit in hstateen3h controls access to the sstateen3 CSR. | ||
type: RW | ||
reset_value: UNDEFINED_LEGAL |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.