zorro_device: let bus-master DMA reach motherboard and accelerator RAM#264
Merged
Merged
Conversation
The Zorro DMA address decode stopped at chip, slow, and Zorro-board RAM, so a bus master's reads of the motherboard (mb_ram) and CPU-slot (accel_ram) banks returned the 0xFF unmapped sentinel and its writes were dropped. A Zorro III master like the A4091 drives full 32-bit addresses and reaches those banks; with the A4000 profile fitting its stock RAM there, the guest allocates the driver's DMA buffers in motherboard RAM, so the SCSI bus scan read garbage and found no units. Decode both banks in all four dma_read/write byte and word helpers, next to the slow-RAM arm. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression where Zorro III bus-master DMA (e.g. the A4091 on the A4000 profile) could not access the 32-bit motherboard and CPU-slot accelerator RAM banks, causing DMA reads to return unmapped 0xFF and DMA writes to be dropped.
Changes:
- Extend
DeviceHostDMA address decoding to includemb_ramandaccel_ramfor both word and byte DMA helpers. - Add a unit test covering DMA round-trips through the motherboard and accelerator RAM banks.
Comments suppressed due to low confidence (1)
src/zorro_device.rs:76
- The new motherboard/accelerator word-write bounds checks use
a + 1 < base + len, which can overflow for large DMA addresses and lead to out-of-bounds panics. Prefer computing a wrapping offset and checkingoff + 1 < lenon that offset.
let mb = mem.mb_ram_base() as usize;
if a >= mb && a + 1 < mb + mem.mb_ram.len() {
let o = a - mb;
mem.mb_ram[o] = (w >> 8) as u8;
mem.mb_ram[o + 1] = w as u8;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The motherboard/accelerator arms tested `a + 1 < base + len`, which wraps when the DMA address is at the top of the space on a 32-bit usize host. Since the `a >= base` guard runs first, bound the access by the offset `a - base` instead, which cannot overflow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
LinuxJedi
approved these changes
Jul 23, 2026
LinuxJedi
left a comment
Collaborator
There was a problem hiding this comment.
Good catch. Many thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The A4091 (and any Zorro III bus master) could no longer scan its SCSI bus on
the A4000 profile: the autoboot ROM and driver run, but no units are found.
This regressed after v0.12.0, when two commits added the motherboard fast-RAM
bank (
mb_ram, ending at$08000000) and the CPU-slot accelerator bank(
accel_ram, starting at$08000000). The A4000 profile fits its stockmotherboard RAM by default, and exec adds it as high-priority LOCAL|FAST, so
the guest allocates the driver's DMA structures there.
Root cause
Zorro bus-master DMA goes through
DeviceHost::dma_read/dma_write, whoseaddress decode only handled chip RAM, slow RAM, and Zorro-board RAM. A Zorro III
master drives full 32-bit addresses, but the two new banks were not in the
decode, so reads of them returned the
0xFFunmapped sentinel and writes weredropped. The driver's SELECT then read a garbage target ID out of motherboard
RAM and the scan came up empty. (A Zorro II master like the A2091 only drives
the low 24 bits and never reaches these banks, so it is unaffected.)
Fix
Decode
mb_ramandaccel_ramin all fourdma_read/dma_writebyte and wordhelpers, next to the existing slow-RAM arm. New unit test
dma_round_trips_motherboard_and_accelerator_ram;cargo fmt/clippyclean.Verified end to end: with the fix, the A4091's SCSI drives scan and mount on
boot; without it, none appear.