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

riscv: elf: taking privilege exception #16

Open
VarunKoyyalagunta opened this issue Dec 31, 2021 · 0 comments
Open

riscv: elf: taking privilege exception #16

VarunKoyyalagunta opened this issue Dec 31, 2021 · 0 comments

Comments

@VarunKoyyalagunta
Copy link

I am unable to execute any of the riscv elf tests on the web interface or the CLI.

For example, if I load the loop5-O0 test on https://www.cl.cam.ac.uk/~sf502/regressions/rmem/, and execute step 20, I get this exception -

0:1    0x01010c (_start) fetch error          
  micro_op_state: MOS_pending_exception decode error: Internal error Type_check.Type_error(_, 0, _)
  waiting to raise an exception
  0 0:1    raise exception: decode error: Internal error Type_check.Type_error(_, 0, _)
          t @ 0x11170
          i @ 0xfffff0003ec

On the CLI, if I take the same loop5-O0 binary (compiled from https://github.com/litmus-tests/litmus-tests-riscv/tree/master/elf-tests/basic), and run ./rmem -model relaxed -model flat -cmds "step 20" I get this exception -

Failure while taking transition (from the state above):                                                                                                                                               
  0:2    register read: cur_privilege = 2b_1'10 from initialstate of 0-1:2b_0'10                                                                                                                      
                                                                                                                                                                                                      
Fail: Pattern match failure at model/riscv_types.sail 78:2 - 82:3. regval_privilege                                                                                                                   
                                                                                                                                                                                                      
Fatal error: exception Failure("Fail: Pattern match failure at model/riscv_types.sail 78:2 - 82:3. regval_privilege")                                                                                 
Raised at file "list.ml", line 187, characters 10-25                                                                                                                                                  
Called from file "src_top/pp.ml", line 359, characters 4-42   

I was able to fix the problem on the CLI with the following change -
VarunKoyyalagunta@8737b47

I can create a PR for that if that is the appropriate fix. I just copied the initial cur_privilege and mstatus settings from

((tid, "cur_privilege"), Sail_impl_base.register_value_for_reg_of_integer (get_reg "cur_privilege") (Nat_big_num.of_int 0));
((tid, "misa"), Sail_impl_base.register_value_for_reg_of_integer (get_reg "misa") (Nat_big_num.of_string "0x8000000000000881")); (* RV64IMA *)
((tid, "mstatus"), Sail_impl_base.register_value_for_reg_of_integer (get_reg "mstatus") (Nat_big_num.of_string "0x0000000a00000000")); (* RV64 in S and U also *)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant