Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The low bit of mepc is not updated correctly #39

Open
mmxsrup opened this issue Mar 11, 2021 · 0 comments
Open

The low bit of mepc is not updated correctly #39

mmxsrup opened this issue Mar 11, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mmxsrup
Copy link
Contributor

mmxsrup commented Mar 11, 2021

Observed Behavior

The low bit of mepc is always zero, as described in Chapter 3.1.19 of RISC-V Privileged Architectures.

mepc is an XLEN-bit read/write register formatted as shown in Figure 3.20. The low bit of mepc (mepc[0]) is always zero. On implementations that do not support instruction-set extensions with 16-bit instruction alignment, the two low bits (mepc[1:0]) are always zero.

For example, csrw mepc, 0x1 is a instruction to set the low bit of mepc. In the current RSD implementation, when such an instruction is executed, the low bit of mepc is set. If the low bit of mepc is updated correctly, the low bit of mepc will always be zero.

Steps to reproduce the issue

The code below writes the value 1 to mepc and then reads the value of mepc. When you execute the following code, you can confirm that the value of mepc is 1. Correctly, the value of mepc should be zero.

int main(void){
    asm volatile ("csrw mepc, 0x1;\
                   csrr t0, mepc");
}
@mmxsrup mmxsrup added the bug Something isn't working label Mar 11, 2021
@mmxsrup mmxsrup self-assigned this Mar 24, 2021
mmxsrup added a commit to mmxsrup/rsd that referenced this issue Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant