vfio-quirks: Pass the actual parent when deleting a memory region
RFC PATCH 1/1 vfio-quirks: Pass the actual parent when deleting a memory region
The usual way of using a quirk's MR is to add it as a subregion of a BAR as this is what quirks are for. However there is less than standard user of this - NVLink2-enabled NVIDIA GPU which exposes a GPU RAM and a ATSD 64K region outside of PCI MMIO window so these MRs get the system address space root as a parent. So when the user unplugs such device, assert occurs:
qemu-system-ppc64: /home/aik/p/qemu/memory.c:2391: memory_region_del_subregion: Assertion `subregion->container == mr' failed.
This passes the actual parent MR to memory_region_del_subregion() in vfio_bar_quirk_exit.
---
This removes an extra sanity check that a quirk has a correct parent; I am not sure if it is very useful.
I could use the "system" MR if quirk->mem[i].container==get_system_memory() and quirk->mem[i].container otherwise to keep that assert working.
Also this does not help with the actual device removal much because of the closed source driver nature - the associated service (nvidia-persistenced, responsible for onlining GPU memory) crashes the guest system but at least the user can reboot the guest after the crash which is not as bad as assert.
--- hw/vfio/pci-quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/vfio/pci-quirks.c +2 -1
@@ -1896,7 +1896,8 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) }for (i =0 ; i < quirk->nr_mem; i++) { -memory_region_del_subregion (bar->region.mem, &quirk->mem[i]); +memory_region_del_subregion (quirk->mem[i].container, + &quirk->mem[i]); } } }
Signature · 1 line
2.17.1
Quoted 7 lines · Alexey Kardashevskiy
The usual way of using a quirk's MR is to add it as a subregion of a BAR as this is what quirks are for. However there is less than standard user of this - NVLink2-enabled NVIDIA GPU which exposes a GPU RAM and a ATSD 64K region outside of PCI MMIO window so these MRs get the system address space root as a parent. So when the user unplugs such device, assert occurs:
Quoted 6 lines
qemu-system-ppc64:
/home/aik/p/qemu/memory.c:2391:memory_region_del_subregion: Assertion `subregion->container == mr' failed.This passes the actual parent MR to
memory_region_del_subregion()invfio_bar_quirk_exit.Signed-off-by Alexey Kardashevskiy <[email protected]>
Quoted 31 lines
---
This removes an extra sanity check that a quirk has a correct parent; I am not sure if it is very useful.
I could use the "system" MR if quirk->mem[i].container==get_system_memory() and quirk->mem[i].container otherwise to keep that assert working.Also this does not help with the actual device removal much because of the closed source driver nature - the associated service (nvidia-persistenced, responsible for onlining GPU memory) crashes the guest system but at least the user can reboot the guest after the crash which is not as bad as assert.
--- hw/vfio/pci-quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/vfio/pci-quirks.c +2
-1@@ -1896,7 +1896,8 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) }for (i =0 ; i < quirk->nr_mem; i++) { -memory_region_del_subregion (bar->region.mem, &quirk->mem[i]); +memory_region_del_subregion (quirk->mem[i].container, + &quirk->mem[i]); } } }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Alex Williamson
NAKQuoted 35 lines · On Fri, 5 Jul 2019 13:25:01 +1000 Alexey Kardashevskiy <[email protected]> wrote:
The usual way of using a quirk's MR is to add it as a subregion of a BAR as this is what quirks are for. However there is less than standard user of this - NVLink2-enabled NVIDIA GPU which exposes a GPU RAM and a ATSD 64K region outside of PCI MMIO window so these MRs get the system address space root as a parent. So when the user unplugs such device, assert occurs:
qemu-system-ppc64:
/home/aik/p/qemu/memory.c:2391:memory_region_del_subregion: Assertion `subregion->container == mr' failed.This passes the actual parent MR to
memory_region_del_subregion()invfio_bar_quirk_exit.Signed-off-by Alexey Kardashevskiy <[email protected]>---
This removes an extra sanity check that a quirk has a correct parent; I am not sure if it is very useful.
I could use the "system" MR if quirk->mem[i].container==get_system_memory() and quirk->mem[i].container otherwise to keep that assert working.Also this does not help with the actual device removal much because of the closed source driver nature - the associated service (nvidia-persistenced, responsible for onlining GPU memory) crashes the guest system but at least the user can reboot the guest after the crash which is not as bad as assert.
--- hw/vfio/pci-quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/vfio/pci-quirks.c +0
-0
hw/vfio/pci-quirks.c void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) · line 1903
Quoted 9 lines
hw/vfio/pci-quirks.c +2
-1@@ -1896,7 +1896,8 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) }for (i =0 ; i < quirk->nr_mem; i++) { -memory_region_del_subregion (bar->region.mem, &quirk->mem[i]); +memory_region_del_subregion (quirk->mem[i].container, + &quirk->mem[i]); } } }
NAK
struct MemoryRegion {
Object parent_obj;
/* All fields are private - violators will be prosecuted */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
MemoryRegion *container;