-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
FEAT_MTE_STORE_ONLY introduces control if Load instructions are Tag Unchecked. Let's add support for that feature, yet (as usual) we need to take extra care for CAS and friends: RMNHCZ If FEAT_MTE_STORE_ONLY is implemented, for a Tag Checked Compare and swap instruction, if the compare fails, it is CONSTRAINED UNPREDICTABLE whether the Tag Check operation is performed. Signed-off-by: Vladimir Murzin <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -603,7 +603,7 @@ module Make | |
|
||
(* Tag checking, MTE *) | ||
|
||
let delayed_check_tags a_virt a_phy ma ii m1 m2 = | ||
let delayed_check_tags dir a_virt a_phy ma ii m1 m2 = | ||
let (+++) = M.data_input_union in | ||
let rtag = | ||
read_tag_mem (match a_phy with None -> a_virt | Some a -> a) ii in | ||
|
@@ -615,15 +615,24 @@ module Make | |
let m = | ||
let (>>=) = match a_phy with None -> (+++) | Some _ -> (>>=) in | ||
m >>= fun cond -> commit +++ fun _ -> M.unitT cond in | ||
M.delay_kont "check_tags" m | ||
let check = M.delay_kont "check_tags" m | ||
(fun c m -> | ||
let ma = (* NB output to initial ma *) | ||
match a_phy with | ||
| None -> | ||
ma >>== fun a -> m >>== fun _ -> loc_extract a | ||
| Some _ -> | ||
M.bind_ctrldata ma (fun a -> m >>== fun _ -> M.unitT a) in | ||
choice c ma) | ||
choice c ma) in | ||
match (dir,C.mte_store_only) with | ||
| Dir.W,_ | ||
| Dir.R,false | ||
-> check | ||
| Dir.R,true | ||
-> | ||
(* The case of a failed CAS with no write, but with a tag chek *) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
let ma = ma >>= fun a -> loc_extract a in | ||
M.altT (check) (m1 ma) | ||
|
||
(* Tag checking Morello *) | ||
let do_append_commit ma txt ii = | ||
|
@@ -1377,7 +1386,7 @@ module Make | |
fault ma >>! B.Fault [] in | ||
let check_tag moa a_virt = | ||
let do_check_tag a_phy moa = | ||
delayed_check_tags a_virt (Some a_phy) moa ii mok mno in | ||
delayed_check_tags dir a_virt (Some a_phy) moa ii mok mno in | ||
M.delay_kont "check_tag" moa do_check_tag in | ||
let cond_check_tag mpte_t a_virt = | ||
(* Only read and check the tag if the PTE of the tag op allows it *) | ||
|
@@ -1410,7 +1419,7 @@ module Make | |
(fun a_virt ma -> | ||
let mm = mop Access.VIR in | ||
let ft = Some FaultType.AArch64.TagCheck in | ||
delayed_check_tags a_virt None ma ii | ||
delayed_check_tags dir a_virt None ma ii | ||
(fun ma -> mm ma >>= M.ignore >>= B.next1T) | ||
(lift_fault_memtag | ||
(mk_fault (Some a_virt) dir an ii ft None) mm dir ii)) | ||
|
@@ -1479,16 +1488,18 @@ module Make | |
else if checked then | ||
lift_memtag_virt mop ma dir an ii | ||
else | ||
let ma = if C.mte_store_only then ma >>= fun a -> loc_extract a else ma in | ||
mop Access.VIR ma >>= M.ignore >>= B.next1T | ||
|
||
let do_ldr rA sz an mop ma ii = | ||
(* Generic load *) | ||
lift_memop rA Dir.R false memtag | ||
let checked = memtag && not C.mte_store_only in | ||
lift_memop rA Dir.R false checked | ||
(fun ac ma _mv -> (* value fake here *) | ||
let open Precision in | ||
let memtag_sync = | ||
memtag && (C.mte_precision = Synchronous || | ||
C.mte_precision = Asymmetric) in | ||
checked && (C.mte_precision = Synchronous || | ||
C.mte_precision = Asymmetric) in | ||
if memtag_sync || Access.is_physical ac then | ||
M.bind_ctrldata ma (mop ac) | ||
else | ||
|
@@ -1956,7 +1967,7 @@ module Make | |
| RMW_A | RMW_AL -> A | ||
|
||
let swp sz rmw r1 r2 r3 ii = | ||
lift_memop r3 Dir.W true (* swp is a write for the purpose of DB *) | ||
lift_memop r3 Dir.W true (* swp is a write for the purpose of DB *) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
murzinv
Author
Contributor
|
||
memtag | ||
(fun ac ma mv -> | ||
let noret = match r2 with | AArch64.ZR -> true | _ -> false in | ||
|
@@ -3162,10 +3173,10 @@ module Make | |
else begin | ||
(* TODO: The size for DC should be a cache line *) | ||
let mop _ac a = dc_loc op a ii in | ||
let dir = match op.AArch64Base.DC.funct with | ||
| AArch64Base.DC.I -> Dir.W | ||
| _ -> Dir.R in | ||
lift_memop rd dir false memtag | ||
let dir,checked = match op.AArch64Base.DC.funct with | ||
| AArch64Base.DC.I -> Dir.W,memtag | ||
| _ -> Dir.R,memtag && not C.mte_store_only in | ||
lift_memop rd dir false checked | ||
This comment has been minimized.
Sorry, something went wrong.
artkhyzha
Collaborator
|
||
(fun ac ma _mv -> (* value fake here *) | ||
if Access.is_physical ac then | ||
M.bind_ctrldata ma (mop ac) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
AArch64 S00 | ||
variant=memtag,sync,store-only | ||
This comment has been minimized.
Sorry, something went wrong.
artkhyzha
Collaborator
|
||
{ | ||
int x=1; | ||
tag(x)=:red; | ||
0:X0=x:green; | ||
} | ||
P0 ; | ||
L0: ; | ||
LDR W1,[X0] ; | ||
L1: ; | ||
STR WZR,[X0]; | ||
forall fault(P0:L1,x) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Test S00 Required | ||
States 1 | ||
Fault(P0:L1,x:green,TagCheck); | ||
Ok | ||
Witnesses | ||
Positive: 1 Negative: 0 | ||
Condition forall (fault(P0:L1,x)) | ||
Observation S00 Always 1 0 | ||
Hash=5229396c405f2016eb0680a632b41e0f | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
AArch64 S01 | ||
variant=memtag,sync,store-only | ||
{ | ||
0:X9=x:red; | ||
} | ||
P0 ; | ||
MOV W0,#1 ; | ||
CAS W0,WZR,[X9] ; | ||
exists ~fault(P0,x) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Test S01 Allowed | ||
States 2 | ||
~Fault(P0,x); | ||
Fault(P0,x:red,TagCheck); | ||
Ok | ||
Witnesses | ||
Positive: 2 Negative: 3 | ||
Condition exists (not (fault(P0,x))) | ||
Observation S01 Sometimes 2 3 | ||
Hash=1f4ab0e23e8f6210451620fc77f6e82a | ||
|
Typo (chek -> check)