stvec

Supervisor Trap Vector

Controls where traps jump.

Attributes

Requirement

S

Defining extensions

S

Supervisor mode

CSR Address

0x105

Length

* 32 when CSR[mstatus].SXL == 0 * 64 when CSR[mstatus].SXL == 1

Privilege Mode

S

Format

This CSR format changes dynamically.

stvec Format when CSR[mstatus].SXL == 0
Figure 1. stvec Format when CSR[mstatus].SXL == 0
stvec Format when CSR[mstatus].SXL == 1
Figure 2. stvec Format when CSR[mstatus].SXL == 1

Field Summary

Name Location Type Reset Value

stvec.BASE

* 31:2 when CSR[mstatus].SXL == 0 * 63:2 when CSR[mstatus].SXL == 1

RW-R

UNDEFINED_LEGAL

stvec.MODE

1:0

[when,"$array_size(STVEC_MODES) == 1"] RO

[when,"$array_size(STVEC_MODES) != 1"] RW-R

UNDEFINED_LEGAL

Fields

BASE

Location
  • 31:2 when CSR[mstatus].SXL == 0

  • 63:2 when CSR[mstatus].SXL == 1

Description

<%- va_size = ext?(:Sv57) ? 57 : (ext?(:Sv48) ? 48 : 39) -%> Bits [SXLEN-1:2] of the virtual address of the exception vector for any trap taken into S-mode.

If the base address is written with a non-canonical address (i.e., bits [SXLEN-1:<%= va_size %>] do not match bit <%= va_size-1 %>), the write should be ignored.

Type

RW-R

Reset value

UNDEFINED_LEGAL

MODE

Location

1:0

Description

Vectoring mode for asynchronous interrupts.

0 - Direct, 1 - Vectored

When Direct, all synchronous exceptions and asynchronous interrupts jump to (stvec.BASE << 2).

When Vectored, asynchronous interrupts jump to (stvec.BASE << 2 + scause.CODE*4) while synchronous exceptions continue to jump to (stvec.BASE << 2).

Type

RO

RW-R

Reset value

UNDEFINED_LEGAL

Software write

This CSR may store a value that is different from what software attempts to write.

When a software write occurs (e.g., through csrrw), the following determines the written value:

BASE = # Base spec says that BASE must be 4-byte aligned, which will always be the case
# implementations may put further constraints on BASE when MODE != Direct
# If that is the case, stvec should have an override for the implementation
return csr_value.BASE;

MODE = if ($array_includes?(STVEC_MODES, csr_value.MODE)) {
  return csr_value.MODE;
}
return UNDEFINED_LEGAL_DETERMINISTIC;