🐛 Make reims-graphics' pool pieces RAM devices, which vfio may skip
A VM with a vfio-pci device beside reims-graphics-pci ended as the guest's graphics driver started: "vfio_container_dma_map(..., 0xcc0000000, 0x1000000, ...) = -14 (Bad address)", then "vfio: DMA mapping failed, unable to continue" (steelbrain/reims-vgpu#213, a Linux host with an RX 6700 XT and a USB controller passed through). 0xcc0000000 is the guest's Shared pool's first piece, a 16 MiB block of the GPU's memory that the library has QEMU map into the guest. The host's mapping of that memory is a dma-buf's, which the IOMMU refused to map. vfio's listener maps every RAM section for the passed- through device's DMA, and at run time a refused map is a hardware error for plain RAM and a warning, once, for a RAM device (hw/vfio/listener.c). Each pool piece is now a RAM device (memory_region_init_ram_device_ptr), with no property or option. In this QEMU a RAM device is otherwise RAM: KVM's and WHPX's slot maps, HVF's, TCG's softmmu and a device's DMA (memory_access_is_direct, which reads memory_region_is_ram alone) take it as before. What changes besides vfio: vhost-vdpa skips it, a guest memory dump leaves it out, and `info mtree` names it ramd. The guest's RAM and BAR 2, the device's region, stay plain RAM: vfio maps them as before. (cherry picked from commit 325206b3c747feaa6675fcc9562680c21bf8cfe9)
This commit is contained in:
1 parent
d20c59a10e
commit
f073adfb3e
1 file changed
+16
-9
@@ -1280,12 +1280,19 @@ static void reims_graphics_routes_close(ReimsGraphicsPCIState *s)
|
||||
* which the library fills with blocks of host memory as the pool grows: one
|
||||
* piece a block, each its own RAM region (so the flat view never merges two,
|
||||
* and an add or a removal touches no other piece's KVM slot or WHPX mapping),
|
||||
* owned by an object of its own, a ReimsGraphicsPoolPiece. The library asks
|
||||
* on its threads (pool_add, pool_remove); the asks are queued and carried out
|
||||
* on the main loop, under the BQL, in order. Under WHPX the add's hypervisor
|
||||
* map runs on the asking thread first, outside the BQL (whpx_map_ahead), and
|
||||
* so does a removal's unmap (whpx_unmap_before_del); under KVM, a removal's
|
||||
* slot delete (kvm_unmap_before_del).
|
||||
* owned by an object of its own, a ReimsGraphicsPoolPiece. Each is a RAM
|
||||
* device: a block is the GPU's memory, which an IOMMU may refuse to map (a
|
||||
* host mapping of a dma-buf), and vfio's listener, which maps every RAM
|
||||
* section for a passed-through device's DMA, takes a refused map of a RAM
|
||||
* device as a warning, where at run time it ends QEMU for any other RAM
|
||||
* (hw/vfio/listener.c). A RAM device is otherwise RAM here: KVM's and WHPX's
|
||||
* maps, TCG's and a device's DMA (memory_access_is_direct) take it as any.
|
||||
*
|
||||
* The library asks on its threads (pool_add, pool_remove); the asks are queued
|
||||
* and carried out on the main loop, under the BQL, in order. Under WHPX the
|
||||
* add's hypervisor map runs on the asking thread first, outside the BQL
|
||||
* (whpx_map_ahead), and so does a removal's unmap (whpx_unmap_before_del);
|
||||
* under KVM, a removal's slot delete (kvm_unmap_before_del).
|
||||
*
|
||||
* A piece leaves the guest's address space at its removal, under the BQL, but
|
||||
* a flat view of an older generation or a device's DMA map
|
||||
@@ -1426,9 +1433,9 @@ static bool reims_graphics_pool_add(ReimsGraphicsPCIState *s,
|
||||
piece = REIMS_GRAPHICS_POOL_PIECE(object_new(TYPE_REIMS_GRAPHICS_POOL_PIECE));
|
||||
piece->s = s;
|
||||
piece->gpa = ask->gpa;
|
||||
memory_region_init_ram_ptr(&piece->mr, OBJECT(piece),
|
||||
"reims-graphics-pci.pool-piece", ask->size,
|
||||
ask->host);
|
||||
memory_region_init_ram_device_ptr(&piece->mr, OBJECT(piece),
|
||||
"reims-graphics-pci.pool-piece",
|
||||
ask->size, ask->host);
|
||||
/*
|
||||
* Inside the add's transaction: on its own, set_unmergeable commits
|
||||
* (and renders every flat view) for a region that is in none yet.
|
||||
|
||||
Reference in new issue
Block a user