News for hackers. Stuff that matters.
Re:USB3: Why it's a bit harder than USB2 by numpad0 on Wednesday October 07, 2020 @06:05AM (#24706751)
DMA stands for Direct Memory Access, and it is called so for the fact that the peripheral device directly read from or write to memory bus while CPU is not accessing it. So CPU internal states or protection are in theory irrelevant.

In a most rudimentary implementation, a device doing DMA is physically wired to the main memory in parallel with CPU. The device will set something like `data, addr, CS, WR = 0xCAFE, 0x1000, TRUE, TRUE` and send a clock pulse. Then when CPU comes back to check address `0x1000`, the data `0xCAFE` is magically “there”, so programs on CPU don’t have to waste cycles polling the device to get the value. Naturally, some arbitration is necessary because trying to change bus states from both sides will mess things up.

Above was probably the case until 1980s or 90s, and DMA in modern days instead goes through bus masters and memory controllers. Since it’s not going directly to physical RAM anymore, such controllers can be configured in such ways as to prevent unwanted accesses.

But it’s more of “can be used to protect against”, not “won’t be possible if done correctly”.

Re:USB3: Why it's a bit harder than USB2 by wtallis on Wednesday October 07, 2020 @08:08AM (#24707368)
> So CPU internal states or protection are in theory irrelevant.

Go look up what IOMMU means. We're not talking about a feature inside an individual CPU core, but in the PCIe Root Complex that implements DMA capabilities in the first place; it's the thing that sits between peripheral devices and the DRAM controller. That functionality is on the CPU die these days.