Skip to content

Commit 0b25388

Browse files
authored
Merge pull request herd#1614 from diaolo01/mte-async-bug
[herd] Bug fix: fault handler must not be entered when using MTE async
2 parents cfe6d3b + 39c9b4c commit 0b25388

7 files changed

Lines changed: 77 additions & 15 deletions

File tree

herd/AArch64Sem.ml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,21 +1363,23 @@ module Make
13631363

13641364
let lift_fault_memtag mfault mm dir ii =
13651365
let lbl_v = get_instr_label ii in
1366-
if has_handler ii then
1367-
fun ma ->
1368-
M.bind_ctrldata ma (fun _ -> mfault >>| set_elr_el1 lbl_v ii) >>!
1369-
B.fault [AArch64Base.elr_el1, lbl_v]
1370-
else
1371-
let open Precision in
1372-
match C.mte_precision,dir with
1373-
| (Synchronous,_)|(Asymmetric,(Dir.R)) ->
1374-
fun ma -> ma >>*= (fun _ -> mfault >>| set_elr_el1 lbl_v ii) >>!
1375-
B.fault [AArch64Base.elr_el1, lbl_v]
1376-
| (Asynchronous,_)|(Asymmetric,Dir.W) ->
1377-
fun ma ->
1378-
let set_tfsr = write_reg AArch64Base.tfsr V.one ii in
1379-
let ma = ma >>*== (fun a -> (set_tfsr >>| mfault) >>! a) in
1380-
mm ma >>! B.Next []
1366+
let open Precision in
1367+
match C.mte_precision, dir with
1368+
| (Synchronous, _)
1369+
| (Asymmetric, Dir.R) ->
1370+
let mexc _ =
1371+
mfault >>| set_elr_el1 lbl_v ii >>!
1372+
B.fault [AArch64Base.elr_el1, lbl_v] in
1373+
if has_handler ii then
1374+
fun ma -> M.bind_ctrldata ma mexc
1375+
else
1376+
fun ma -> ma >>*= mexc
1377+
| (Asynchronous,_)
1378+
| (Asymmetric,Dir.W) ->
1379+
fun ma ->
1380+
let set_tfsr = write_reg AArch64Base.tfsr V.one ii in
1381+
let ma = ma >>*== (fun a -> (set_tfsr >>| mfault) >>! a) in
1382+
mm ma >>! B.Next []
13811383

13821384
(* KVM mode *)
13831385

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
AArch64 F001
2+
(* test must not enter fault handler when mte_precision is async *)
3+
variant=mte,async
4+
{
5+
[tag(x)]=:green;
6+
0:X1=x:red;
7+
}
8+
P0 | P0.F ;
9+
STR W0,[X1] | MOV W2,#1 ;
10+
forall(0:X2=0)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Test F001 Required
2+
States 1
3+
0:X2=0;
4+
Ok
5+
Witnesses
6+
Positive: 1 Negative: 0
7+
Condition forall (0:X2=0)
8+
Observation F001 Always 1 0
9+
Hash=2d337b1db56e968a8b4aa52898d6683a
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
AArch64 F002
2+
(* test must enter fault handler when mte_precision is default:sync *)
3+
variant=mte
4+
{
5+
[tag(x)]=:green;
6+
0:X1=x:red;
7+
}
8+
P0 | P0.F ;
9+
STR W0,[X1] | MOV W2,#1 ;
10+
forall(0:X2=1)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Test F002 Required
2+
States 1
3+
0:X2=1;
4+
Ok
5+
Witnesses
6+
Positive: 1 Negative: 0
7+
Condition forall (0:X2=1)
8+
Observation F002 Always 1 0
9+
Hash=2d337b1db56e968a8b4aa52898d6683a
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
AArch64 F003
2+
Variant=mte,asym
3+
{
4+
0:X1=x:red;
5+
1:X1=x:red;
6+
}
7+
P0 | P0.F | P1 | P1.F ;
8+
LDR W0,[X1] | MOV W2,#3 | MOV W0,#2 | MOV W2,#3 ;
9+
| | STR W0,[X1] | ;
10+
forall(0:X2=3 /\ 1:X2=0)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Test F003 Required
2+
States 1
3+
0:X2=3; 1:X2=0;
4+
Ok
5+
Witnesses
6+
Positive: 1 Negative: 0
7+
Condition forall (0:X2=3 /\ 1:X2=0)
8+
Observation F003 Always 1 0
9+
Hash=c721899d1198ef9b8d0385d633e7bd6c
10+

0 commit comments

Comments
 (0)