3 ms·
Indeed we thought this would be a challenge and I didn’t explain this aspect in the blog post. But on this chip, DMA is its own peripheral and the DMA periphera
by bkettle 3y ago
Indeed we thought this would be a challenge and I didn’t explain this aspect in the blog post. But on this chip, DMA is its own peripheral and the DMA peripheral is not used by the USB driver. Instead, the USB peripheral and the main CPU share a small memory region. The USB peripheral is then programmed in terms of offsets into this shared memory region, rather than physical memory addresses—-the USB peripheral does not have access to all of physical memory. This is discussed at the bottom of page 48 of the thesis itself [1].
This saved a lot of trouble, but in intro work on this I was using another chip (nRF52840) that worked the way you describe. To safely handle DMA in that case, without an IOMMU, we had to add somewhat complex reasoning that looked at each memory read and write to see if it was modifying a DMA control register and reject the write if it could lead to unsafe behavior. More info is on pages 52-55 of the thesis PDF.
This was pretty messy, so it was fortunate that the chip we used had a different plan. Let me know if I’m misunderstanding you!
[1]: https://pdos.csail.mit.edu/papers/bkettle-meng.pdf#page48 https://pdos.csail.mit.edu/papers/bkettle-meng.pdf#page48
- westurner 3y agoAre there NX pages/flags?
- westurner 3y agoNX bit: https://en.wikipedia.org/wiki/NX_bit https://en.wikipedia.org/wiki/NX_bit Tagged architecture / Memory tagging: https://en.wikipedia.org/wiki/Tagged_architecture https://en.wikipedia.org/wiki/Tagged_architecture & type unions Harvard architecture > memory details > Contrast with modified Harvard architecture: https://en.wikipedia.org/wiki/Harvard_architecture#Contrast_with_modified_Harvard_architecture https://en.wikipedia.org/wiki/Harvard_architecture#Contrast_... IIUC Ideally there should be an NX bit on pages, registers, names, and/or variables; and the programming language supports it. (IIRC, with CPython the NX bit doesn't work when any imported C extension has nested functions / trampolines?)