Hi, Vivek, On Thu, Aug 03, 2023 at 08:08:41AM +0000, Kasireddy, Vivek wrote: > > Isn't it already too late though to wait that notification until page is > > installed? Because here you pinned the page for DMA, I think it means > > before a new page installed (but after the page is invalidated) the device > > can DMA to an invalid buffer. > > The page is only invalidated in the memfd. Until the hole is written to, > we (udmabuf) can choose to handle any reads (or DMA) using old pages > if needed. But what happens if there's DMA writes? I don't see anything that will stop the device from doing so - the whole design looks fully transparent, I just still don't see how it can be done without synchronizing with the device. IIUC, we need to e.g. quiesce the device when any page got invalidated in some way like hole punching, and should happen right before it happens (comparing to the notification of new page update which should be right after the installation OTOH). I think the vfio use case currently face the same condition and challenge, assuming there's currently no easy solution so that was just prohibited. I guess people are just waiting for hardware vendors to support device page faults, like processors - then we can synchronize with the device using the device IOMMU page tables (by clearing it at proper time and blocks DMA writes). Thanks, -- Peter Xu