Documentation

Miri.Concurrency.AtomicAccess

Atomic intrinsic ordering and access checks #

This module ports the ordered pre-memory portion of Miri's atomic path: machine.rs converts intrinsic orderings before calling the atomic operation, and data_race.rs::atomic_access_check derives the required alignment from the access size, checks it, resolves allocation identity, then applies the read-only-memory rules. The pointer resolver, machine alignment policy, live allocation lookup, and mutability lookup are explicit callbacks because they belong to the concrete interpreter state.

This does not perform a scalar load/store, RMW calculation, bounds/permission hook, or the later race-clock and store-buffer updates. Callers pass callbacks closed over the actual place and must invoke this check before those effects, matching Miri's source order.

The access class tested by atomic_access_check.

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The first read-only-memory restriction selected by the source match.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          inductive Miri.Concurrency.AtomicAccessError (PointerError MutabilityError : Type) :

          Failures from the source-owned stages of atomic_access_check. The alignment-construction and allocation-expectation variants record the pinned Rust unwrap/expect boundaries; they are never treated as successful accesses.

          Instances For
            @[instance_reducible]
            instance Miri.Concurrency.instDecidableEqAtomicAccessError {PointerError✝ MutabilityError✝ : Type} [DecidableEq PointerError✝] [DecidableEq MutabilityError✝] :
            DecidableEq (AtomicAccessError PointerError✝ MutabilityError✝)
            Equations
            def Miri.Concurrency.instDecidableEqAtomicAccessError.decEq {PointerError✝ MutabilityError✝ : Type} [DecidableEq PointerError✝] [DecidableEq MutabilityError✝] (x✝ x✝¹ : AtomicAccessError PointerError✝ MutabilityError✝) :
            Decidable (x✝ = x✝¹)
            Equations
            Instances For
              def Miri.Concurrency.instReprAtomicAccessError.repr {PointerError✝ MutabilityError✝ : Type} [Repr PointerError✝] [Repr MutabilityError✝] :
              AtomicAccessError PointerError✝ MutabilityError✝ → Nat → Std.Format
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[instance_reducible]
                instance Miri.Concurrency.instReprAtomicAccessError {PointerError✝ MutabilityError✝ : Type} [Repr PointerError✝] [Repr MutabilityError✝] :
                Repr (AtomicAccessError PointerError✝ MutabilityError✝)
                Equations
                structure Miri.Concurrency.AtomicAccessOps (AllocId PointerError MutabilityError : Type) :

                Interpreter-owned callbacks used by the source atomic access check. pointerTryGetAllocId is the ptr_try_get_alloc_id(ptr, 0) operation. Its address error is kept distinct because the pinned source immediately calls expect on this result.

                Instances For
                  def Miri.Concurrency.atomicAccessCheck {AllocId PointerError MutabilityError : Type} (size pointerSize : ABI.Size) (kind : AtomicAccessKind) (ops : AtomicAccessOps AllocId PointerError MutabilityError) :
                  Except (AtomicAccessError PointerError MutabilityError) Unit

                  Port of atomic_access_check after its concrete MPlace callbacks are supplied. The order is size-to-alignment conversion, pointer alignment, allocation identity, mutability lookup, and the ordered read-only rules.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    inductive Miri.Concurrency.AtomicIntrinsicError (PointerError MutabilityError : Type) :

                    Errors before an atomic operation reaches its place access check. Invalid read/write/fence orderings correspond to the pinned conversion panics and are kept explicit rather than weakened.

                    Instances For
                      def Miri.Concurrency.instDecidableEqAtomicIntrinsicError.decEq {PointerError✝ MutabilityError✝ : Type} [DecidableEq PointerError✝] [DecidableEq MutabilityError✝] (x✝ x✝¹ : AtomicIntrinsicError PointerError✝ MutabilityError✝) :
                      Decidable (x✝ = x✝¹)
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[instance_reducible]
                        instance Miri.Concurrency.instDecidableEqAtomicIntrinsicError {PointerError✝ MutabilityError✝ : Type} [DecidableEq PointerError✝] [DecidableEq MutabilityError✝] :
                        DecidableEq (AtomicIntrinsicError PointerError✝ MutabilityError✝)
                        Equations
                        def Miri.Concurrency.instReprAtomicIntrinsicError.repr {PointerError✝ MutabilityError✝ : Type} [Repr PointerError✝] [Repr MutabilityError✝] :
                        AtomicIntrinsicError PointerError✝ MutabilityError✝ → Nat → Std.Format
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          @[instance_reducible]
                          instance Miri.Concurrency.instReprAtomicIntrinsicError {PointerError✝ MutabilityError✝ : Type} [Repr PointerError✝] [Repr MutabilityError✝] :
                          Repr (AtomicIntrinsicError PointerError✝ MutabilityError✝)
                          Equations
                          def Miri.Concurrency.prepareAtomicLoad {AllocId PointerError MutabilityError : Type} (ordering : AtomicOrdering) (size pointerSize : ABI.Size) (ops : AtomicAccessOps AllocId PointerError MutabilityError) :
                          Except (AtomicIntrinsicError PointerError MutabilityError) AtomicReadOrd

                          Machine atomic_load: ordering conversion precedes the access check.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Miri.Concurrency.prepareAtomicStore {AllocId PointerError MutabilityError : Type} (ordering : AtomicOrdering) (size pointerSize : ABI.Size) (ops : AtomicAccessOps AllocId PointerError MutabilityError) :
                            Except (AtomicIntrinsicError PointerError MutabilityError) AtomicWriteOrd

                            Machine atomic_store: ordering conversion precedes the access check.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def Miri.Concurrency.prepareAtomicRmw {AllocId PointerError MutabilityError : Type} (ordering : AtomicOrdering) (size pointerSize : ABI.Size) (ops : AtomicAccessOps AllocId PointerError MutabilityError) :
                              Except (AtomicIntrinsicError PointerError MutabilityError) AtomicRwOrd

                              Machine atomic_rmw: its ordering conversion accepts every ordering, then the shared atomic access check runs before the interpreter reads memory.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Miri.Concurrency.prepareAtomicCompareExchange {AllocId PointerError MutabilityError : Type} (successOrdering failureOrdering : AtomicOrdering) (size pointerSize : ABI.Size) (ops : AtomicAccessOps AllocId PointerError MutabilityError) :
                                Except (AtomicIntrinsicError PointerError MutabilityError) (AtomicRwOrd × AtomicReadOrd)

                                Machine compare-exchange converts the success ordering, then the failure read ordering, before atomic_compare_exchange performs its access check.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  A single-thread fence is a source NOP and skips ordering conversion. A multithread fence uses the checked AtomicFenceOrd::from conversion.

                                  Equations
                                  Instances For