Skip to content

Enforce MMIO/passthrough overlap invariant with atomic replace + rollback #385

Description

@Solicey

Follow-up to #384.

#384 currently only logs a warning when an MMIO handler and a passthrough region overlap, in both directions: a handler registered over an existing passthrough region, and a BAR/ROM passthrough remapped over an existing handler.

The warning does not enforce the invariant: the overlapping region is still accepted, and the actual failure is only deferred to a later access path. It is meant as a debugging aid, not a safety guarantee.

A proper fix would:

  • Add atomic replacement APIs in ZoneInner, e.g. replace_mmio_handler(old_region, new_region) and replace_passthrough_region(old_region, new_region).
  • Validate the new range while excluding the old region, perform the update as one operation, and restore the old mapping on failure.
  • Remove the duplicated preflight checks and manual rollback in the PCI BAR/MSI-X/ROM paths; callers should rely on these APIs instead.
  • Keep mmio_region_register as the final invariant guard, and reject duplicate registrations with a different size.

This would let the overlap check reject bad configs transactionally instead of only warning about them.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfeatureNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions