|
| 1 | +(* |
| 2 | + * The Armv8 Application Level Memory Model. |
| 3 | + * |
| 4 | + * This is a machine-readable, executable and formal artefact, which aims to be |
| 5 | + * the latest stable version of the Armv8 memory model. |
| 6 | + * If you have comments on the content of this file, please send an email to |
| 7 | + * memory-model@arm.com |
| 8 | + * For a textual version of the model, see section B2.3 of the Armv8 ARM: |
| 9 | + * https://developer.arm.com/documentation/ddi0487/ |
| 10 | + * |
| 11 | + * Authors: |
| 12 | + * Will Deacon <will.deacon@arm.com> |
| 13 | + * Jade Alglave <jade.alglave@arm.com> |
| 14 | + * Nikos Nikoleris <nikos.nikoleris@arm.com> |
| 15 | + * Artem Khyzha <artem.khyzha@arm.com> |
| 16 | + * |
| 17 | + * Copyright (C) 2016-present, Arm Ltd. |
| 18 | + * All rights reserved. |
| 19 | + * |
| 20 | + * Redistribution and use in source and binary forms, with or without |
| 21 | + * modification, are permitted provided that the following conditions are |
| 22 | + * met: |
| 23 | + * |
| 24 | + * * Redistributions of source code must retain the above copyright |
| 25 | + * notice, this list of conditions and the following disclaimer. |
| 26 | + * * Redistributions in binary form must reproduce the above copyright |
| 27 | + * notice, this list of conditions and the following disclaimer in |
| 28 | + * the documentation and/or other materials provided with the |
| 29 | + * distribution. |
| 30 | + * * Neither the name of ARM nor the names of its contributors may be |
| 31 | + * used to endorse or promote products derived from this software |
| 32 | + * without specific prior written permission. |
| 33 | + * |
| 34 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
| 35 | + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 36 | + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 37 | + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 38 | + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 39 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 40 | + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 41 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 42 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 43 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 44 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 45 | + *) |
| 46 | + |
| 47 | +catdep (* This option says that the cat file computes dependencies *) |
| 48 | + |
| 49 | +include "aarch64hwreqs.cat" |
| 50 | + |
| 51 | +(*** Coherence-after ***) |
| 52 | +let ca = fr | co |
| 53 | + |
| 54 | +(*** TLBI-after, DC-after, IC-after ***) |
| 55 | +include "enumerations.cat" |
| 56 | +with TLBI-after from (all-TLBI-Imp_TTD_R-enums local-hw-reqs) |
| 57 | +with DC-after from (all-DC-Exp_W-enums local-hw-reqs) |
| 58 | +with IC-after from (all-IC-Imp_Instr_R-enums local-hw-reqs) |
| 59 | + |
| 60 | +(*** Hazard-ordered-before ***) |
| 61 | + |
| 62 | +(** Explicitly-hazard-ordered-before **) |
| 63 | +let Exp-haz-ob = |
| 64 | + [Exp & R]; (po & same-loc); [Exp & R]; sca-class?; [Exp & R]; (ca & ext); [Exp & W]; sca-class?; [Exp & W] |
| 65 | + |
| 66 | +(** TLBI-ordered-before **) |
| 67 | + |
| 68 | +(* TTD-read-ordered-before *) |
| 69 | +let TTD-read-ordered-before = |
| 70 | + TLBI-after; [TLBI]; po; [dsb.full]; po; [~(Imp & M)] |
| 71 | + | TLBI-after; [TLBI]; po; [dsb.full]; po; [IFB]; po; [Imp & M] |
| 72 | + | (if "ETS2" || "ETS3" then TLBI-after; [TLBI]; po; [dsb.full]; po; [Imp & TTD & M] else 0) |
| 73 | + |
| 74 | +(* TLBI-ordered-before *) |
| 75 | +let TLBI-ob = |
| 76 | + TTD-read-ordered-before |
| 77 | + | tr-ib^-1; TTD-read-ordered-before & ext |
| 78 | + | po-va-loc; TTD-read-ordered-before & ext |
| 79 | + |
| 80 | +(** IC-ordered-before **) |
| 81 | + |
| 82 | +(* Instr-read-ordered-before *) |
| 83 | +let Instr-read-ordered-before = |
| 84 | + IC-after; [IC]; po; [dsb.full]; po; [~(Imp & M)] |
| 85 | + | (if "DIC" then ca else 0) |
| 86 | + |
| 87 | +(* IC-ordered-before *) |
| 88 | +let IC-ob = [Imp & Instr & R]; po; [Imp & Instr & R]; Instr-read-ordered-before |
| 89 | + |
| 90 | +(* Hazard-ordered-before *) |
| 91 | +let haz-ob = |
| 92 | + Exp-haz-ob | TLBI-ob | IC-ob |
| 93 | + |
| 94 | +(*** Hardware-required-ordered-before ***) |
| 95 | +let hw-reqs = local-hw-reqs | haz-ob |
| 96 | + |
| 97 | +(*** Observed-by ***) |
| 98 | + |
| 99 | +(** Explicitly-observed-by **) |
| 100 | +let Exp-obs = |
| 101 | + [Exp & M]; rf & ext; [Exp & M] |
| 102 | + | [Exp & M]; ca & ext; [Exp & M] |
| 103 | + |
| 104 | +(** Tag-observed-by **) |
| 105 | +let Tag-obs = |
| 106 | + [Exp & W]; rf & ext; [Imp & Tag & R] |
| 107 | + | [Imp & Tag & R]; ca & ext; [Exp & W] |
| 108 | + |
| 109 | +(** TTD-observed-by **) |
| 110 | + |
| 111 | +(* TLBUncacheable-coherence-after *) |
| 112 | +let TLBuncacheable-ca = |
| 113 | + [range([TLBUncacheable & FAULT]; tr-ib^-1; [Imp & TTD & R])]; ca; [Exp & W | HU] |
| 114 | + |
| 115 | +(* Hardware-update-coherence-after *) |
| 116 | +let HU-ca = |
| 117 | + [Exp & R]; ca; [HU] |
| 118 | + |
| 119 | +(* TLBI-coherence-after *) |
| 120 | +let TLBI-ca = |
| 121 | + [TLBI]; TLBI-after; [Imp & TTD & R]; ca; [W] |
| 122 | + |
| 123 | +(* TTD-observed-by *) |
| 124 | +let TTD-obs = |
| 125 | + [Imp & TTD]; rf | rf; [Imp & TTD] |
| 126 | + | TLBuncacheable-ca |
| 127 | + | HU-ca |
| 128 | + | [HU]; ca; [W] | [W]; ca; [HU] |
| 129 | + | TLBI-ca |
| 130 | + |
| 131 | +(** Instr-observed-by **) |
| 132 | + |
| 133 | +(* IC-coherence-after *) |
| 134 | +let IC-ca = |
| 135 | + (if not "DIC" && not "IDC" then [IC]; IC-after; [Imp & Instr & R]; ca; [W]; DC-after; [DC.CVAU] else 0) |
| 136 | + | (if not "DIC" && "IDC" then [IC]; IC-after; [Imp & Instr & R]; ca; [W] else 0) |
| 137 | + | (if "DIC" && "IDC" then [Imp & Instr & R]; ca; [W] else 0) |
| 138 | + |
| 139 | +(* Instr-observed-by *) |
| 140 | +let Instr-obs = |
| 141 | + rf; [Imp & Instr & R] |
| 142 | + | IC-after |
| 143 | + | [DC.CVAU]; DC-after; [W] | [W]; DC-after; [DC.CVAU] |
| 144 | + | IC-ca |
| 145 | + |
| 146 | +(** Observed-by **) |
| 147 | +let obs = |
| 148 | + Exp-obs; sca-class? |
| 149 | + | Tag-obs; sca-class? |
| 150 | + | TTD-obs |
| 151 | + | Instr-obs |
| 152 | + |
| 153 | +(*** Ordered-before ***) |
| 154 | +let rec ob = |
| 155 | + hw-reqs |
| 156 | + | obs |
| 157 | + | ob; ob |
| 158 | + |
| 159 | +(*** External visibility requirement ***) |
| 160 | +irreflexive ob as external |
| 161 | + |
| 162 | +(*** Internal visibility requirements ***) |
| 163 | +irreflexive [Exp & R]; ((po & same-loc) | rmw); [Exp & W]; rfi; [Exp & R] as coRW1-Exp |
| 164 | +irreflexive [Imp & Tag & R]; (po & same-loc); [Exp & Tag & W]; rfi; [Imp & Tag & R] as coRW1-MTE |
| 165 | +irreflexive [Exp & W]; (po & same-loc); [Exp & W]; (ca & int); [Exp & W] as coWW-Exp |
| 166 | +irreflexive [Exp & W]; (po & same-loc); [Exp & R]; (ca & int); [Exp & W] as coWR-Exp |
| 167 | +irreflexive [Exp & Tag & W]; (po & same-loc); [Imp & Tag & R]; (ca & int) as coWR-MTE |
| 168 | + |
| 169 | +(*** Atomic: LDXR/STXR, AMO and HU constraint to forbid intervening writes. ***) |
| 170 | +empty (rmw & (fr; co)) \ (([Exp]; rmw; [Exp]) & (fri ; [Exp & W]; coi)) as atomic |
| 171 | + |
| 172 | +(*** Break Before Make ***) |
| 173 | +let BBM = ([TTDV]; ca; [TTDINV]; co; [TTDV]) |
| 174 | +flag ~empty (TTD-update-needsBBM & ~BBM) as requires-BBM |
| 175 | + |
| 176 | +(*** Additional synchronisation requirements for CMODX ***) |
| 177 | +let CMODX-conflicts = same-loc & ( |
| 178 | + (Imp & Instr & R & Within-CMODX-List) * W |
| 179 | + | (Imp & Instr & R) * (Within-CMODX-List & W) |
| 180 | + | W * (Within-CMODX-List & Imp & Instr & R) |
| 181 | + | (Within-CMODX-List & W) * (Imp & Instr & R) |
| 182 | + ) |
| 183 | + |
| 184 | +let CMODX-ordering = |
| 185 | + [Imp & Instr & R]; ob; [W] |
| 186 | + | [W]; ob; [Imp & Instr & R] |
| 187 | + |
| 188 | +let CMODX-unordered-conflicts = |
| 189 | + CMODX-conflicts \ (CMODX-ordering | CMODX-ordering^-1) |
| 190 | + |
| 191 | +flag ~empty CMODX-unordered-conflicts as violates-CMODX-requirements |
0 commit comments