On 2020-06-01 22:28, Mathieu Poirier wrote:
That being said I'm sure that dependencies on an IOMMU isn't a problem confined
to coresight. I am adding Robin Murphy, who added this commit [1], to the thread
in the hope that he can provide guidance on the right way to do this.
Right, it's not specific to CoreSight, and it's not even specific to
IOMMUs really. In short, blame kexec ;)
The fundamental thing is that devices should stop any DMA activity at
shutdown. For a normal poweroff you can typically get away without
doing so, but over kexec, ongoing DMA traffic may corrupt memory in
the new kernel (at worst, I think even DMA reads could potentially
cause unexpected cache behaviour that might lead to mishaps, given the
right combination of memory attributes).
IOMMUs merely help to make the situation more serious. For similar
kexec reasons, they need to disable any existing translations at
shutdown (imagine if the second kernel didn't have an IOMMU driver).
And at that point, even the normal poweroff case becomes problematic,
because any device DMA that hasn't been shut down beforehand is now
not necessarily going benignly to memory as it would in the no-IOMMU
case above, but potentially to random physical addresses, with all the
hilarity ensuing that you would expect from that.