CSR Bit Fields

RISC-V scounteren CSR Register

Address 0x106Privilege SupervisorAccess RW / 32Supervisor environment-configuration and state-enable CSRs

Supervisor counter-enable register; controls whether U-mode can access hardware counters.

Field Map

Understand scounteren By Bit Fields

4 key fields
0

CY

RW

Enable cycle read in U-mode

CY (bit 0) — Enable cycle read in U-mode.

What This Field Controls

  • - Enable cycle read in U-mode

Common Values

0Disabled

U-mode reads of cycle are not authorized by S-mode.

1Enabled

S-mode allows U-mode reads of cycle; machine-level authorization is still constrained by mcounteren and related rules.

1

TM

RW

Enable time read in U-mode

TM (bit 1) — Enable time read in U-mode.

What This Field Controls

  • - Enable time read in U-mode

Common Values

0Disabled

U-mode reads of time are not authorized by S-mode.

1Enabled

S-mode allows U-mode reads of time; machine-level authorization is still constrained by mcounteren and related rules.

2

IR

RW

Enable instret read in U-mode

IR (bit 2) — Enable instret read in U-mode.

What This Field Controls

  • - Enable instret read in U-mode

Common Values

0Disabled

U-mode reads of instret are not authorized by S-mode.

1Enabled

S-mode allows U-mode reads of instret; machine-level authorization is still constrained by mcounteren and related rules.

31:3

HPMn

RW

Enable U-mode reads of corresponding hpmcounter3..31; also constrained by mcounteren and whether the counters are implemented.

HPMn (bits 31:3) — Enable U-mode reads of corresponding hpmcounter3..31; also constrained by mcounteren and whether the counters are implemented.

What This Field Controls

  • - Enable U-mode reads of corresponding hpmcounter3..31; also constrained by mcounteren and whether the counters are implemented.

Common Values

0Disabled

U-mode reads of hpmcounter3-31 are not authorized by S-mode.

1Enabled

S-mode allows U-mode reads of hpmcounter3-31; machine-level authorization is still constrained by mcounteren and related rules.

Official Basis & Search Notes

scounteren is a RW CSR in supervisor environment-configuration and state-enable csrs at 0x106. Check privilege and implemented extensions before interpreting its bit fields.

scounteren address, lowest access privilege, and access class are checked against the official CSR table: 0x106, Supervisor, RW.
Read it as part of supervisor environment-configuration and state-enable csrs before interpreting the bit-field table on this page.
Modify only target fields and preserve unchanged bits; interpret WPRI and reserved fields only as the official specification and implementation define them.

What To Check First When Reading This CSR

  • - First confirm that the current hart implements scounteren; unimplemented or insufficiently privileged accesses raise an illegal-instruction exception.
  • - Use address 0x106 and the lowest access privilege (Supervisor) to decide whether software may read it directly.
  • - Do not assume fixed values for reserved, WARL, or WLRL bits; interpret the value according to the specification and implementation.

Risk Checks Before Writing

  • - Preserve bits that are not being changed so reserved or implementation-defined fields are not written with invalid values.
  • - Prefer CSRRS/CSRRC for local set/clear operations to avoid CSRRW overwriting concurrently updated status bits.

Put It Back Into A Real Flow

1

During initialization or the relevant privileged flow, software reads scounteren to observe the current state.

2

Modify only the target fields while preserving all other bits.

3

Read back the CSR or validate through later trap, interrupt, or context-switch behavior that the setting took effect.

FAQ

Can scounteren be accessed from any privilege level?

Do not decide from the CSR name alone. The official CSR address encoding and tables define the lowest access privilege; this entry records scounteren as Supervisor. Access with insufficient privilege or to an unimplemented CSR raises an illegal-instruction exception.

What is easiest to miss when writing scounteren?

Do not overwrite the whole CSR as if it were an ordinary integer. Modify only target fields, preserve unchanged bits, and follow the specification for WARL, WLRL, WPRI, or reserved fields.