From 289d7582bed48717d14f7a99062a9b98a4116793 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Mon, 19 May 2025 18:29:34 +0000 Subject: [PATCH 01/15] docs(jvt): add jvt yaml file --- arch/csr/jvt.yaml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 arch/csr/jvt.yaml diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml new file mode 100644 index 000000000..c4f0e120d --- /dev/null +++ b/arch/csr/jvt.yaml @@ -0,0 +1,46 @@ +# 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: RW + reset_value: UNDEFINED_LEGAL + MODE: + location_rv64: 5-0 + location_rv32: 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: RW + reset_value: UNDEFINED_LEGAL From 8e75447cf75f17827823cc6c65393de6dc53a48b Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Mon, 19 May 2025 18:37:43 +0000 Subject: [PATCH 02/15] docs(jvt): fix field location --- arch/csr/jvt.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml index c4f0e120d..e08005bab 100644 --- a/arch/csr/jvt.yaml +++ b/arch/csr/jvt.yaml @@ -36,8 +36,7 @@ fields: type: RW reset_value: UNDEFINED_LEGAL MODE: - location_rv64: 5-0 - location_rv32: 5-0 + 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 From 6e97e272fe2f88703ab01607daed1919973488eb Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Wed, 28 May 2025 05:49:02 +0000 Subject: [PATCH 03/15] docs(jvt): add illegal instruction code --- arch/csr/jvt.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml index e08005bab..3fc8ecaa3 100644 --- a/arch/csr/jvt.yaml +++ b/arch/csr/jvt.yaml @@ -35,6 +35,11 @@ fields: jump instructions, implying execute access permission. type: RW reset_value: UNDEFINED_LEGAL + sw_write(csr_value): | + if (implemented?(ExtensionName::Smstateen) && (CSR[mstateen0].JVT == 1'b0 || CSR[sstateen0].JVT == 1'b0 || CSR[hstateen0].JVT == 1'b0)) { + return ILLEGAL_WLRL; + } + return csr_value.BASE; MODE: location: 5-0 description: | @@ -43,3 +48,17 @@ fields: are available. Jump table mode must be implemented. type: RW reset_value: UNDEFINED_LEGAL + sw_write(csr_value): | + if (implemented?(ExtensionName::Smstateen) && (CSR[mstateen0].JVT == 1'b0 || CSR[sstateen0].JVT == 1'b0 || CSR[hstateen0].JVT == 1'b0)) { + return ILLEGAL_WLRL; + } + return csr_value.MODE; +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). + + if (implemented?(ExtensionName::Smstateen) && (CSR[mstateen0].JVT == 1'b0 || CSR[sstateen0].JVT == 1'b0 || CSR[hstateen0].JVT == 1'b0)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } From bc6445e5e140b6663de939250b8a1e2f3503d17a Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Tue, 3 Jun 2025 02:09:38 +0000 Subject: [PATCH 04/15] docs(jvt): fixing illegal instruction code --- arch/csr/jvt.yaml | 68 +++++++++++++++++++++++++++++++++++++--------- arch/ext/Zcmt.yaml | 20 ++++++++++++++ 2 files changed, 75 insertions(+), 13 deletions(-) diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml index 3fc8ecaa3..c715ca616 100644 --- a/arch/csr/jvt.yaml +++ b/arch/csr/jvt.yaml @@ -33,32 +33,74 @@ fields: 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: RW + type(): | + if (implemented?(ExtensionName::Zcmt)) { + return CsrFieldType::RO; + } + else { + return CsrFieldType::RW; + } reset_value: UNDEFINED_LEGAL sw_write(csr_value): | - if (implemented?(ExtensionName::Smstateen) && (CSR[mstateen0].JVT == 1'b0 || CSR[sstateen0].JVT == 1'b0 || CSR[hstateen0].JVT == 1'b0)) { - return ILLEGAL_WLRL; + if ((mode() != PrivMode::M) && implemented?(ExtensionName::Smstateen)) { + 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; } - return csr_value.BASE; 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: RW - reset_value: UNDEFINED_LEGAL - sw_write(csr_value): | - if (implemented?(ExtensionName::Smstateen) && (CSR[mstateen0].JVT == 1'b0 || CSR[sstateen0].JVT == 1'b0 || CSR[hstateen0].JVT == 1'b0)) { - return ILLEGAL_WLRL; - } - return csr_value.MODE; + type: RO + 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). - if (implemented?(ExtensionName::Smstateen) && (CSR[mstateen0].JVT == 1'b0 || CSR[sstateen0].JVT == 1'b0 || CSR[hstateen0].JVT == 1'b0)) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + 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); + } } diff --git a/arch/ext/Zcmt.yaml b/arch/ext/Zcmt.yaml index f3ed2357e..293954134 100644 --- a/arch/ext/Zcmt.yaml +++ b/arch/ext/Zcmt.yaml @@ -90,3 +90,23 @@ versions: # - [Zcb, "1.0.0"] # - [Zcmp, "1.0.0"] # - [Zcmt, "1.0.0"] + +params: + JVT_BASE_TYPE: + schema: + enum: [mask, custom] + description: | + Type of the jvt.BASE CSR field. One of: + + * mask: jvt.BASE contains one or more implemented bits, which are indicated by JVT_BASE_MASK. + * custom: Custom behavior. Will cause hart to enter 'unpredictable' state on a write to jvt.BASE. + JVT_BASE_MASK: + schema: + type: integer + minimum: 64 + maximum: 0x7ffffffffffffff # 58 bits + required_if(): return JVT_BASE_TYPE == "mask"; + description: | + Mask representing the implemented bits of jvt.BASE. Includes the implicitly-zero bits of jvt.BASE, so JVT_BASE_MASK[5:0] must always be 0. + extra_validation: | + assert JVT_BASE_MASK < 0xffffffc0 if MXLEN == 32 From c0737a4a4a41a3be0bcd46c8ea7d780827788dd5 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Tue, 3 Jun 2025 03:42:14 +0000 Subject: [PATCH 05/15] docs(jvt): add param for jvt RO --- arch/csr/jvt.yaml | 2 +- arch/ext/Zcmt.yaml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml index c715ca616..9db4f3cd6 100644 --- a/arch/csr/jvt.yaml +++ b/arch/csr/jvt.yaml @@ -34,7 +34,7 @@ fields: 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 (implemented?(ExtensionName::Zcmt)) { + if (JVT_READ_ONLY) { return CsrFieldType::RO; } else { diff --git a/arch/ext/Zcmt.yaml b/arch/ext/Zcmt.yaml index 293954134..1f3a11861 100644 --- a/arch/ext/Zcmt.yaml +++ b/arch/ext/Zcmt.yaml @@ -110,3 +110,8 @@ params: Mask representing the implemented bits of jvt.BASE. Includes the implicitly-zero bits of jvt.BASE, so JVT_BASE_MASK[5:0] must always be 0. extra_validation: | assert JVT_BASE_MASK < 0xffffffc0 if MXLEN == 32 + JVT_READ_ONLY: + schema: + type: boolean + description: | + If Zcmt is implemented, JVT is implemented, but can contain a read-only value From 48fa0599e6a8fd6e3ee6cec4df3aa1a598c6410c Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Tue, 3 Jun 2025 03:55:36 +0000 Subject: [PATCH 06/15] docs(jvt): fix CI failure --- arch/ext/Zcmt.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/ext/Zcmt.yaml b/arch/ext/Zcmt.yaml index 1f3a11861..738e15564 100644 --- a/arch/ext/Zcmt.yaml +++ b/arch/ext/Zcmt.yaml @@ -94,6 +94,7 @@ versions: params: JVT_BASE_TYPE: schema: + type: string enum: [mask, custom] description: | Type of the jvt.BASE CSR field. One of: From beadb2daf3c078f25454590bc32f6196f0aa957c Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Fri, 13 Jun 2025 17:03:12 +0000 Subject: [PATCH 07/15] docs(jvt): add type() for MODE field --- arch/csr/jvt.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml index 9db4f3cd6..e9f0f34bf 100644 --- a/arch/csr/jvt.yaml +++ b/arch/csr/jvt.yaml @@ -76,7 +76,13 @@ fields: `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 + type(): | + if (JVT_READ_ONLY) { + return CsrFieldType::RO; + } + else { + return CsrFieldType::RW; + } reset_value: 0 sw_read(): | # If the Smstateen extension is implemented, then bit 2 in `mstateen0`, `sstateen0`, and `hstateen0` is From 2d70a5b0bbf4e19d27d757365a633a79052693f3 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Fri, 13 Jun 2025 17:05:57 +0000 Subject: [PATCH 08/15] docs(jvt): add virtual-instruction trap --- arch/csr/jvt.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml index e9f0f34bf..a2239e478 100644 --- a/arch/csr/jvt.yaml +++ b/arch/csr/jvt.yaml @@ -92,7 +92,7 @@ sw_read(): | if ((mode() != PrivMode::M) && implemented?(ExtensionName::Smstateen)) { if (CSR[mstateen0].JVT == 1'b0) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } } else if ((mode() == PrivMode::U) && implemented?(ExtensionName::Ssstaten)) { @@ -102,11 +102,11 @@ sw_read(): | } else if ((mode() == PrivMode::VS) && implemented?(ExtensionName::Ssstaten)) { if (CSR[hstateen0].JVT == 1'b0) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + raise(ExceptionCode::VirtualInstruction, 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); + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } } From d4f370a209b0339675c4737890396de5d1638215 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Fri, 20 Jun 2025 15:05:45 +0000 Subject: [PATCH 09/15] docs(jvt): fix CI failure --- arch/csr/jvt.yaml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/csr/jvt.yaml b/arch/csr/jvt.yaml index a2239e478..e9508e1d0 100644 --- a/arch/csr/jvt.yaml +++ b/arch/csr/jvt.yaml @@ -1,3 +1,6 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + # yaml-language-server: $schema=../../schemas/csr_schema.json $schema: "csr_schema.json#" @@ -42,22 +45,22 @@ fields: } reset_value: UNDEFINED_LEGAL sw_write(csr_value): | - if ((mode() != PrivMode::M) && implemented?(ExtensionName::Smstateen)) { + if ((mode() != PrivilegeMode::M) && implemented?(ExtensionName::Smstateen)) { if (CSR[mstateen0].JVT == 1'b0) { unimplemented_csr(); } } - else if ((mode() == PrivMode::U) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::U) && implemented?(ExtensionName::Ssstaten)) { if (CSR[sstateen0].JVT == 1'b0) { unimplemented_csr(); } } - else if ((mode() == PrivMode::VS) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::VS) && implemented?(ExtensionName::Ssstaten)) { if (CSR[hstateen0].JVT == 1'b0) { unimplemented_csr(); } } - else if ((mode() == PrivMode::VU) && implemented?(ExtensionName::Ssstateen)) { + else if ((mode() == PrivilegeMode::VU) && implemented?(ExtensionName::Ssstateen)) { if ((CSR[sstateen0].JVT == 1'b0) || (CSR[hstateen0].JVT == 1'b0)) { unimplemented_csr(); } @@ -90,22 +93,22 @@ sw_read(): | # 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). - if ((mode() != PrivMode::M) && implemented?(ExtensionName::Smstateen)) { + if ((mode() != PrivilegeMode::M) && implemented?(ExtensionName::Smstateen)) { if (CSR[mstateen0].JVT == 1'b0) { raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } } - else if ((mode() == PrivMode::U) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::U) && implemented?(ExtensionName::Ssstaten)) { if (CSR[sstateen0].JVT == 1'b0) { raise(ExceptionCode::IllegalInstruction, mode(), $encoding); } } - else if ((mode() == PrivMode::VS) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::VS) && implemented?(ExtensionName::Ssstaten)) { if (CSR[hstateen0].JVT == 1'b0) { raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } } - else if ((mode() == PrivMode::VU) && implemented?(ExtensionName::Ssstateen)) { + else if ((mode() == PrivilegeMode::VU) && implemented?(ExtensionName::Ssstateen)) { if ((CSR[sstateen0].JVT == 1'b0) || (CSR[hstateen0].JVT == 1'b0)) { raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } From dc67acd7a822b95ae9ca58beeca94f34af2aff6d Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Fri, 20 Jun 2025 15:13:44 +0000 Subject: [PATCH 10/15] fix(jvt): file directory fix --- {arch => spec/std/isa}/csr/jvt.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {arch => spec/std/isa}/csr/jvt.yaml (100%) diff --git a/arch/csr/jvt.yaml b/spec/std/isa/csr/jvt.yaml similarity index 100% rename from arch/csr/jvt.yaml rename to spec/std/isa/csr/jvt.yaml From 939d6a0bdf510c7361a6c6f557bd6c27aded72a4 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Fri, 20 Jun 2025 15:18:06 +0000 Subject: [PATCH 11/15] fix(jvt): file directory fix --- {arch => spec/std/isa}/ext/Zcmt.yaml | 3 +++ 1 file changed, 3 insertions(+) rename {arch => spec/std/isa}/ext/Zcmt.yaml (97%) diff --git a/arch/ext/Zcmt.yaml b/spec/std/isa/ext/Zcmt.yaml similarity index 97% rename from arch/ext/Zcmt.yaml rename to spec/std/isa/ext/Zcmt.yaml index af53e4d7b..35c945cfc 100644 --- a/arch/ext/Zcmt.yaml +++ b/spec/std/isa/ext/Zcmt.yaml @@ -1,3 +1,6 @@ +# Copyright (c) Qualcomm Technologies, Inc. and Katherine Hsu +# SPDX-License-Identifier: BSD-3-Clause-Clear + # yaml-language-server: $schema=../../schemas/ext_schema.json $schema: "ext_schema.json#" From d19b787159eea0a0f68ceaa362ae7a04483a79e9 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Fri, 20 Jun 2025 15:30:04 +0000 Subject: [PATCH 12/15] fix(jvt): fix extension name --- spec/std/isa/csr/jvt.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/std/isa/csr/jvt.yaml b/spec/std/isa/csr/jvt.yaml index a66a3b64d..1300fdc5e 100644 --- a/spec/std/isa/csr/jvt.yaml +++ b/spec/std/isa/csr/jvt.yaml @@ -50,12 +50,12 @@ fields: unimplemented_csr(); } } - else if ((mode() == PrivilegeMode::U) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::U) && implemented?(ExtensionName::Ssstateen)) { if (CSR[sstateen0].JVT == 1'b0) { unimplemented_csr(); } } - else if ((mode() == PrivilegeMode::VS) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::VS) && implemented?(ExtensionName::Ssstateen)) { if (CSR[hstateen0].JVT == 1'b0) { unimplemented_csr(); } @@ -98,12 +98,12 @@ sw_read(): | raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } } - else if ((mode() == PrivilegeMode::U) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::U) && implemented?(ExtensionName::Ssstateen)) { if (CSR[sstateen0].JVT == 1'b0) { raise(ExceptionCode::IllegalInstruction, mode(), $encoding); } } - else if ((mode() == PrivilegeMode::VS) && implemented?(ExtensionName::Ssstaten)) { + else if ((mode() == PrivilegeMode::VS) && implemented?(ExtensionName::Ssstateen)) { if (CSR[hstateen0].JVT == 1'b0) { raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } From eb793da5f98837ad0c674afea3f36436a1804bf4 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Fri, 20 Jun 2025 15:40:33 +0000 Subject: [PATCH 13/15] fix: syntax fix --- spec/std/isa/csr/jvt.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/std/isa/csr/jvt.yaml b/spec/std/isa/csr/jvt.yaml index 1300fdc5e..e7528c838 100644 --- a/spec/std/isa/csr/jvt.yaml +++ b/spec/std/isa/csr/jvt.yaml @@ -47,22 +47,22 @@ fields: sw_write(csr_value): | if ((mode() != PrivilegeMode::M) && implemented?(ExtensionName::Smstateen)) { if (CSR[mstateen0].JVT == 1'b0) { - unimplemented_csr(); + unimplemented_csr($encoding); } } else if ((mode() == PrivilegeMode::U) && implemented?(ExtensionName::Ssstateen)) { if (CSR[sstateen0].JVT == 1'b0) { - unimplemented_csr(); + unimplemented_csr($encoding); } } else if ((mode() == PrivilegeMode::VS) && implemented?(ExtensionName::Ssstateen)) { if (CSR[hstateen0].JVT == 1'b0) { - unimplemented_csr(); + unimplemented_csr($encoding); } } else if ((mode() == PrivilegeMode::VU) && implemented?(ExtensionName::Ssstateen)) { if ((CSR[sstateen0].JVT == 1'b0) || (CSR[hstateen0].JVT == 1'b0)) { - unimplemented_csr(); + unimplemented_csr($encoding); } } else { From e3c25f219ff34e9d6864feade3f0a6898a50db76 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Thu, 26 Jun 2025 02:43:41 +0000 Subject: [PATCH 14/15] docs(jvt): add sw_write for MODE --- spec/std/isa/csr/jvt.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/std/isa/csr/jvt.yaml b/spec/std/isa/csr/jvt.yaml index e7528c838..e53d912e6 100644 --- a/spec/std/isa/csr/jvt.yaml +++ b/spec/std/isa/csr/jvt.yaml @@ -87,6 +87,11 @@ fields: return CsrFieldType::RW; } reset_value: 0 + sw_write(csr_value): | + if (JVT_READ_ONLY || (csr_value != 0)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + return 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 From 7ba3f12a576fe0b3da50f16e06ce3a23c1249019 Mon Sep 17 00:00:00 2001 From: Katherine Hsu <2katherinehsu@gmail.com> Date: Thu, 26 Jun 2025 03:04:04 +0000 Subject: [PATCH 15/15] docs(jvt): minor fix --- spec/std/isa/csr/jvt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/std/isa/csr/jvt.yaml b/spec/std/isa/csr/jvt.yaml index e53d912e6..dc69e00ed 100644 --- a/spec/std/isa/csr/jvt.yaml +++ b/spec/std/isa/csr/jvt.yaml @@ -88,7 +88,7 @@ fields: } reset_value: 0 sw_write(csr_value): | - if (JVT_READ_ONLY || (csr_value != 0)) { + if (JVT_READ_ONLY || (csr_value.MODE != 0)) { raise(ExceptionCode::IllegalInstruction, mode(), $encoding); } return 0;