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.
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:
replace_mmio_handler(old_region, new_region)andreplace_passthrough_region(old_region, new_region).mmio_region_registeras 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.