Skip to content

Commit

Permalink
Fix movsr: only if PCC has SR register
Browse files Browse the repository at this point in the history
  • Loading branch information
JuneRousseau committed Jun 6, 2024
1 parent b7d59d5 commit 939a61e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/machine.ml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ let load_deep_immutable (w : word) : word =
| Sealed (ot, s) -> Sealed (ot, load_deep_immutable_sealable s)
| _ -> w

let authorised_access_system_register (conf : exec_conf) : bool =
match PC @! conf with
| Sealable (Cap (p, _, _, _, _)) -> PermSet.mem SR p
| _ -> false

(* NOTE Although we've already check that not supported instructions / capabilities *)
(* are not in the initial machine, we still need to make sure that *)
(* the user does not encode not supported instructions *)
Expand Down Expand Up @@ -269,10 +274,11 @@ let exec_single (conf : exec_conf) : mchn =
let new_pc = Sealable (Cap (p, g, b, e, Z.(a + imm))) in
(Running, upd_reg PC new_pc conf)
| _, _ -> fail_state))
let w = get_word conf c in
!>(upd_reg r w conf)
| Move (r, c) when (not (r = mtcc)) && not (c = Register mtcc) ->
| MoveSR (r, c) ->
if authorised_access_system_register conf
then let w = get_word conf c in !>(upd_reg r w conf)
else fail_state
| Move (r, c) when (not (r = mtdc)) && not (c = Register mtdc) ->
let w = get_word conf c in
!>(upd_reg r w conf)
| Load (r1, r2) when (not (r1 = mtdc)) && not (r2 = mtdc) -> (
Expand Down

0 comments on commit 939a61e

Please sign in to comment.