Skip to content

Commit 4211964

Browse files
committed
fix: updates per review
1 parent 0597854 commit 4211964

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

spec/std/isa/inst/Zcmt/cm.jalt.yaml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ access:
2525
vu: always
2626
operation(): |
2727
# Ensure JVT readable
28-
Csr csr_handle = direct_csr_lookup(0x017);
28+
Csr csr_handle = direct_csr_lookup(CSR[jvt].address());
2929
XReg jvt = csr_sw_read(csr_handle);
3030
3131
if (CSR[jvt].MODE != 0) {
@@ -37,30 +37,26 @@ operation(): |
3737
X[1] = return_addr;
3838
3939
XReg jump_table_base = { CSR[jvt].BASE, 6'b000000 };
40-
XReg virtual_address = jump_table_base + index * (xlen() / 8);
40+
XReg virtual_address = jump_table_base + index `* (xlen() / 8);
4141
XReg addr;
42+
TranslationResult result;
4243
43-
# TODO
44-
# For a table jump instruction, the table entry that the instruction selects
45-
# is considered an extension of the instruction itself. Hence, the execution
46-
# of a table jump instruction involves two instruction fetches, the first to
47-
# read the instruction (cm.jt/cm.jalt) and the second to read from the jump
48-
# vector table (JVT). Both instruction fetches are implicit reads, and both
49-
# require execute permission; read permission is irrelevant. It is
50-
# recommended that the second fetch be ignored for hardware triggers and breakpoints.
51-
#
52-
# If an exception occurs on either instruction fetch, xEPC is set to the PC
53-
# of the table jump instruction, xCAUSE is set as expected for the type of
54-
# fault and xTVAL (if not set to zero) contains the fetch address which
55-
# caused the fault.
44+
# TODO: Correct this check when we figure out what MISA can do
45+
if (CSR[misa].S == 1) {
46+
result = translate(virtual_address, MemoryOperation::Fetch, mode(), $encoding);
47+
} else {
48+
result.paddr = virtual_address;
49+
}
50+
51+
# may raise an exception
52+
access_check(result.paddr, xlen(), $pc, MemoryOperation::Fetch, ExceptionCode::InstructionAccessFault, mode());
5653
5754
if (xlen() == 32) {
58-
addr = read_memory<32>(virtual_address, $encoding);
55+
addr = read_physical_memory<32>(result.paddr);
5956
} else {
60-
addr = read_memory<64>(virtual_address, $encoding);
61-
}
57+
addr = read_physical_memory<64>(result.paddr);
58+
} # Ensure low-order bit is clear
6259
63-
# Ensure low-order bit is clear
6460
addr = addr & $signed(2'b10);
6561
6662
jump(addr);

spec/std/isa/inst/Zcmt/cm.jt.yaml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ access:
2323
vu: always
2424
operation(): |
2525
# Ensure JVT readable
26-
Csr csr_handle = direct_csr_lookup(0x017);
26+
Csr csr_handle = direct_csr_lookup(CSR[jvt].address());
2727
XReg jvt = csr_sw_read(csr_handle);
2828
2929
if (CSR[jvt].MODE != 0) {
@@ -33,25 +33,22 @@ operation(): |
3333
XReg jump_table_base = { CSR[jvt].BASE, 6'b000000 };
3434
XReg virtual_address = jump_table_base + index `* (xlen() / 8);
3535
XReg addr;
36+
TranslationResult result;
3637
37-
# TODO
38-
# For a table jump instruction, the table entry that the instruction selects
39-
# is considered an extension of the instruction itself. Hence, the execution
40-
# of a table jump instruction involves two instruction fetches, the first to
41-
# read the instruction (cm.jt/cm.jalt) and the second to read from the jump
42-
# vector table (JVT). Both instruction fetches are implicit reads, and both
43-
# require execute permission; read permission is irrelevant. It is
44-
# recommended that the second fetch be ignored for hardware triggers and breakpoints.
45-
#
46-
# If an exception occurs on either instruction fetch, xEPC is set to the PC
47-
# of the table jump instruction, xCAUSE is set as expected for the type of
48-
# fault and xTVAL (if not set to zero) contains the fetch address which
49-
# caused the fault.
38+
# TODO: Correct this check when we figure out what MISA can do
39+
if (CSR[misa].S == 1) {
40+
result = translate(virtual_address, MemoryOperation::Fetch, mode(), $encoding);
41+
} else {
42+
result.paddr = virtual_address;
43+
}
44+
45+
# may raise an exception
46+
access_check(result.paddr, xlen(), $pc, MemoryOperation::Fetch, ExceptionCode::InstructionAccessFault, mode());
5047
5148
if (xlen() == 32) {
52-
addr = read_memory<32>(virtual_address, $encoding);
49+
addr = read_physical_memory<32>(result.paddr);
5350
} else {
54-
addr = read_memory<64>(virtual_address, $encoding);
51+
addr = read_physical_memory<64>(result.paddr);
5552
}
5653
5754
# Ensure low-order bit is clear

0 commit comments

Comments
 (0)