[gen] Fix problems related to physical address change, annotation PteOA.#1707
[gen] Fix problems related to physical address change, annotation PteOA.#1707ShaleXIONG wants to merge 10 commits intoherd:masterfrom
PteOA.#1707Conversation
26ac7f6 to
f413a24
Compare
PteOA.PteOA.
PteOA.PteOA.
f413a24 to
5b3e8a5
Compare
gen/cycle.ml
Outdated
| (* TODO Rework here, esp the function `next_loc` and ref value `next_x_pred`. | ||
| They are all difficult to understand. *) | ||
| let next_x_pred = ref false in | ||
| (* Wrap the `new_physical_address` and `st` which might |
There was a problem hiding this comment.
I don't follow the logic of this code. Very few comments and where they exist they are stale.
This block would benefit from some comments and refactoring. As an example why the logic doesn't work take the produced by this:
$ diyone7 -metadata false -variant kvm -arch AArch64 PteOA TLBI-sync.ISHsWW PteOA TLBI-sync.ISHdWW Rfe DMB.LDdRR Fre
AArch64 MP+tlbi-sync.ishsWpteoapteoa-tlbi-sync.ishpteoap+dmb.ld
{ int z=5;
0:X0=PTE(x); 0:X1=(oa:PA(z)); 0:X2=(oa:PA(x)); 0:X4=y; 0:X5=x;
1:X4=y; 1:X5=x;
}
P0 | P1 ;
STR X1,[X0] | LDR W3,[X4] ;
DSB ISH | DMB LD ;
LSR X6,X5,#12 | LDR W6,[X5] ;
TLBI VAAE1IS,X6 | ;
DSB ISH | ;
STR X2,[X0] | ;
DSB ISH | ;
LSR X6,X5,#12 | ;
TLBI VAAE1IS,X6 | ;
DSB ISH | ;
MOV W3,#1 | ;
STR W3,[X4] | ;
exists ([PTE(x)]=(oa:PA(x)) /\ 1:X3=1 /\ 1:X6=0)
Why are we going from oa:PA(x) to oa:PA(z) back to oa:PA(x)?
Out of nowhere, the code introduces a constant 5 which is meant to be a good initial value for the fresh PA?
There was a problem hiding this comment.
I did the toggle behaviour on PteOA. However I checked the old behaviour which changes to the OA of a new location and never changes back. I will update to reflect this.
5 is a mistake, it should be 4, as the initial value is 0 now, and I preserve the old behaviour of gapping 4 so the read can reflect the value being read.
There was a problem hiding this comment.
I have updated the code, PteOA will always pick a new fresh location.
In the kvm/pte/vmsa variant, the new physical address will be picked freshly and then toggled between the original address and the newly picked address.
When there is a physical address change for a location. We will check the read values corresponding the underline physical address.
`PteOA` will no longer toggle the value of `OA` but change to a fresh location.
gen/cycle.ml
Outdated
| fun () -> | ||
| let new_loc = match !variable_counter with | ||
| | n when n <= 2 -> String.make 1 (Char.chr (Char.code 'x' + n)) | ||
| | n when n <= 26 -> String.make 1 (Char.chr (Char.code 'a' + n - 3)) |
There was a problem hiding this comment.
I think for n 26 this will return "x".
There was a problem hiding this comment.
ah yes, will fix with n<26
gen/common/value_gen.ml
Outdated
| Dir W and Dir R for write and read, respectively. | ||
| and Irr for both, NoDir for none *) | ||
| val need_check_fault : atom option -> Code.extr | ||
| (* check if the `pte_atom` trigger value for further access *) |
There was a problem hiding this comment.
I am not sure I understand this comment can you please rephase this.
There was a problem hiding this comment.
I have updated. It is a function for PteOA, as it leads to different physical locations, so further read to the same virtual address should have a value check.
This pull request (1) changes the behaviour of
PteOA, which now always picks a fresh physical address now, and (2) ensure the memory access correctly to the underline physical address.For example,
diyone7 -arch AArch64 -variant kvm PteOA PodWR Fre PodWR FreThe first
STRinstruction inP0writes a fresh locationPA(z)toPTE(x)given thePteOAannotation. It was previouslyPA(y). Because the new strategy always picks a fresh location/variable, we no longer need to initialise existing variable in1,5,9,...but now always initialise to 0. However the newly picked locationzwill be initialised to4,8,.... To recall, this is for distinguishing read from the original variable, e.g.x, and new variable, e.g.z.If multiple
PteOAannotation apply to the same virtual location, it will always pick a fresh location for theOA. For example,diyone7 -arch AArch64 -variant kvm PteOA PosWW PteOA Coi -onelocLast, we fixed a long existing problem: the read after changing of
PA. It now correctly checks the read value is from the newPA. For example,diyone7 -arch AArch64 -variant kvm PteOA PosWR Fre PteOA PosWR Fre -onelocPreviously, it was
0:X3=1, which was incorrect.