File nvidia_fake_gpus.patch of Package qemu

diff -r '--exclude=*.old*' -u -N qemu-8.2.10.orig/hw/misc/Kconfig qemu-8.2.10/hw/misc/Kconfig
--- qemu-8.2.10.orig/hw/misc/Kconfig	2026-03-19 13:18:04.407335122 +0100
+++ qemu-8.2.10/hw/misc/Kconfig	2026-03-19 13:34:06.180770603 +0100
@@ -25,6 +25,16 @@
     default y if TEST_DEVICES
     depends on PCI
 
+config TURING
+    bool
+    default y if TEST_DEVICES
+    depends on PCI && MSI_NONBROKEN
+
+config PASCAL
+    bool
+    default y if TEST_DEVICES
+    depends on PCI && MSI_NONBROKEN
+
 config EDU
     bool
     default y if TEST_DEVICES
diff -r '--exclude=*.old*' -u -N qemu-8.2.10.orig/hw/misc/fake_pascal.c qemu-8.2.10/hw/misc/fake_pascal.c
--- qemu-8.2.10.orig/hw/misc/fake_pascal.c	1970-01-01 01:00:00.000000000 +0100
+++ qemu-8.2.10/hw/misc/fake_pascal.c	2026-03-19 22:42:59.458968200 +0100
@@ -0,0 +1,113 @@
+#include "qemu/osdep.h"
+#include "qom/object.h"
+
+/* Full PCI device definition needed for embedding */
+#include "hw/pci/pci_device.h"
+
+#include "hw/pci/pci_ids.h"
+#include "qemu/error-report.h"
+
+/* Memory functions / BARs */
+#include "exec/memory.h"
+
+#include "qemu/units.h"   /* MiB / GiB macros */
+
+#define TYPE_PCI_GPU_DEVICE "fake-pascal"
+#define GPU_DEVICE_ID 0x1CBC   /* Quadro P600 */
+
+typedef struct GpuState {
+    PCIDevice parent_obj;   /* full definition now available */
+    MemoryRegion vram;
+} GpuState;
+
+/* Forward declarations */
+static void gpu_instance_init(Object *obj);
+static void gpu_class_init(ObjectClass *class, void *data);
+static void pci_gpu_realize(PCIDevice *pdev, Error **errp);
+static void pci_gpu_uninit(PCIDevice *pdev);
+
+/* Instance init — nothing for now */
+static void gpu_instance_init(Object *obj)
+{
+    /* empty */
+}
+
+/* Realize the PCI device — setup BARs, config space, etc */
+static void pci_gpu_realize(PCIDevice *pdev, Error **errp)
+{
+    GpuState *s = (GpuState *)pdev;
+
+    /* PCI basics */
+    pci_config_set_interrupt_pin(pdev->config, 1);
+    pci_set_word(pdev->config + PCI_COMMAND,
+                 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+
+    /* Set class to VGA compatible (important for lspci) */
+    pci_config_set_class(pdev->config, PCI_CLASS_DISPLAY_VGA);
+
+    /* Fake VRAM BAR — 16 MiB */
+    memory_region_init_ram(&s->vram, OBJECT(s),
+                           "fake-pascal.vram",
+                           16 * MiB,
+                           errp);
+    pci_register_bar(pdev, 0,
+                     PCI_BASE_ADDRESS_SPACE_MEMORY,
+                     &s->vram);
+
+    /* Optional: ROM BAR if you want a BIOS */
+    /* pci_register_rom_bar(pdev, "fake-nvidia.rom"); */
+}
+
+/* Cleanup */
+static void pci_gpu_uninit(PCIDevice *pdev)
+{
+    GpuState *s = (GpuState *)pdev;
+
+    /* Unref the MemoryRegion (replaces memory_region_destroy) */
+    memory_region_unref(&s->vram);
+}
+
+/* Class init — set PCI IDs, class, subsystem, revision */
+static void gpu_class_init(ObjectClass *class, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(class);
+    PCIDeviceClass *k = (PCIDeviceClass *)dc;
+
+    k->realize = pci_gpu_realize;
+    k->exit    = pci_gpu_uninit;
+
+    k->vendor_id = 0x10DE;
+    k->device_id = GPU_DEVICE_ID;
+
+    /* VGA compatible */
+    k->class_id  = 0x0302;
+
+    /* Subsystem IDs to make lspci name resolution happy */
+    k->subsystem_vendor_id = 0x10DE;
+    k->subsystem_id        = 0x12A2;
+
+    /* Revision */
+    k->revision = 0xA1;
+}
+
+/* Register the type */
+static const TypeInfo gpu_info = {
+    .name          = TYPE_PCI_GPU_DEVICE,
+    .parent        = TYPE_PCI_DEVICE,
+    .instance_size = sizeof(GpuState),
+    .instance_init = gpu_instance_init,
+    .class_init    = gpu_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { INTERFACE_PCIE_DEVICE },   // 👈 THIS is what you're missing
+        { }
+    },
+};
+
+/* Type registration function */
+static void pci_gpu_register_types(void)
+{
+    type_register_static(&gpu_info);
+}
+
+/* Tell QEMU to call the type registration */
+type_init(pci_gpu_register_types)
diff -r '--exclude=*.old*' -u -N qemu-8.2.10.orig/hw/misc/fake_turing.c qemu-8.2.10/hw/misc/fake_turing.c
--- qemu-8.2.10.orig/hw/misc/fake_turing.c	1970-01-01 01:00:00.000000000 +0100
+++ qemu-8.2.10/hw/misc/fake_turing.c	2026-03-19 22:42:35.434433215 +0100
@@ -0,0 +1,113 @@
+#include "qemu/osdep.h"
+#include "qom/object.h"
+
+/* Full PCI device definition needed for embedding */
+#include "hw/pci/pci_device.h"
+
+#include "hw/pci/pci_ids.h"
+#include "qemu/error-report.h"
+
+/* Memory functions / BARs */
+#include "exec/memory.h"
+
+#include "qemu/units.h"   /* MiB / GiB macros */
+
+#define TYPE_PCI_GPU_DEVICE "fake-turing"
+#define GPU_DEVICE_ID 0x1FF2   /* TU117GL (T400) */
+
+typedef struct GpuState {
+    PCIDevice parent_obj;   /* full definition now available */
+    MemoryRegion vram;
+} GpuState;
+
+/* Forward declarations */
+static void gpu_instance_init(Object *obj);
+static void gpu_class_init(ObjectClass *class, void *data);
+static void pci_gpu_realize(PCIDevice *pdev, Error **errp);
+static void pci_gpu_uninit(PCIDevice *pdev);
+
+/* Instance init — nothing for now */
+static void gpu_instance_init(Object *obj)
+{
+    /* empty */
+}
+
+/* Realize the PCI device — setup BARs, config space, etc */
+static void pci_gpu_realize(PCIDevice *pdev, Error **errp)
+{
+    GpuState *s = (GpuState *)pdev;
+
+    /* PCI basics */
+    pci_config_set_interrupt_pin(pdev->config, 1);
+    pci_set_word(pdev->config + PCI_COMMAND,
+                 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+
+    /* Set class to VGA compatible (important for lspci) */
+    pci_config_set_class(pdev->config, PCI_CLASS_DISPLAY_VGA);
+
+    /* Fake VRAM BAR — 16 MiB */
+    memory_region_init_ram(&s->vram, OBJECT(s),
+                           "fake-turing.vram",
+                           16 * MiB,
+                           errp);
+    pci_register_bar(pdev, 0,
+                     PCI_BASE_ADDRESS_SPACE_MEMORY,
+                     &s->vram);
+
+    /* Optional: ROM BAR if you want a BIOS */
+    /* pci_register_rom_bar(pdev, "fake-nvidia.rom"); */
+}
+
+/* Cleanup */
+static void pci_gpu_uninit(PCIDevice *pdev)
+{
+    GpuState *s = (GpuState *)pdev;
+
+    /* Unref the MemoryRegion (replaces memory_region_destroy) */
+    memory_region_unref(&s->vram);
+}
+
+/* Class init — set PCI IDs, class, subsystem, revision */
+static void gpu_class_init(ObjectClass *class, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(class);
+    PCIDeviceClass *k = (PCIDeviceClass *)dc;
+
+    k->realize = pci_gpu_realize;
+    k->exit    = pci_gpu_uninit;
+
+    k->vendor_id = 0x10DE;
+    k->device_id = GPU_DEVICE_ID;
+
+    /* VGA compatible */
+    k->class_id  = 0x0302;
+
+    /* Subsystem IDs to make lspci name resolution happy */
+    k->subsystem_vendor_id = 0x10DE;
+    k->subsystem_id        = 0x12A2;
+
+    /* Revision */
+    k->revision = 0xA1;
+}
+
+/* Register the type */
+static const TypeInfo gpu_info = {
+    .name          = TYPE_PCI_GPU_DEVICE,
+    .parent        = TYPE_PCI_DEVICE,
+    .instance_size = sizeof(GpuState),
+    .instance_init = gpu_instance_init,
+    .class_init    = gpu_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { INTERFACE_PCIE_DEVICE },   // 👈 THIS is what you're missing
+        { }
+    },
+};
+
+/* Type registration function */
+static void pci_gpu_register_types(void)
+{
+    type_register_static(&gpu_info);
+}
+
+/* Tell QEMU to call the type registration */
+type_init(pci_gpu_register_types)
diff -r '--exclude=*.old*' -u -N qemu-8.2.10.orig/hw/misc/meson.build qemu-8.2.10/hw/misc/meson.build
--- qemu-8.2.10.orig/hw/misc/meson.build	2026-03-19 13:18:04.411335210 +0100
+++ qemu-8.2.10/hw/misc/meson.build	2026-03-19 14:11:36.666954728 +0100
@@ -1,4 +1,6 @@
 system_ss.add(when: 'CONFIG_APPLESMC', if_true: files('applesmc.c'))
+system_ss.add(when: 'CONFIG_TURING', if_true: files('fake_turing.c'))
+system_ss.add(when: 'CONFIG_PASCAL', if_true: files('fake_pascal.c'))
 system_ss.add(when: 'CONFIG_EDU', if_true: files('edu.c'))
 system_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('vmcoreinfo.c'))
 system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugexit.c'))
openSUSE Build Service is sponsored by