qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/2] hw/vfio/pci: Prevent BARs from being dma mapped in d3hot state
@ 2025-02-19 17:58 Eric Auger
  2025-02-19 17:58 ` [RFC 1/2] hw/vfio: Introduce vfio_is_dma_map_allowed() callback Eric Auger
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Eric Auger @ 2025-02-19 17:58 UTC (permalink / raw)
  To: eric.auger.pro, eric.auger, qemu-devel, alex.williamson, clg,
	zhenzhong.duan

Since kernel commit:
2b2c651baf1c ("vfio/pci: Invalidate mmaps and block the access
in D3hot power state")
any attempt to do an mmap access to a BAR when the device is in d3hot
state will generate a fault.

On system_powerdown, if the VFIO device is translated by an IOMMU,
the device is moved to D3hot state and then the vIOMMU gets disabled
by the guest. As a result of this later operation, the address space is
swapped from translated to untranslated. When re-enabling the aliased
regions, the RAM regions are dma-mapped again and this causes DMA_MAP
faults when attempting the operation on BARs.

To avoid doing the remap on those BARs, we compute whether the
device is in D3hot state and if so, skip the DMA MAP.

This series can be found at:
https://github.com/eauger/qemu/tree/d3hot_dma_map


Eric Auger (2):
  hw/vfio: Introduce vfio_is_dma_map_allowed() callback
  hw/vfio/pci: Prevents BARs from being dma mapped in d3hot state

 hw/vfio/common.c              | 57 +++++++++++++++++++++--------------
 hw/vfio/pci.c                 | 22 ++++++++++++++
 hw/vfio/trace-events          |  1 +
 include/hw/vfio/vfio-common.h | 11 +++++++
 4 files changed, 69 insertions(+), 22 deletions(-)

-- 
2.47.1



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-02-20 15:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 17:58 [RFC 0/2] hw/vfio/pci: Prevent BARs from being dma mapped in d3hot state Eric Auger
2025-02-19 17:58 ` [RFC 1/2] hw/vfio: Introduce vfio_is_dma_map_allowed() callback Eric Auger
2025-02-19 17:59 ` [RFC 2/2] hw/vfio/pci: Prevents BARs from being dma mapped in d3hot state Eric Auger
2025-02-19 18:58 ` [RFC 0/2] hw/vfio/pci: Prevent " Alex Williamson
2025-02-19 21:19   ` Alex Williamson
2025-02-20 10:31     ` Eric Auger
2025-02-20 10:45       ` Eric Auger
2025-02-20 15:07         ` Alex Williamson
2025-02-20 15:48           ` Alex Williamson
2025-02-20  4:24   ` Duan, Zhenzhong
2025-02-20  5:05     ` Alex Williamson
2025-02-20  8:25       ` Duan, Zhenzhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).