|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 11 - Architectural Invariants |
This chapter defines the architectural invariants of EmulatR.
An architectural invariant is a rule that:
Must always hold true
Is independent of implementation details
Cannot be violated by optimization
Defines correctness, not performance
If an invariant is violated, the emulator is architecturally incorrect, even if it appears to work.
These invariants apply across:
Single-CPU and SMP systems
PAL and non-PAL execution
All pipeline stages
All device and MMIO interactions
All exceptions are precise
When an exception is delivered:
All prior instructions have completed
No later instruction has modified architectural state
No instruction partially commits
There are no imprecise exceptions in EmulatR.
Architectural state commits only in Writeback
No instruction updates architectural state earlier
Speculative results are never visible
This applies to:
Registers
PC
Condition codes
Memory visibility
All instruction semantics execute in EX stage
Memory operations occur in EX via MBox
Other pipeline stages perform bookkeeping only
No architectural work occurs outside EX.
No speculative instruction may execute past:
MB
WMB
EXCB
TRAPB
CALL_PAL
HW_REI
Serialization points are absolute.
Memory is weakly ordered
Loads and stores may reorder
Stores may be deferred
Visibility is not guaranteed without barriers
No implicit ordering exists.
Ordering is enforced only by:
MB / WMB
EXCB / TRAPB
PAL entry / exit
Certain MMIO semantics
Any code relying on implicit ordering is incorrect.
MMIO accesses are strongly ordered
MMIO accesses are synchronous
MMIO accesses are never buffered
MMIO accesses are never speculative
MMIO correctness overrides performance.
LL/SC uses reservations, not locks
Reservations are:
Per-CPU
Cache-line granular
Optimistic
Non-blocking
No mutex semantics exist.
A CPU may hold at most one reservation
Reservations are cleared on:
Any store to the cache line
Any store by the same CPU
MB / EXCB where required
PAL entry or exit
Exception or interrupt delivery
Context switch
Reservations never survive privilege boundaries.
ST*_C must:
Succeed only if reservation is valid
Fail otherwise
Clear reservation regardless of outcome
No retries are implicit.
Execution is either PAL or non-PAL
There is no intermediate privilege state
Privilege cannot be escalated incrementally
CALL_PAL is the only entry into PAL
HW_REI is the only exit from PAL
Any other path is illegal and must fault.
PAL entry captures full architectural state
HW_REI restores full architectural state
No partial restoration is permitted
No PAL state leaks into non-PAL execution
Faults are synchronous
Traps are synchronous but post-commit
Interrupts are asynchronous
Each follows distinct delivery rules.
Only one exception or interrupt is delivered at a time
Exceptions are prioritized deterministically
Interrupts are maskable and deferrable
Faults affect only the current CPU
All exceptions and interrupts enter PAL
No exception bypasses PAL
PAL is the sole authority for dispatch
All CPUs are peers
No CPU has implicit authority
No global CPU lock exists
Each CPU has independent:
Pipeline
Registers
TLBs
Write buffers
Reservations
PAL state
No CPU directly mutates another CPU’s private state.
GuestMemory is shared
Visibility is not immediate
Coordination occurs only through:
Barriers
IPIs
PAL operations
Devices operate asynchronously
CPU never blocks on device execution
Completion is interrupt-driven or polled
MMIO access is synchronous
Side effects occur immediately
MMIO is strongly ordered
DMA operates on GuestMemory
DMA obeys access permissions
DMA completion does not imply ordering without barriers
Given the same inputs, execution is deterministic
SMP ordering differences are intentional and observable
No hidden timing dependencies exist
Every architectural event is traceable:
Exceptions
Interrupts
Barriers
PAL transitions
Reservation changes
MMIO accesses
If it cannot be traced, it cannot be trusted.
Any violation of an architectural invariant indicates:
A design bug, or
An implementation defect
Performance, convenience, or simplicity never justify violating an invariant.
Architectural invariants define what EmulatR is.
Key guarantees:
Precise execution
Explicit ordering
Absolute privilege separation
Deterministic SMP behavior
Correct atomic semantics
Strong MMIO correctness
PAL-mediated control
Full observability
These invariants are the foundation on which all future features must stand.
Where This Chapter Fits
This chapter should be treated as:
A correctness checklist
A validation guide
A regression test oracle
A contributor contract