-
Notifications
You must be signed in to change notification settings - Fork 50
Add JVT CSR #782
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
Open
neverlandiz
wants to merge
18
commits into
riscv-software-src:main
Choose a base branch
from
neverlandiz:add-jvt-csr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add JVT CSR #782
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
289d758
docs(jvt): add jvt yaml file
neverlandiz 8e75447
docs(jvt): fix field location
neverlandiz 6e97e27
docs(jvt): add illegal instruction code
neverlandiz bc6445e
docs(jvt): fixing illegal instruction code
neverlandiz c0737a4
docs(jvt): add param for jvt RO
neverlandiz 48fa059
docs(jvt): fix CI failure
neverlandiz beadb2d
docs(jvt): add type() for MODE field
neverlandiz 2d70a5b
docs(jvt): add virtual-instruction trap
neverlandiz 7968ca8
Merge branch 'main' into add-jvt-csr
neverlandiz d4f370a
docs(jvt): fix CI failure
neverlandiz 22c75ec
fix(jvt): merge
neverlandiz dc67acd
fix(jvt): file directory fix
neverlandiz 939d6a0
fix(jvt): file directory fix
neverlandiz 7a44b90
Merge branch 'main' into add-jvt-csr
neverlandiz d19b787
fix(jvt): fix extension name
neverlandiz eb793da
fix: syntax fix
neverlandiz e3c25f2
docs(jvt): add sw_write for MODE
neverlandiz 7ba3f12
docs(jvt): minor fix
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,106 @@ | ||
# yaml-language-server: $schema=../../schemas/csr_schema.json | ||
|
||
$schema: "csr_schema.json#" | ||
kind: csr | ||
name: jvt | ||
long_name: Table Jump Base Vector and Control Register | ||
address: 0x017 | ||
description: | ||
- id: csr-jvt-purpose | ||
normative: true | ||
text: | | ||
The `jvt` register is an XLEN-bit WARL read/write register that holds the jump table configuration, | ||
consisting of the jump table base address (BASE) and the jump table mode (MODE). | ||
- id: csr-jvt-architectural | ||
normative: false | ||
text: | | ||
`jvt` CSR adds architectural state to the system software context (such as an OS process), therefore | ||
must be saved/restored on context switches. | ||
priv_mode: U | ||
length: XLEN | ||
definedBy: Zcmt | ||
fields: | ||
BASE: | ||
location_rv64: 63-6 | ||
location_rv32: 31-6 | ||
description: | | ||
The value in the BASE field must always be aligned on a 64-byte boundary. Note that the CSR contains only | ||
bits XLEN-1 through 6 of the address base. When computing jump-table accesses, the lower six bits of base | ||
are filled with zeroes to obtain an XLEN-bit jump-table base address `jvt.base` that is always aligned on a | ||
64-byte boundary. | ||
|
||
`jvt.base` is a virtual address, whenever virtual memory is enabled. | ||
|
||
The memory pointed to by `jvt.base` is treated as instruction memory for the purpose of executing table | ||
jump instructions, implying execute access permission. | ||
type(): | | ||
if (JVT_READ_ONLY) { | ||
return CsrFieldType::RO; | ||
} | ||
else { | ||
return CsrFieldType::RW; | ||
} | ||
reset_value: UNDEFINED_LEGAL | ||
sw_write(csr_value): | | ||
if ((mode() != PrivMode::M) && implemented?(ExtensionName::Smstateen)) { | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (CSR[mstateen0].JVT == 1'b0) { | ||
unimplemented_csr(); | ||
} | ||
} | ||
else if ((mode() == PrivMode::U) && implemented?(ExtensionName::Ssstaten)) { | ||
if (CSR[sstateen0].JVT == 1'b0) { | ||
unimplemented_csr(); | ||
} | ||
} | ||
else if ((mode() == PrivMode::VS) && implemented?(ExtensionName::Ssstaten)) { | ||
if (CSR[hstateen0].JVT == 1'b0) { | ||
unimplemented_csr(); | ||
} | ||
} | ||
else if ((mode() == PrivMode::VU) && implemented?(ExtensionName::Ssstateen)) { | ||
if ((CSR[sstateen0].JVT == 1'b0) || (CSR[hstateen0].JVT == 1'b0)) { | ||
unimplemented_csr(); | ||
} | ||
} | ||
else { | ||
if (JVT_BASE_TYPE == "custom") { | ||
unpredictable("jvt.BASE has custom behavior"); | ||
} else { | ||
return csr_value.BASE & (JVT_BASE_MASK >> 6); | ||
} | ||
return csr_value.BASE == 0 ? 0 : UNDEFINED_LEGAL_DETERMINISTIC; | ||
} | ||
MODE: | ||
location: 5-0 | ||
description: | | ||
`jvt.mode` is a WARL field, so can only be programmed to modes which are implemented. Therefore the | ||
discovery mechanism is to attempt to program different modes and read back the values to see which | ||
are available. Jump table mode must be implemented. | ||
type: RO | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
reset_value: 0 | ||
sw_read(): | | ||
# If the Smstateen extension is implemented, then bit 2 in `mstateen0`, `sstateen0`, and `hstateen0` is | ||
# implemented. If bit 2 of a controlling `stateen0` CSR is zero, then access to the `jvt` CSR and execution | ||
# of a `cm.jalt` or `cm.jt` instruction by a lower privilege level results in an illegal-instruction trap (or, if | ||
# appropriate, a virtual-instruction trap). | ||
ThinkOpenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if ((mode() != PrivMode::M) && implemented?(ExtensionName::Smstateen)) { | ||
if (CSR[mstateen0].JVT == 1'b0) { | ||
raise(ExceptionCode::IllegalInstruction, mode(), $encoding); | ||
} | ||
} | ||
else if ((mode() == PrivMode::U) && implemented?(ExtensionName::Ssstaten)) { | ||
if (CSR[sstateen0].JVT == 1'b0) { | ||
raise(ExceptionCode::IllegalInstruction, mode(), $encoding); | ||
} | ||
} | ||
else if ((mode() == PrivMode::VS) && implemented?(ExtensionName::Ssstaten)) { | ||
if (CSR[hstateen0].JVT == 1'b0) { | ||
raise(ExceptionCode::IllegalInstruction, mode(), $encoding); | ||
} | ||
} | ||
else if ((mode() == PrivMode::VU) && implemented?(ExtensionName::Ssstateen)) { | ||
if ((CSR[sstateen0].JVT == 1'b0) || (CSR[hstateen0].JVT == 1'b0)) { | ||
raise(ExceptionCode::IllegalInstruction, mode(), $encoding); | ||
} | ||
} |
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
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.