dmb

Data Memory Barrier (Thumb)

DMB <option>

Memory barrier (Thumb).

Details

Data Memory Barrier enforces completion of all explicit data memory operations before any subsequent memory operations are executed. It ensures memory ordering without requiring instruction completion. In Thumb mode, the option field (bits 3:0) specifies the barrier domain: SY (full system), ISH (inner shareable), OSH (outer shareable), or NSH (non-shareable). No condition flags are affected, and this instruction has no restrictions on execution state or privilege level.

Pseudocode Operation

if option == SY then
  DataMemoryBarrier(FullSystem)
else if option == ISH then
  DataMemoryBarrier(InnerShareable)
else if option == OSH then
  DataMemoryBarrier(OuterShareable)
else if option == NSH then
  DataMemoryBarrier(NonShareable)
else
  DataMemoryBarrier(FullSystem)

Example

DMB option

Encoding

Binary Layout
111100111011
1
1
1
1
10
0
0
1
1
1
1
0101
option
 
Format Thumb System
Opcode 0xF3BF8F50
Extension A32 (Base)

Operands

  • option
    SY/ISH

Reference (Arm AArch32 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0xF57FF050 DMB{<c>}{<q>} {<option>} A32 111101010111 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0101 | option
0xF3BF8F50 DMB{<c>}{<q>} {<option>} T32 111100111011 | 1 | 1 | 1 | 1 | 10 | 0 | 0 | 1 | 1 | 1 | 1 | 0101 | option

Description

Data Memory Barrier is a memory barrier that ensures the ordering of observations of memory accesses, see Data Memory Barrier (DMB).

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    MBReqDomain domain;
    MBReqTypes types;
    case option of
        when '0001'  domain = MBReqDomain_OuterShareable;  types = MBReqTypes_Reads;
        when '0010'  domain = MBReqDomain_OuterShareable;  types = MBReqTypes_Writes;
        when '0011'  domain = MBReqDomain_OuterShareable;  types = MBReqTypes_All;
        when '0101'  domain = MBReqDomain_Nonshareable;    types = MBReqTypes_Reads;
        when '0110'  domain = MBReqDomain_Nonshareable;    types = MBReqTypes_Writes;
        when '0111'  domain = MBReqDomain_Nonshareable;    types = MBReqTypes_All;
        when '1001'  domain = MBReqDomain_InnerShareable;  types = MBReqTypes_Reads;
        when '1010'  domain = MBReqDomain_InnerShareable;  types = MBReqTypes_Writes;
        when '1011'  domain = MBReqDomain_InnerShareable;  types = MBReqTypes_All;
        when '1101'  domain = MBReqDomain_FullSystem;      types = MBReqTypes_Reads;
        when '1110'  domain = MBReqDomain_FullSystem;      types = MBReqTypes_Writes;
        otherwise    domain = MBReqDomain_FullSystem;      types = MBReqTypes_All;

    if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then
        if HCR.BSU == '11' then
            domain = MBReqDomain_FullSystem;
        if HCR.BSU == '10' && domain != MBReqDomain_FullSystem then
            domain = MBReqDomain_OuterShareable;
        if HCR.BSU == '01' && domain == MBReqDomain_Nonshareable then
            domain = MBReqDomain_InnerShareable;

    DataMemoryBarrier(domain, types);