Skip to content

Executing SRET in Lower-Privilege Mode Does Not Raise an Exception #251

@fly-1011

Description

@fly-1011

Bug Description:

According to the RISC-V Privileged Specification:

An xRET instruction can be executed in
privilege mode x or higher, where executing a lower-privilege xRET instruction will pop the relevant
lower-privilege interrupt enable and privilege mode stack. Attempting to execute an xRET instruction in
a mode less privileged than x will raise an illegal-instruction exception. In addition to manipulating the
privilege stack as described in Section 3.1.6.1, xRET sets the pc to the value stored in the xepc register.

However, NutShell executes the SRET instruction in U-mode without raising an illegal-instruction exception, which violates the RISC-V privileged specification and also differs from the behavior of the Spike reference model.

Test program and log information: test_sret.zip

Inconsistent information:

Image Image

Environment:

NutShell: commit e315a27

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions