[PATCH v3 5/7] hw/loongarch/virt: Add property highmem_mmio with virt machine

Bibo Mao posted 7 patches 4 weeks ago
Maintainers: Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>
[PATCH v3 5/7] hw/loongarch/virt: Add property highmem_mmio with virt machine
Posted by Bibo Mao 4 weeks ago
On LoongArch Virt Machine, MMIO region with GPEX host bridge is
0x40000000 -- 0x7FFFFFFF. The total size is 1G bytes and it is enough
for emulated virtio devices basically.

However on some conditions such as hostmem is added with virtio-gpu
device, the command line is -device virtio-gpu-gl,hostmem=4G. The
PCIE MMIO region is not enough, 64-bit high MMIO region is required.

Here add property highmem_mmio with virt machine, however it brings
out incompatible issue. Here the default value is false.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 hw/loongarch/virt.c         | 21 +++++++++++++++++++++
 include/hw/loongarch/virt.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 01bd21dbab..b068f63d3f 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -89,6 +89,20 @@ static void virt_set_veiointc(Object *obj, Visitor *v, const char *name,
     visit_type_OnOffAuto(v, name, &lvms->veiointc, errp);
 }
 
+static bool virt_get_highmem_mmio(Object *obj, Error **errp)
+{
+    LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(obj);
+
+    return lvms->highmem_mmio;
+}
+
+static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp)
+{
+    LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(obj);
+
+    lvms->highmem_mmio = value;
+}
+
 static PFlashCFI01 *virt_flash_create1(LoongArchVirtMachineState *lvms,
                                        const char *name,
                                        const char *alias_prop_name)
@@ -1380,6 +1394,13 @@ static void virt_class_init(ObjectClass *oc, const void *data)
                                           "Override the default value of field OEM Table ID "
                                           "in ACPI table header."
                                           "The string may be up to 8 bytes in size");
+
+    object_class_property_add_bool(oc, "highmem-mmio",
+                                   virt_get_highmem_mmio,
+                                   virt_set_highmem_mmio);
+    object_class_property_set_description(oc, "highmem-mmio",
+                                          "Set on/off to enable/disable high "
+                                          "memory region for PCI MMIO");
 }
 
 static const TypeInfo virt_machine_types[] = {
diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h
index 8f0538a72d..5d40546c78 100644
--- a/include/hw/loongarch/virt.h
+++ b/include/hw/loongarch/virt.h
@@ -127,6 +127,7 @@ struct LoongArchVirtMachineState {
     DeviceState *dintc;
     hwaddr ram_end;
     struct GPEXConfig gpex;
+    bool highmem_mmio;
 };
 
 #define TYPE_LOONGARCH_VIRT_MACHINE  MACHINE_TYPE_NAME("virt")
-- 
2.39.3