[gen] Add store-only variant#1843
Conversation
There was a problem hiding this comment.
Can you please explain how you chose these cycles/three tests?
There was a problem hiding this comment.
Given your comment, I have update some comments in the tests and also I add one more section. Now we have 3 set of tests:
store-onlycompletely removes the label and associated fault check, because there is no moreSTRafterwards to the same location.- The newly added section contains two tests that without
store-only, there are labels for bothSTRandLDRrespectively, while withstore-onlythe label toLDRis removed. LxSxtest, this is the most tricky case in technical sense, because it is a form ofrmwhowever it compiles to two separate instructions,LDXRandSTXR. In this case, the label is moved fromLDXRwithoutstore-onlytoSTXRwithstore-only.
cc24af5 to
578d0b9
Compare
Add a `StoreOnly` generator variant and emit it to herd metadata as `store-only`. For multi-instruction RMWs, carry memtag fault checks from the read event to the write event under `store-only`, so AArch64 `LxSx` generation labels the store-exclusive instruction rather than the load-exclusive instruction. Add `diyone7` regressions tests for the new metadata, read-side fault suppression, and the `LDXR` to `STXR` label-placement change.
b1a238b to
9655d3f
Compare
relokin
left a comment
There was a problem hiding this comment.
I think you have to be more specific about suppressing the fault check for loads. Take this test for example:
$> diyone7 -metadata false -arch AArch64 -variant vmsa,memtag,store-only -oneloc PteV0 TLBI-sync.ISHsWR ISB Fri
AArch64 CoWR0+tlbi-sync.ishsptev0p-[isb]-fripptev0
Variant=memtag store-only vmsa
{
[x]=1;
0:X0=PTE(x:red); 0:X1=(oa:PA(x), valid:0); 0:X2=x:red; 0:X4=x;
}
P0 ;
STR X1,[X0] ;
DSB ISH ;
LSR X5,X4,#12 ;
TLBI VAAE1IS,X5 ;
DSB ISH ;
ISB ;
LDR W3,[X2] ;
exists (true)
The LDR in this test needs to be checked for faults.
As a side comment, in the initialization, we shouldnot refer to PTE(x:red) but to PTE(x).
|
|
||
| exists ([tag(y)]=:blue /\ 0:X0=x:green /\ 1:X0=0 /\ not (fault(P1:L00,y))) | ||
| A memtag store-only comparison test against the version above on label `L00` | ||
| $ diyone7 -arch AArch64 -variant memtag,store-only DpDatadW T PosWW T Rfe PodRW Rfe T |
There was a problem hiding this comment.
BTW, I think it is problematic that by default diyone7 will give the same name to the test above and this test.
There was a problem hiding this comment.
I opened an issue #1898 for this. I will update it in a separate PR.
I will strengthen the WIll patch the [Update] I have patched the |
| let loc = match e.C.atom with | ||
| | Some (Pte _,_) -> loc | ||
| | _ -> add_tag loc e.C.tag in |
There was a problem hiding this comment.
Is there a reason why this check is not implemented inside add_tag?
There was a problem hiding this comment.
This existing function add_tag is frankly of bad name. It basically appends the tag value (second parameter) such as green and red, after the location (first parameter) such as x and y. We can move the check inside add_tag but we will need extra parameter to carry the atom value.
Let me move those check into add_tag in a separate commit and we can decide if we like this change.
There was a problem hiding this comment.
I update another wrapper function get_tagged_loc which includes the check on Pte. This function already take a node event e as the input so we get all the information we need. ref: 5692616
| let pte_val = get_pte_value st in | ||
| match () with | ||
| | _ when (st.check_fault = NoDir || do_no_fault) -> None,unset_check_fault st | ||
| | _ when do_store_only && dir = R |
There was a problem hiding this comment.
I am really struggling with the way fault_update is structured. Specifically, I don't understand why you do match () with.
But specifically the new code makes the whole logic even more complex. Can you please move this case below the | _ when kvm and merge it with | do_memtag.
I would also favour a complete rewrite of this along the lines of relokin@a107a85
There was a problem hiding this comment.
Let me rewrite this function here; I will put in a separate commit.
Here match ()-when is basically a if-else if chain.
There was a problem hiding this comment.
I just update in a new commit ref: 7c64a52. it is mostly what you proposed but the first match |_,_ when do_no_fault will short-circuit all the rest of update/check, rather than a if-else branch just decide the st value.
This adds a
StoreOnlygenerator variant formemtagvariant and emits it toherd7metadata asstore-only. The parser accepts bothStoreOnlyandstore-only, and validation requires it to be used together withmemtag.For multi-instruction RMWs, store-only carries the
memtagfault check from the read event to the write event. In particular, onAarch64LxSxinstruction's generated fault label moves from the load-exclusive instruction to the store-exclusive instruction, for example,diyone7 -arch AArch64 -variant memtag,store-only PodRW T Rfe LxSx PodWW RfeThis means:
cycle.ml, we changed fault-label assignment to be event-aware rather than passing only a direction. The new logic detects multi-instruction RMWs, such asLxSx, and under store-only suppresses the read-side fault label while preserving the pending fault-check state for the write event.AArch64Compile_gen.ml, we replaced the old “label the first instruction” viaadd_label_to_first_instructionshandling for exclusive RMW code with logic that recognises exclusive loads and stores separately viaadd_label_to_exclusive_load_and_store. ForLxSx, it can now attach the read event’s label toLDXR/LDAXR, and the write event’s label toSTXR/STLXR/STXP.