static void vfio_probe_nvidia_bar0_quirk(VFIOPCIDevice *vdev, int nr)

{

    VFIOQuirk *quirk;

    VFIOConfigMirrorQuirk *mirror;



    if (!vfio_pci_is(vdev, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID) ||

        !vfio_is_vga(vdev) || nr != 0) {

        return;

    }



    quirk = g_malloc0(sizeof(*quirk));

    mirror = quirk->data = g_malloc0(sizeof(*mirror));

    mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);

    quirk->nr_mem = 1;

    mirror->vdev = vdev;

    mirror->offset = 0x88000;

    mirror->bar = nr;



    memory_region_init_io(mirror->mem, OBJECT(vdev),

                          &vfio_nvidia_mirror_quirk, mirror,

                          "vfio-nvidia-bar0-88000-mirror-quirk",

                          PCIE_CONFIG_SPACE_SIZE);

    memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,

                                        mirror->offset, mirror->mem, 1);



    QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);



    /* The 0x1800 offset mirror only seems to get used by legacy VGA */

    if (vdev->has_vga) {

        quirk = g_malloc0(sizeof(*quirk));

        mirror = quirk->data = g_malloc0(sizeof(*mirror));

        mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);

        quirk->nr_mem = 1;

        mirror->vdev = vdev;

        mirror->offset = 0x1800;

        mirror->bar = nr;



        memory_region_init_io(mirror->mem, OBJECT(vdev),

                              &vfio_nvidia_mirror_quirk, mirror,

                              "vfio-nvidia-bar0-1800-mirror-quirk",

                              PCI_CONFIG_SPACE_SIZE);

        memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,

                                            mirror->offset, mirror->mem, 1);



        QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);

    }



    trace_vfio_quirk_nvidia_bar0_probe(vdev->vbasedev.name);

}

static void vfio_probe_nvidia_bar0_quirk(VFIOPCIDevice *vdev, int nr)

{

    VFIOQuirk *quirk;

    VFIOConfigMirrorQuirk *mirror;



    if (!vfio_pci_is(vdev, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID) ||

        !vfio_is_vga(vdev) || nr != 0) {

        return;

    }



    quirk = g_malloc0(sizeof(*quirk));

    mirror = quirk->data = g_malloc0(sizeof(*mirror));

    mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);

    quirk->nr_mem = 1;

    mirror->vdev = vdev;

    mirror->offset = 0x88000;

    mirror->bar = nr;



    memory_region_init_io(mirror->mem, OBJECT(vdev),

                          &vfio_nvidia_mirror_quirk, mirror,

                          "vfio-nvidia-bar0-88000-mirror-quirk",

                          PCIE_CONFIG_SPACE_SIZE);

    memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,

                                        mirror->offset, mirror->mem, 1);



    QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);



    

    if (vdev->has_vga) {

        quirk = g_malloc0(sizeof(*quirk));

        mirror = quirk->data = g_malloc0(sizeof(*mirror));

        mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);

        quirk->nr_mem = 1;

        mirror->vdev = vdev;

        mirror->offset = 0x1800;

        mirror->bar = nr;



        memory_region_init_io(mirror->mem, OBJECT(vdev),

                              &vfio_nvidia_mirror_quirk, mirror,

                              "vfio-nvidia-bar0-1800-mirror-quirk",

                              PCI_CONFIG_SPACE_SIZE);

        memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,

                                            mirror->offset, mirror->mem, 1);



        QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);

    }



    trace_vfio_quirk_nvidia_bar0_probe(vdev->vbasedev.name);

}

static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)

{

    VFIOQuirk *quirk;

    VFIOConfigMirrorQuirk *mirror;



    if (!vfio_pci_is(VAR_0, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID) ||

        !vfio_is_vga(VAR_0) || VAR_1 != 0) {

        return;

    }



    quirk = g_malloc0(sizeof(*quirk));

    mirror = quirk->data = g_malloc0(sizeof(*mirror));

    mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);

    quirk->nr_mem = 1;

    mirror->VAR_0 = VAR_0;

    mirror->offset = 0x88000;

    mirror->bar = VAR_1;



    memory_region_init_io(mirror->mem, OBJECT(VAR_0),

                          &vfio_nvidia_mirror_quirk, mirror,

                          "vfio-nvidia-bar0-88000-mirror-quirk",

                          PCIE_CONFIG_SPACE_SIZE);

    memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,

                                        mirror->offset, mirror->mem, 1);



    QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next);



    

    if (VAR_0->has_vga) {

        quirk = g_malloc0(sizeof(*quirk));

        mirror = quirk->data = g_malloc0(sizeof(*mirror));

        mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);

        quirk->nr_mem = 1;

        mirror->VAR_0 = VAR_0;

        mirror->offset = 0x1800;

        mirror->bar = VAR_1;



        memory_region_init_io(mirror->mem, OBJECT(VAR_0),

                              &vfio_nvidia_mirror_quirk, mirror,

                              "vfio-nvidia-bar0-1800-mirror-quirk",

                              PCI_CONFIG_SPACE_SIZE);

        memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,

                                            mirror->offset, mirror->mem, 1);



        QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next);

    }



    trace_vfio_quirk_nvidia_bar0_probe(VAR_0->vbasedev.name);

}

static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)
{ VFIOQuirk *quirk; VFIOConfigMirrorQuirk *mirror; if (!vfio_pci_is(VAR_0, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID) ||
!vfio_is_vga(VAR_0) || VAR_1 != 0) { return; } quirk = g_malloc0(sizeof(*quirk)); mirror = quirk->data = g_malloc0(sizeof(*mirror)); mirror->mem = quirk->mem = g_new0(MemoryRegion, 1); quirk->nr_mem = 1; mirror->VAR_0 = VAR_0; mirror->offset = 0x88000; mirror->bar = VAR_1; memory_region_init_io(mirror->mem, OBJECT(VAR_0),
&vfio_nvidia_mirror_quirk, mirror,
"vfio-nvidia-bar0-88000-mirror-quirk",
PCIE_CONFIG_SPACE_SIZE); memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,
mirror->offset, mirror->mem, 1); QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next); if (VAR_0->has_vga) { quirk = g_malloc0(sizeof(*quirk)); mirror = quirk->data = g_malloc0(sizeof(*mirror)); mirror->mem = quirk->mem = g_new0(MemoryRegion, 1); quirk->nr_mem = 1; mirror->VAR_0 = VAR_0; mirror->offset = 0x1800; mirror->bar = VAR_1; memory_region_init_io(mirror->mem, OBJECT(VAR_0),
&vfio_nvidia_mirror_quirk, mirror,
"vfio-nvidia-bar0-1800-mirror-quirk",
PCI_CONFIG_SPACE_SIZE); memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,
mirror->offset, mirror->mem, 1); QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next); } trace_vfio_quirk_nvidia_bar0_probe(VAR_0->vbasedev.name); }