CSR Bit Fields

RISC-V mctrctl CSR Register

Address 0x34EPrivilege MachineAccess Machine read/write (MRW) / 64-bit; RV32 explicit access reaches only bits 31:0, with no mctrctlhMachine Control Transfer Records CSRs

mctrctl (0x34E) is the 64-bit Smctr v1.0 machine control CSR for selecting recorded privilege modes, controlling external-trap/freeze behavior, and filtering control-transfer types.

Field Map

Understand mctrctl By Bit Fields

27 key fields
0

U

RW

Selects transfer recording in U-mode. This field is mandatory and writable.

U (bit 0) — Selects transfer recording in U-mode. This field is mandatory and writable.

What This Field Controls

  • - Selects transfer recording in U-mode. This field is mandatory and writable.

Common Values

00

U-mode recording is not selected.

11

U-mode recording is selected.

1

S

RW

Selects transfer recording in S/HS-mode. This field is mandatory and writable.

S (bit 1) — Selects transfer recording in S/HS-mode. This field is mandatory and writable.

What This Field Controls

  • - Selects transfer recording in S/HS-mode. This field is mandatory and writable.

Common Values

00

S/HS-mode recording is not selected.

11

S/HS-mode recording is selected.

2

M

RW

Selects transfer recording in M-mode. This field is mandatory and writable.

M (bit 2) — Selects transfer recording in M-mode. This field is mandatory and writable.

What This Field Controls

  • - Selects transfer recording in M-mode. This field is mandatory and writable.

Common Values

00

M-mode recording is not selected.

11

M-mode recording is selected.

6:3

WPRI

WPRI / RO0

Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

WPRI (bits 6:3) — Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

What This Field Controls

  • - Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

Common Values

This field is better understood together with surrounding context than as a fixed memorized enumeration.

7

RASEMU

RW if implemented; otherwise RO0

Enables Return Address Stack (RAS) emulation mode; when set, calls are recorded, returns pop entries, co-routine swaps act as a return plus call, other transfer types are inhibited, and bits 47:32 plus xTE are ignored.

RASEMU (bit 7) — Enables Return Address Stack (RAS) emulation mode; when set, calls are recorded, returns pop entries, co-routine swaps act as a return plus call, other transfer types are inhibited, and bits 47:32 plus xTE are ignored.

What This Field Controls

  • - Enables Return Address Stack (RAS) emulation mode; when set, calls are recorded, returns pop entries, co-routine swaps act as a return plus call, other transfer types are inhibited, and bits 47:32 plus xTE are ignored.

Common Values

00

Use normal CTR recording behavior.

11

Enable RAS-emulation recording behavior and ignore the transfer filters and external-trap enable bits.

8

STE

RW if implemented; otherwise RO0

When S=0, allows recording external traps to S-mode.

STE (bit 8) — When S=0, allows recording external traps to S-mode.

What This Field Controls

  • - When S=0, allows recording external traps to S-mode.

Common Values

00

Do not additionally permit recording external traps to S-mode.

11

Permit recording external traps to S-mode.

9

MTE

RW if implemented; otherwise RO0

When M=0, allows recording external traps to M-mode.

MTE (bit 9) — When M=0, allows recording external traps to M-mode.

What This Field Controls

  • - When M=0, allows recording external traps to M-mode.

Common Values

00

Do not additionally permit recording external traps to M-mode.

11

Permit recording external traps to M-mode.

10

WPRI

WPRI / RO0

Reserved. Software ignores reads and preserves this bit on writes; an undefined implementation is read-only zero.

WPRI (bit 10) — Reserved. Software ignores reads and preserves this bit on writes; an undefined implementation is read-only zero.

What This Field Controls

  • - Reserved. Software ignores reads and preserves this bit on writes; an undefined implementation is read-only zero.

Common Values

This field is better understood together with surrounding context than as a fixed memorized enumeration.

11

BPFRZ

RW

Sets sctrstatus.FROZEN when a breakpoint exception traps to M-mode or S-mode. This field is mandatory and writable.

BPFRZ (bit 11) — Sets sctrstatus.FROZEN when a breakpoint exception traps to M-mode or S-mode. This field is mandatory and writable.

What This Field Controls

  • - Sets sctrstatus.FROZEN when a breakpoint exception traps to M-mode or S-mode. This field is mandatory and writable.

Common Values

00

Breakpoint traps do not trigger this automatic freeze.

11

A qualifying breakpoint trap sets FROZEN.

12

LCOFIFRZ

RW if implemented; otherwise RO0

Sets sctrstatus.FROZEN when an LCOFI traps to M-mode or S-mode; it must be writable when Sscofpmf is implemented.

LCOFIFRZ (bit 12) — Sets sctrstatus.FROZEN when an LCOFI traps to M-mode or S-mode; it must be writable when Sscofpmf is implemented.

What This Field Controls

  • - Sets sctrstatus.FROZEN when an LCOFI traps to M-mode or S-mode; it must be writable when Sscofpmf is implemented.

Common Values

00

LCOFI traps do not trigger this automatic freeze.

11

A qualifying LCOFI trap sets FROZEN.

32:13

WPRI

WPRI / RO0

Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

WPRI (bits 32:13) — Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

What This Field Controls

  • - Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

Common Values

This field is better understood together with surrounding context than as a fixed memorized enumeration.

33

EXCINH

RW if implemented; otherwise RO0

Inhibits recording exceptions, except that it does not affect external-trap recording enabled through xTE.

EXCINH (bit 33) — Inhibits recording exceptions, except that it does not affect external-trap recording enabled through xTE.

What This Field Controls

  • - Inhibits recording exceptions, except that it does not affect external-trap recording enabled through xTE.

Common Values

00

Do not inhibit exception recording through this bit.

11

Inhibit exception recording; external traps enabled through xTE are unaffected by this bit.

34

INTRINH

RW if implemented; otherwise RO0

Inhibits recording interrupts, except that it does not affect external-trap recording enabled through xTE.

INTRINH (bit 34) — Inhibits recording interrupts, except that it does not affect external-trap recording enabled through xTE.

What This Field Controls

  • - Inhibits recording interrupts, except that it does not affect external-trap recording enabled through xTE.

Common Values

00

Do not inhibit interrupt recording through this bit.

11

Inhibit interrupt recording; external traps enabled through xTE are unaffected by this bit.

35

TRETINH

RW if implemented; otherwise RO0

Inhibits recording trap returns.

TRETINH (bit 35) — Inhibits recording trap returns.

What This Field Controls

  • - Inhibits recording trap returns.

Common Values

00

Do not inhibit trap-return recording through this bit.

11

Inhibit trap-return recording.

36

NTBREN

RW if implemented; otherwise RO0

Enables recording not-taken branches; this is an enable bit rather than an inhibit bit.

NTBREN (bit 36) — Enables recording not-taken branches; this is an enable bit rather than an inhibit bit.

What This Field Controls

  • - Enables recording not-taken branches; this is an enable bit rather than an inhibit bit.

Common Values

00

Do not record not-taken branches.

11

Record qualifying not-taken branches.

37

TKBRINH

RW if implemented; otherwise RO0

Inhibits recording taken branches.

TKBRINH (bit 37) — Inhibits recording taken branches.

What This Field Controls

  • - Inhibits recording taken branches.

Common Values

00

Do not inhibit taken-branch recording through this bit.

11

Inhibit taken-branch recording.

39:38

WPRI

WPRI / RO0

Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

WPRI (bits 39:38) — Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

What This Field Controls

  • - Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

Common Values

This field is better understood together with surrounding context than as a fixed memorized enumeration.

40

INDCALLINH

RW if implemented; otherwise RO0

Inhibits recording indirect calls.

INDCALLINH (bit 40) — Inhibits recording indirect calls.

What This Field Controls

  • - Inhibits recording indirect calls.

Common Values

00

Do not inhibit indirect-call recording through this bit.

11

Inhibit indirect-call recording.

41

DIRCALLINH

RW if implemented; otherwise RO0

Inhibits recording direct calls.

DIRCALLINH (bit 41) — Inhibits recording direct calls.

What This Field Controls

  • - Inhibits recording direct calls.

Common Values

00

Do not inhibit direct-call recording through this bit.

11

Inhibit direct-call recording.

42

INDJMPINH

RW if implemented; otherwise RO0

Inhibits recording indirect jumps without linkage.

INDJMPINH (bit 42) — Inhibits recording indirect jumps without linkage.

What This Field Controls

  • - Inhibits recording indirect jumps without linkage.

Common Values

00

Do not inhibit this jump class through this bit.

11

Inhibit indirect jumps without linkage.

43

DIRJMPINH

RW if implemented; otherwise RO0

Inhibits recording direct jumps without linkage.

DIRJMPINH (bit 43) — Inhibits recording direct jumps without linkage.

What This Field Controls

  • - Inhibits recording direct jumps without linkage.

Common Values

00

Do not inhibit this jump class through this bit.

11

Inhibit direct jumps without linkage.

44

CORSWAPINH

RW if implemented; otherwise RO0

Inhibits recording co-routine swaps.

CORSWAPINH (bit 44) — Inhibits recording co-routine swaps.

What This Field Controls

  • - Inhibits recording co-routine swaps.

Common Values

00

Do not inhibit co-routine-swap recording through this bit.

11

Inhibit co-routine-swap recording.

45

RETINH

RW if implemented; otherwise RO0

Inhibits recording function returns.

RETINH (bit 45) — Inhibits recording function returns.

What This Field Controls

  • - Inhibits recording function returns.

Common Values

00

Do not inhibit function-return recording through this bit.

11

Inhibit function-return recording.

46

INDLJMPINH

RW if implemented; otherwise RO0

Inhibits recording other indirect jumps with linkage.

INDLJMPINH (bit 46) — Inhibits recording other indirect jumps with linkage.

What This Field Controls

  • - Inhibits recording other indirect jumps with linkage.

Common Values

00

Do not inhibit this jump class through this bit.

11

Inhibit other indirect jumps with linkage.

47

DIRLJMPINH

RW if implemented; otherwise RO0

Inhibits recording other direct jumps with linkage.

DIRLJMPINH (bit 47) — Inhibits recording other direct jumps with linkage.

What This Field Controls

  • - Inhibits recording other direct jumps with linkage.

Common Values

00

Do not inhibit this jump class through this bit.

11

Inhibit other direct jumps with linkage.

59:48

WPRI

WPRI / RO0

Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

WPRI (bits 59:48) — Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

What This Field Controls

  • - Reserved. Software ignores reads and preserves these bits on writes; undefined implementations are read-only zero.

Common Values

This field is better understood together with surrounding context than as a fixed memorized enumeration.

63:60

Custom[3:0]

WARL; RO0 if unimplemented

WARL bits for custom use; value 0 must correspond to standard behavior.

Custom[3:0] (bits 63:60) — WARL bits for custom use; value 0 must correspond to standard behavior.

What This Field Controls

  • - WARL bits for custom use; value 0 must correspond to standard behavior.

Common Values

This field is better understood together with surrounding context than as a fixed memorized enumeration.

Official Basis & Search Notes

mctrctl is the 64-bit top-level CTR control register: low bits select modes, RAS, external traps, and freeze behavior, while the upper half mainly filters transfer types; RV32 cannot explicitly access bits 63:32.

Smctr v1.0 defines mctrctl as a 64-bit read/write register.
M, S, U, and BPFRZ are mandatory; other fields are optional and read-only zero when unimplemented.
Custom[3:0] is WARL and zero must mean standard behavior; reserved segments are WPRI.
Writing xctrctl resets the CTR cycle counter and makes CCV zero in the next record.

What To Check First When Reading This CSR

  • - The official CSR table allocates mctrctl at 0x34E with MRW access.
  • - The register is 64-bit; RV32 explicit access reaches only the low 32 bits, and Smctr v1.0 defines no mctrctlh.
  • - All fields except mandatory M, S, U, and BPFRZ are optional; unimplemented fields are read-only zero.

Risk Checks Before Writing

  • - Preserve every WPRI bit and modify only implemented fields that need to change.
  • - Any write to xctrctl resets the CTR cycle counter, so the next record has ctrdata.CCV=0.
  • - RV32 cannot explicitly modify bits 63:32; do not assume upper transfer filters or Custom fields are configurable.

Put It Back Into A Real Flow

1

Confirm Smctr, S-mode, and Sscsrind are implemented.

2

Read mctrctl, identify implemented fields, and preserve WPRI bits.

3

Configure M/S/U, freeze/external-trap policy, and required transfer-type filters.

4

After writing, account for CCV=0 in the next record.

FAQ

Can RV32 configure every mctrctl field?

No. RV32 explicit access reaches only bits 31:0, and Smctr v1.0 defines no mctrctlh, so RV32 software cannot explicitly access bits 63:32.

Must every mctrctl field be implemented?

No. Only M, S, U, and BPFRZ are mandatory; other fields are optional and read-only zero when absent. LCOFIFRZ must be writable when Sscofpmf is implemented.