medeleg

Machine Exception Delegation

Controls exception delegation from M-mode to (H)S-mode or, in conjunction with hedeleg, to VS-mode .

An exception cause is delegated to (H)S-mode when all of the following hold:

  • The corresponding field in medeleg is set.

  • The current privilege level is not M-mode.

  • The same field in hedeleg is clear.

An exception cause is delegated to VS-mode when all of the following hold:

  • The corresponding field in medeleg is set.

  • The corresponding field in hedeleg is set.

  • The current privilege level is not M-mode or HS-mode.

Otherwise, an exception cause is handled by M-mode.

See interrupt documentation for more details.

Attributes

CSR Address

0x302

Defining extension

  • S, version >= 0

Length

64-bit

Privilege Mode

M

Format

medeleg format
Figure 1. medeleg format

Field Summary

Name Location Type Reset Value

IAM

0

RW

UNDEFINED_LEGAL

IAF

1

RW

UNDEFINED_LEGAL

II

2

RW

UNDEFINED_LEGAL

B

3

RW

UNDEFINED_LEGAL

LAM

4

RW

UNDEFINED_LEGAL

LAF

5

RW

UNDEFINED_LEGAL

SAM

6

RW

UNDEFINED_LEGAL

SAF

7

RW

UNDEFINED_LEGAL

EU

8

RW

UNDEFINED_LEGAL

ES

9

RW

UNDEFINED_LEGAL

EVS

10

RW

UNDEFINED_LEGAL

EM

11

RO

0

IPF

12

RW

UNDEFINED_LEGAL

LPF

13

RW

UNDEFINED_LEGAL

SPF

15

RW

UNDEFINED_LEGAL

IGPF

20

RW

UNDEFINED_LEGAL

LGPF

21

RW

UNDEFINED_LEGAL

VI

22

RW

UNDEFINED_LEGAL

SGPF

23

RW

UNDEFINED_LEGAL

Fields

IAM

Location

medeleg[0]

Description

Instruction Address Misaligned

Delegates Instruction Address Misaligned exceptions to (H)S-mode. Instruction Address Misaligned exceptions may be futher delegated to VS-mode if hedeleg.IAM is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.IAM

hedeleg.IAM

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

IAF

Location

medeleg[1]

Description

Instruction Access Fault

Delegates Instruction Access Fault exceptions to (H)S-mode. Instruction Access Fault exceptions may be futher delegated to VS-mode if hedeleg.IAM is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.IAF

hedeleg.IAF

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

II

Location

medeleg[2]

Description

Illegal Instruction

Delegates Illegal Instruction exceptions to (H)S-mode. Illegal Instruction exceptions may be futher delegated to VS-mode if hedeleg.II is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.II

hedeleg.II

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

B

Location

medeleg[3]

Description

Breakpoint

Delegates Breakpoint exceptions to (H)S-mode. Breakpoint exceptions may be futher delegated to VS-mode if hedeleg.B is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.B

hedeleg.B

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

LAM

Location

medeleg[4]

Description

Load Address Misaligned

Delegates Load Address Misaligned exceptions to (H)S-mode. Load Address Misaligned exceptions may be futher delegated to VS-mode if hedeleg.LAM is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

Note that because this implementation supports misaligned loads, this exception will never occur. However, the writeable bit should be presented anyway.

The handling mode is determined as follows:

medeleg.LAM

hedeleg.LAM

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

LAF

Location

medeleg[5]

Description

Load Access Fault

Delegates Load Access Fault exceptions to (H)S-mode. Load Access Fault exceptions may be futher delegated to VS-mode if hedeleg.LAF is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.LAF

hedeleg.LAF

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

SAM

Location

medeleg[6]

Description

Store/AMO Address Misaligned

Delegates Store/AMO Address Misaligned exceptions to (H)S-mode. Store/AMO Address Misaligned exceptions may be futher delegated to VS-mode if hedeleg.SAM is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

Note that beause the implementation supports misaligned stores and misaligned AMOs (or no AMOs), this exception will never occur. Even so, the writeable bit should be presented anyway.

The handling mode is determined as follows:

medeleg.SAM

hedeleg.SAM

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

SAF

Location

medeleg[7]

Description

Store/AMO Access Fault

Delegates Store/AMO Access Fault exceptions to (H)S-mode. Store/AMO Access Fault exceptions may be futher delegated to VS-mode if hedeleg.SAM is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.SAF

hedeleg.SAF

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

EU

Location

medeleg[8]

Description

Environment Call from U-Mode

Delegates Environment Call from U-mode exceptions to (H)S-mode. Enviornment Call from U-mode exceptions may be futher delegated to VS-mode if hedeleg.EU is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.EU

hedeleg.EU

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

ES

Location

medeleg[9]

Description

Environment Call from S-Mode

Delegates Environment Call from S-mode exceptions to (H)S-mode. Enviornment Call from S-mode exceptions cannot be delegated to VS-mode.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.ES

Current Mode

M-mode

(H)S-mode +

0

M

M

1

M

(H)S

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

EVS

Location

medeleg[10]

Description

Environment Call from VS-Mode

Delegates Environment Call from VS-mode exceptions to (H)S-mode. Enviornment Call from S-mode exceptions cannot be delegated to VS-mode.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.EVS

Current Mode

M-mode

(H)S-mode +

0

M

M

1

M

(H)S

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

EM

Location

medeleg[11]

Description

Environment Call from M-Mode

An Environment Call from M-mode cannot be delegated, so this is a read-only field.

All Enviornment Call from M-mode exceptions are taken by M-mode.

Type

RO

Read-Only

Field has a hardwired value that does not change. Writes to an RO field are ignored.

Reset value

0

IPF

Location

medeleg[12]

Description

Instruction Page Fault

Delegates Instruction Page Fault exceptions to (H)S-mode. Instruction Page Fault exceptions may be futher delegated to VS-mode if hedeleg.IPF is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.IPF

hedeleg.IPF

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

LPF

Location

medeleg[13]

Description

Load Page Fault

Delegates Load Page Fault exceptions to (H)S-mode. Load Page Fault exceptions may be futher delegated to VS-mode if hedeleg.LPF is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.LPF

hedeleg.LPF

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

SPF

Location

medeleg[15]

Description

Store/AMO Page Fault

Delegates Store/AMO Page Fault exceptions to (H)S-mode. Store/AMO Page Fault exceptions may be futher delegated to VS-mode if hedeleg.SPF is also set.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.SPF

hedeleg.SPF

Current Mode

M-mode

HS-mode

VS-mode

VU-mode +

0

0

M

M

M

M

0

1

M

M

M

M

1

0

M

HS

HS

HS

1

1

M

HS

VS

VS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

IGPF

Location

medeleg[20]

Description

Instruction Guest Page Fault

Delegates Instruction Guest Page Fault exceptions to (H)S-mode. Instruction Guest Page Fault exceptions cannot be delegated to VS-mode.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.IGPF

Current Mode

M-mode

(H)S-mode +

0

M

M

1

M

HS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

LGPF

Location

medeleg[21]

Description

Load Guest Page Fault

Delegates Load Guest Page Fault exceptions to (H)S-mode. Load Guest Page Fault exceptions cannot be delegated to VS-mode.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.LGPF

Current Mode

M-mode

(H)S-mode +

0

M

M

1

M

HS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

VI

Location

medeleg[22]

Description

Virtual Instruction

Delegates Virtual Instruction exceptions to (H)S-mode. Virtual Instruction exceptions cannot be delegated to VS-mode.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.VI

Current Mode

M-mode

(H)S-mode +

0

M

M

1

M

HS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL

SGPF

Location

medeleg[23]

Description

Store/AMO Guest Page Fault

Delegates Store/AMO Guest Page Fault exceptions to (H)S-mode. Store/AMO Guest Page Fault exceptions cannot be delegated to VS-mode.

Exceptions are never taken into a less-privileged mode, regardless of medeleg.

The handling mode is determined as follows:

medeleg.SGPF

Current Mode

M-mode

(H)S-mode +

0

M

M

1

M

HS

Type

RW

Read-Write

Field is writable by software. Any value that fits in the field is acceptable and shall be retained for subsequent reads.

Reset value

UNDEFINED_LEGAL