medeleg

Machine Exception Delegation

Controls exception delegation from M-mode to (H)S-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.

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

See interrupt documentation for more details.

Attributes

Defining Extension

  • S, version >= 0

CSR Address

0x302

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

xref:exts:B.adoc#B-def[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

0

Description

Instruction Address Misaligned

Delegates Instruction Address Misaligned exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.IAM 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

IAF

Location

1

Description

Instruction Access Fault

Delegates Instruction Access Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.IAF 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

II

Location

2

Description

Illegal Instruction

Delegates Illegal Instruction exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.II 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

B

Location

3

Description

Breakpoint

Delegates Breakpoint exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.B 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

LAM

Location

4

Description

Load Address Misaligned

Delegates Load Address Misaligned exceptions to (H)S-mode.

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

[when,"MISALIGNED_LDST == true"]
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:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.LAM 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

LAF

Location

5

Description

Load Access Fault

Delegates Load Access Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.LAF 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

SAM

Location

6

Description

Store/AMO Address Misaligned

Delegates Store/AMO Address Misaligned exceptions to (H)S-mode.

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

[when,"MISALIGNED_LDST == true && MISALIGNED_AMO == true"]
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:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.SAM 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

SAF

Location

7

Description

Store/AMO Access Fault

Delegates Store/AMO Access Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.SAF 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

EU

Location

8

Description

Environment Call from U-Mode

Delegates Environment Call from U-mode exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.EU 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

ES

Location

9

Description

Environment Call from S-Mode

Delegates Environment Call from S-mode exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.ES 2+^.>! Current Mode
.>h! M-mode .>h! (H)S-mode

! 0 ! M ! M
! 1 ! M ! (H)S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

EVS

Location

10

Description

Environment Call from VS-Mode

Delegates Environment Call from VS-mode exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.EVS 2+^.>! Current Mode
.>h! M-mode .>h! (H)S-mode

! 0 ! M ! M
! 1 ! M ! (H)S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

EM

Location

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

Reset value

0

IPF

Location

12

Description

Instruction Page Fault

Delegates Instruction Page Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.IPF 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

LPF

Location

13

Description

Load Page Fault

Delegates Load Page Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.LPF 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

SPF

Location

15

Description

Store/AMO Page Fault

Delegates Store/AMO Page Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.LPF 2+^.>! Current Mode
.>h! M-mode .>h! S-mode

! 0 ! M ! M
! 1 ! M ! S
!===

Type

RW

Reset value

UNDEFINED_LEGAL

IGPF

Location

20

Description

Instruction Guest Page Fault

Delegates Instruction Guest Page Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.IGPF 2+^.>! Current Mode
.>h! M-mode .>h! (H)S-mode

! 0 ! M ! M
! 1 ! M ! HS
!===

Type

RW

Reset value

UNDEFINED_LEGAL

LGPF

Location

21

Description

Load Guest Page Fault

Delegates Load Guest Page Fault exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.LGPF 2+^.>! Current Mode
.>h! M-mode .>h! (H)S-mode

! 0 ! M ! M
! 1 ! M ! HS
!===

Type

RW

Reset value

UNDEFINED_LEGAL

VI

Location

22

Description

Virtual Instruction

Delegates Virtual Instruction exceptions to (H)S-mode.

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.VI 2+^.>! Current Mode
.>h! M-mode .>h! (H)S-mode

! 0 ! M ! M
! 1 ! M ! HS
!===

Type

RW

Reset value

UNDEFINED_LEGAL

SGPF

Location

23

Description

Store/AMO Guest Page Fault

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

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

The handling mode is determined as follows:

[separator="!",%autowidth, %footer]
!===
.2+! medeleg.SGPF 2+^.>! Current Mode
.>h! M-mode .>h! (H)S-mode

! 0 ! M ! M
! 1 ! M ! HS
!===

Type

RW

Reset value

UNDEFINED_LEGAL