Study guides · Advanced

Virtualization permissions and faults: why a mapped address can still fail

Distinguish missing mappings, denied writes, and deliberate MMIO traps before choosing a response.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. Split failure into observable conditions
  2. Do not fabricate the output of a failed first stage
  3. A present mapping can deny a store
  4. Accept an intentional device trap only after validation
  5. Keep retry, completion, and rejection separate
  6. Check the whole range at a page boundary
  7. Exercise: assign different responses to three stops
  8. Ask Logeia about this articleCheck your understanding

Split failure into observable conditions

A stopped guest store might involve a wrong address, a missing allocation, denied permission, or intentional device interception. Similar visible symptoms do not imply the same cause. Record the operation, original VA, and how far each stage progressed. Do not invent an address for a stage that never completed. Classification determines the appropriate response.

Use a repeatable diagnostic order: input format, access kind, VM context, stage-1 outcome, stage-2 outcome, and permission. Editing a later condition cannot necessarily repair a failure that occurred earlier. Retaining each stop point is not about displaying as many numbers as a successful trace. It records what has been established and where knowledge ends, so subsequent investigation does not mistake an invented downstream value for an observed translation result.

Do not fabricate the output of a failed first stage

If stage 1 has no valid mapping for the VA page, the ordinary access has no resulting IPA. In this simplified arrangement, the guest OS handles the guest-side translation issue, while real routing can depend on additional configuration. The model leaves IPA and PA unset. A correct stage-2 table does not repair a missing stage-1 mapping.

With a missing stage-2 entry, the IPA has already been established. Compare that trace with a stage-1 stop, where only the VA is known. Real diagnostic records likewise need a useful classification and context while avoiding unnecessary sensitive values. Counting events under one generic fault label may be useful for volume, but it does not identify the responsible mapping owner or justify a particular repair. The teaching comparison makes that missing distinction concrete.

A present mapping can deny a store

A VA and IPA may map to existing RAM while the selected store is denied. Read-only shared data is one reason to allow reads without writes. Toggle read and write while keeping the target unchanged to observe that presence and permission are different. Copy-on-write is a possible additional policy, not an automatic consequence of every denied write.

A useful test keeps the address fixed, selects the read-only stage-2 variant, and runs one read and one write. The model expects the read to pass and the write to fail. If both pass, the interface may have changed a label without changing the engine input. If both fail, another condition such as a missing mapping may be present. A negative test is meaningful when its changed condition and expected failure reason are controlled.

python
# Permission policy for this small teaching model only.
def allowed(access, stage2_writable):
    if access not in {'read', 'write'}:
        raise ValueError('unsupported access')
    return access == 'read' or stage2_writable

assert allowed('read', False)
assert not allowed('write', False)
assert allowed('write', True)
print('read allowed; write denied')

Accept an intentional device trap only after validation

A virtual UART can be left without direct RAM mapping so EL2 handles its accesses. That does not make every stage-2 fault a UART operation. Check the registered device range, supported access width and direction, and validity of the exception information used for decoding. A mechanism that traps accesses and a policy that accepts a device operation are distinct decisions.

Even within a UART-related range, the first model distinguishes its supported data-register location from other unimplemented offsets. It accepts the selected 32-bit write at 0x09000000 but stops an access at 0x09000004 or an unsupported 64-bit access. Being inside a broad device range is necessary but not sufficient for a supported operation. An unchanged character value does not justify silently ignoring a changed register or transfer width.

ObservationClassification hereNext check
No stage-1 entryGuest translation failureGuest table and accessed range
Stage-2 RAM write deniedPermission failureSharing, protection, and recovery policy
Supported access in UART rangeCandidate device operationRange, width, direction, valid syndrome
Unregistered IPACandidate invalid accessIntended layout and rejection policy

Keep retry, completion, and rejection separate

A repaired RAM mapping may call for retrying the original instruction. A completed device emulation may resume after it under the instruction contract. An invalid operation needs its own rejection or guest-fault policy. The demonstration displays separate outcomes and records what was authorized or completed; it does not color every handled exit as a successful guest access.

Management code can successfully reject an operation while the guest operation itself fails. Tests should therefore check more than whether a handler returned without throwing. Assert that no output was added and no unauthorized state changed on the rejected path. Showing an error after performing the forbidden side effect would produce a convincing-looking failure message while violating the very boundary the lesson is intended to explain.

Check the whole range at a page boundary

A four-byte access starting at VA 0x1FFE touches two 4 KiB pages. Permission for the first page does not establish permission for the second. This is a range-analysis example, not a promise about instruction atomicity or partial effects on real hardware. A single-address model must mark unsupported cross-page operations rather than infer their success from the starting byte.

Extending the model to cross-page operations requires an explicit length input. Silently assigning a length to an address-only example hides what range was actually checked. An implementation exercise can derive the last addressed byte and reject overflow or unsupported ranges. When model scope expands, input contracts and negative cases must expand too. The existing single-address demonstration should not be presented as though it already validates every multi-byte access across page boundaries.

Exercise: assign different responses to three stops

A lacks a guest stage-1 mapping, B has a stage-2-denied write to mapped RAM, and C is a supported character write in a registered UART range. Investigate guest translation for A, protection and recovery policy for B, and device validation/emulation for C. Unconditionally exposing all RAM to fix B removes isolation instead of diagnosing the needed mapping. State whether the guest operation actually completed in each case.

Before proposing to repair a permission failure, recover the original protection objective. A shared read-only page may be working correctly by refusing writes. Eliminating every stop would then remove a valid boundary. A good answer first identifies the intended actor, target, and operation; it then decides whether rejection is a defect or the expected outcome. Only after that should it propose a narrowly scoped mapping or policy change and a test that demonstrates the intended behavior.

Try the interactive model

Two-stage address translation

Loading demo checkpoint…

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Build your CS foundations · STEP 16

Understand the systems behind the web · STEP 6

Prepare for AI systems · STEP 6

Choose a learning path