Skip to contentSkip to conversation

hw/arm/virt: Support larger highmem MMIO regions

PATCH Superseded Matthew R. Ochs 4 participants 10 messages Jan 28, 2025 – Feb 1, 2025

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/virt: Support larger highmem MMIO regions

The MMIO region size required to support virtualized environments with large PCI BAR regions can exceed the hardcoded limit configured in QEMU. For example, a VM with multiple NVIDIA Grace-Hopper GPUs passed through requires more MMIO memory than the amount provided by VIRT_HIGH_PCIE_MMIO (currently 512GB). Instead of updating VIRT_HIGH_PCIE_MMIO, introduce a new parameter, highmem-mmio-size, that specifies the MMIO size required to support the VM configuration.

Example usage with 1TB MMIO region size:

	-machine virt,gic-version=3,highmem-mmio-size=1099511627776
---
 docs/system/arm/virt.rst |  4 ++++
 hw/arm/virt.c            | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
docs/system/arm/virt.rst +4 -0
index e67e7f0f7c50..36344554788a 100644
@@ -138,6 +138,10 @@ highmem-mmio
   Set ``on``/``off`` to enable/disable the high memory region for PCI MMIO.
   The default is ``on``.
 
+highmem-mmio-size
+  Set extended MMIO memory map size. Must be a power-of-2 and greater than
+  the default size.
+
 gic-version
   Specify the version of the Generic Interrupt Controller (GIC) to provide.
   Valid values are:
hw/arm/virt.c +36 -0
index 49eb0355ef0c..43d47ffedd9a 100644
@@ -2773,6 +2773,35 @@ static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp)
     vms->highmem_mmio = value;
 }
 
+static void virt_get_highmem_mmio_size(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size = extended_memmap[VIRT_HIGH_PCIE_MMIO].size;
+
+    visit_type_size(v, name, &size, errp);
+}
+
+static void virt_set_highmem_mmio_size(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size;
+
+    if (!visit_type_size(v, name, &size, errp))
+        return;
+
+    if (!is_power_of_2(size)) {
+        error_setg(errp, "highmem_mmio_size is not a power-of-2");
+        return;
+    }
+
+    if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {
+        error_setg(errp, "highmem_mmio_size is less than the default (%lu)",
+                   extended_memmap[VIRT_HIGH_PCIE_MMIO].size);
+        return;
+    }
+
+    extended_memmap[VIRT_HIGH_PCIE_MMIO].size = size;
+}
 
 static bool virt_get_its(Object *obj, Error **errp)
 {
@@ -3446,6 +3475,13 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
                                           "Set on/off to enable/disable high "
                                           "memory region for PCI MMIO");
 
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+
     object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
                                   virt_set_gic_version);
     object_class_property_set_description(oc, "gic-version",
Signature · 1 line
2.46.0
#1 lore raw
Quoted 21 lines

-----Original Message-----
From: Matthew R. Ochs <[email protected]>
Sent: Tuesday, January 28, 2025 4:03 PM
To: [email protected]; Shameerali Kolothum Thodi <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] hw/arm/virt: Support larger highmem MMIO regions

The MMIO region size required to support virtualized environments with large PCI BAR regions can exceed the hardcoded limit configured in QEMU. For example, a VM with multiple NVIDIA Grace-Hopper GPUs passed through
requires more MMIO memory than the amount provided by VIRT_HIGH_PCIE_MMIO
(currently 512GB). Instead of updating VIRT_HIGH_PCIE_MMIO, introduce a new parameter, highmem-mmio-size, that specifies the MMIO size required to support the VM configuration.

Quoted 2 lines

Example usage with 1TB MMIO region size:

	-machine virt,gic-version=3,highmem-mmio-size=1099511627776

I guess you could do highmem-mmio-size=1024G as well.

Quoted 39 lines
---
 docs/system/arm/virt.rst |  4 ++++
 hw/arm/virt.c            | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
docs/system/arm/virt.rst +2 -0
index e67e7f0f7c50..36344554788a 100644
@@ -138,6 +138,10 @@ highmem-mmio
   Set ``on``/``off`` to enable/disable the high memory region for PCI MMIO.
   The default is ``on``.
 
+highmem-mmio-size
+  Set extended MMIO memory map size. Must be a power-of-2 and greater

than

docs/system/arm/virt.rst +2 -0
+  the default size.
+
 gic-version
   Specify the version of the Generic Interrupt Controller (GIC) to provide.
   Valid values are:
hw/arm/virt.c +6 -0
index 49eb0355ef0c..43d47ffedd9a 100644
@@ -2773,6 +2773,35 @@ static void virt_set_highmem_mmio(Object *obj,
 bool value, Error **errp)
     vms->highmem_mmio = value;
 }
 
+static void virt_get_highmem_mmio_size(Object *obj, Visitor *v, const
 char *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size = extended_memmap[VIRT_HIGH_PCIE_MMIO].size;
+
+    visit_type_size(v, name, &size, errp);

hw/arm/virt.c static void virt_set_highmem_mmio(Object *obj, · line 2793

Quoted 10 lines
hw/arm/virt.c +9 -0
+}
+
+static void virt_set_highmem_mmio_size(Object *obj, Visitor *v, const char
 *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size;
+
+    if (!visit_type_size(v, name, &size, errp))
+        return;

Qemu style mandates braces around.

hw/arm/virt.c static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp) · line 2797

Quoted 7 lines
hw/arm/virt.c +7 -0
+
+    if (!is_power_of_2(size)) {
+        error_setg(errp, "highmem_mmio_size is not a power-of-2");
+        return;
+    }
+
+    if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {

Not sure it is better to fallback to default size here instead of setting error.

Quoted 12 lines
hw/arm/virt.c +7 -0
+        error_setg(errp, "highmem_mmio_size is less than the default (%lu)",
+                   extended_memmap[VIRT_HIGH_PCIE_MMIO].size);
+        return;
+    }
+
+    extended_memmap[VIRT_HIGH_PCIE_MMIO].size = size;
+}

static bool virt_get_its(Object *obj, Error **errp) {

hw/arm/virt.c +0 -0
@@ -3446,6 +3475,13 @@ static void virt_machine_class_init(ObjectClass
 *oc, void *data)

hw/arm/virt.c static void virt_machine_class_init(ObjectClass · line 3485

Quoted 10 lines
hw/arm/virt.c +7 -0
                                           "Set on/off to enable/disable high "
                                           "memory region for PCI MMIO");
 
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+

I think this probably needs backward compatibility to keep migration happy. Isn't it? See the no_highmem_compact handling.

Thanks,
Shameer

#2 lore raw

Hi Matthew, Shameer,

Quoted 38 lines · Shameerali Kolothum Thodi
Quoted 20 lines

-----Original Message-----
From: Matthew R. Ochs <[email protected]>
Sent: Tuesday, January 28, 2025 4:03 PM
To: [email protected]; Shameerali Kolothum Thodi <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] hw/arm/virt: Support larger highmem MMIO regions

The MMIO region size required to support virtualized environments with large PCI BAR regions can exceed the hardcoded limit configured in QEMU. For example, a VM with multiple NVIDIA Grace-Hopper GPUs passed through
requires more MMIO memory than the amount provided by VIRT_HIGH_PCIE_MMIO
(currently 512GB). Instead of updating VIRT_HIGH_PCIE_MMIO, introduce a new parameter, highmem-mmio-size, that specifies the MMIO size required to support the VM configuration.

Quoted 2 lines

Example usage with 1TB MMIO region size:

	-machine virt,gic-version=3,highmem-mmio-size=1099511627776

I guess you could do highmem-mmio-size=1024G as well.

Quoted 14 lines
---
 docs/system/arm/virt.rst |  4 ++++
 hw/arm/virt.c            | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
docs/system/arm/virt.rst +0 -0
index e67e7f0f7c50..36344554788a 100644
@@ -138,6 +138,10 @@ highmem-mmio
   Set ``on``/``off`` to enable/disable the high memory region for PCI MMIO.
   The default is ``on``.
 
Quoted 2 lines

docs/system/arm/virt.rst highmem-mmio · line 142

Quoted 2 lines
docs/system/arm/virt.rst +2 -0
+highmem-mmio-size
+  Set extended MMIO memory map size. Must be a power-of-2 and greater

maybe keep the existing terminology, ie. high PCIE MMIO region. extended_memmap
Would deserve to add some comments on top of extended_memmap[] too.

Quoted 34 lines
Quoted 22 lines

than

docs/system/arm/virt.rst +2 -0
+  the default size.
+
 gic-version
   Specify the version of the Generic Interrupt Controller (GIC) to provide.
   Valid values are:
hw/arm/virt.c +6 -0
index 49eb0355ef0c..43d47ffedd9a 100644
@@ -2773,6 +2773,35 @@ static void virt_set_highmem_mmio(Object *obj,
 bool value, Error **errp)
     vms->highmem_mmio = value;
 }
 
+static void virt_get_highmem_mmio_size(Object *obj, Visitor *v, const
 char *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size = extended_memmap[VIRT_HIGH_PCIE_MMIO].size;
+
+    visit_type_size(v, name, &size, errp);

hw/arm/virt.c static void virt_set_highmem_mmio(Object *obj, · line 2793

Quoted 10 lines
hw/arm/virt.c +9 -0
+}
+
+static void virt_set_highmem_mmio_size(Object *obj, Visitor *v, const char
 *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size;
+
+    if (!visit_type_size(v, name, &size, errp))
+        return;

Qemu style mandates braces around.

Quoted 8 lines

hw/arm/virt.c static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp) · line 2797

Quoted 7 lines
hw/arm/virt.c +7 -0
+
+    if (!is_power_of_2(size)) {
+        error_setg(errp, "highmem_mmio_size is not a power-of-2");
+        return;
+    }
+
+    if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {

Not sure it is better to fallback to default size here instead of setting error.

I think if the user sets a value it shall be obeyed
Note that per the dynamic memory map algo, changing the size will also change the base address. See

virt_set_high_memmap(). By the wayn why do we forbid a smaller size?

Quoted 16 lines
Quoted 16 lines
hw/arm/virt.c +7 -0
+        error_setg(errp, "highmem_mmio_size is less than the default (%lu)",
+                   extended_memmap[VIRT_HIGH_PCIE_MMIO].size);
+        return;
+    }
+
+    extended_memmap[VIRT_HIGH_PCIE_MMIO].size = size;
+}

static bool virt_get_its(Object *obj, Error **errp) {

hw/arm/virt.c +0 -0
@@ -3446,6 +3475,13 @@ static void virt_machine_class_init(ObjectClass
 *oc, void *data)
                                           "Set on/off to enable/disable high "
                                           "memory region for PCI MMIO");
 
Quoted 9 lines

hw/arm/virt.c static void virt_machine_class_init(ObjectClass *oc, void *data) · line 3484

Quoted 7 lines
hw/arm/virt.c +7 -0
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+

I think this probably needs backward compatibility to keep migration happy. Isn't it? See the no_highmem_compact handling.

I guess if we keep the same value as default we are good. The difference with highmem_compact is it was set by default from 7.2 onwards hence changing the mmio layout. Here by default you keep the same IIUC.

Thanks

Eric

Quoted 4 lines

Thanks,
Shameer

author
#3 lore raw
Quoted 28 lines · Eric Auger

Hi Matthew, Shameer,

Quoted 23 lines · Shameerali Kolothum Thodi
Quoted 20 lines

-----Original Message-----
From: Matthew R. Ochs <[email protected]>
Sent: Tuesday, January 28, 2025 4:03 PM
To: [email protected]; Shameerali Kolothum Thodi <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] hw/arm/virt: Support larger highmem MMIO regions

The MMIO region size required to support virtualized environments with large PCI BAR regions can exceed the hardcoded limit configured in QEMU. For example, a VM with multiple NVIDIA Grace-Hopper GPUs passed through
requires more MMIO memory than the amount provided by VIRT_HIGH_PCIE_MMIO
(currently 512GB). Instead of updating VIRT_HIGH_PCIE_MMIO, introduce a new parameter, highmem-mmio-size, that specifies the MMIO size required to support the VM configuration.

Quoted 2 lines

Example usage with 1TB MMIO region size:
-machine virt,gic-version=3,highmem-mmio-size=1099511627776

I guess you could do highmem-mmio-size=1024G as well.

Sure, the visit_type_size() helper can understand the common unit suffixes used for sizes, e.g. 1T. To clarify, I’ll update the example in v2.

Quoted 5 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+highmem-mmio-size
+  Set extended MMIO memory map size. Must be a power-of-2 and greater

maybe keep the existing terminology, ie. high PCIE MMIO region. extended_memmap
Would deserve to add some comments on top of extended_memmap[] too.

Thanks for the suggestion, will update the patch to use existing terminology.

Quoted 3 lines
Quoted 3 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+    if (!visit_type_size(v, name, &size, errp))
+        return;

Qemu style mandates braces around.

Will fix in v2.

Quoted 10 lines
Quoted 9 lines

hw/arm/virt.c static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp) · line 2797

Quoted 8 lines
hw/arm/virt.c +7 -0
+
+    if (!is_power_of_2(size)) {
+        error_setg(errp, "highmem_mmio_size is not a power-of-2");
+        return;
+    }
+
+    if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {

Not sure it is better to fallback to default size here instead of setting error.

I think if the user sets a value it shall be obeyed

Agreed.

Quoted 4 lines

Note that per the dynamic memory map algo, changing the size will also change the base address. See

virt_set_high_memmap(). By the wayn why do we forbid a smaller size?

That’s a good point, I will remove this check.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
hw/arm/virt.c +7 -0
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+
Quoted 5 lines
Quoted 2 lines

I think this probably needs backward compatibility to keep migration happy. Isn't it? See the no_highmem_compact handling.

I guess if we keep the same value as default we are good. The difference with highmem_compact is it was set by default from 7.2 onwards hence changing the mmio layout. Here by default you keep the same IIUC.

I’m not sure I see an issue since the code is directly modifying the size value in the extended_memmap array.

#4 lore raw

Hi,

Quoted 66 lines · Matt Ochs
Quoted 27 lines · Eric Auger

Hi Matthew, Shameer,

Quoted 22 lines · Shameerali Kolothum Thodi
Quoted 19 lines

-----Original Message-----
From: Matthew R. Ochs <[email protected]>
Sent: Tuesday, January 28, 2025 4:03 PM
To: [email protected]; Shameerali Kolothum Thodi <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] hw/arm/virt: Support larger highmem MMIO regions

The MMIO region size required to support virtualized environments with large PCI BAR regions can exceed the hardcoded limit configured in QEMU. For example, a VM with multiple NVIDIA Grace-Hopper GPUs passed through
requires more MMIO memory than the amount provided by VIRT_HIGH_PCIE_MMIO
(currently 512GB). Instead of updating VIRT_HIGH_PCIE_MMIO, introduce a new parameter, highmem-mmio-size, that specifies the MMIO size required to support the VM configuration.

Quoted 2 lines

Example usage with 1TB MMIO region size:
-machine virt,gic-version=3,highmem-mmio-size=1099511627776

I guess you could do highmem-mmio-size=1024G as well.

Sure, the visit_type_size() helper can understand the common unit suffixes used for sizes, e.g. 1T. To clarify, I’ll update the example in v2.

Quoted 5 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+highmem-mmio-size
+  Set extended MMIO memory map size. Must be a power-of-2 and greater

maybe keep the existing terminology, ie. high PCIE MMIO region. extended_memmap
Would deserve to add some comments on top of extended_memmap[] too.

Thanks for the suggestion, will update the patch to use existing terminology.

Quoted 3 lines
Quoted 3 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+    if (!visit_type_size(v, name, &size, errp))
+        return;

Qemu style mandates braces around.

Will fix in v2.

Quoted 9 lines
Quoted 8 lines

hw/arm/virt.c static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp) · line 2797

Quoted 7 lines
hw/arm/virt.c +7 -0
+
+    if (!is_power_of_2(size)) {
+        error_setg(errp, "highmem_mmio_size is not a power-of-2");
+        return;
+    }
+
+    if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {

Not sure it is better to fallback to default size here instead of setting error.

I think if the user sets a value it shall be obeyed

Agreed.

Quoted 4 lines

Note that per the dynamic memory map algo, changing the size will also change the base address. See

virt_set_high_memmap(). By the wayn why do we forbid a smaller size?

That’s a good point, I will remove this check.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
hw/arm/virt.c +7 -0
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I think this probably needs backward compatibility to keep migration happy. Isn't it? See the no_highmem_compact handling.

I guess if we keep the same value as default we are good. The difference with highmem_compact is it was set by default from 7.2 onwards hence changing the mmio layout. Here by default you keep the same IIUC.

I’m not sure I see an issue since the code is directly modifying the size value in the extended_memmap array.

I meant that if by default we keep the size value equal to 512G (the existing default value), I don't think we need to care about compats.

Eric

Quoted 2 lines
#5 lore raw
Quoted 13 lines

-----Original Message-----
From: Eric Auger <[email protected]>
Sent: Wednesday, January 29, 2025 7:56 AM
To: Matt Ochs <[email protected]>; Shameerali Kolothum Thodi <[email protected]>
Cc: [email protected]; Nathan Chen <[email protected]>; [email protected]; Nicolin Chen <[email protected]>; Ankit Agrawal <[email protected]>
Subject: Re: [PATCH] hw/arm/virt: Support larger highmem MMIO regions

Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

+ if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {

Not sure it is better to fallback to default size here instead of setting

error.

Quoted 8 lines
Quoted 1 line

I think if the user sets a value it shall be obeyed

Agreed.

Quoted 4 lines

Note that per the dynamic memory map algo, changing the size will also change the base address. See

virt_set_high_memmap(). By the wayn why do we forbid a smaller size?

That’s a good point, I will remove this check.

Is there really a use case where a user will want a smaller size than default?

Quoted 14 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

hw/arm/virt.c static void virt_machine_class_init(ObjectClass *oc, void *data) · line 3484

Quoted 8 lines
hw/arm/virt.c +7 -0
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+

I think this probably needs backward compatibility to keep migration

happy.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Isn't it? See the no_highmem_compact handling.

I guess if we keep the same value as default we are good. The difference with highmem_compact is it was set by default from 7.2 onwards hence changing the mmio layout. Here by default you keep the same IIUC.

Quoted 6 lines
Quoted 1 line

I’m not sure I see an issue since the code is directly modifying the size

value

Quoted 1 line

in the extended_memmap array.

I meant that if by default we keep the size value equal to 512G (the existing default value), I don't think we need to care about compats.

Yeah. If it has default size , it should be Ok I guess. But what if,

Your source is something like,

./qemu-new -machine virt-9.1,...,highmem-mmio-size=XXX

and has a target VM started with

./qemu-9.1 -machine virt,...

The migration will be still successful but will have memory map differences, right?

Or the above is not considered as a valid use case and the onus of making sure we are using it correctly with default size is on the user.

Thanks,
SHameer

#6 lore raw

Hi Shameer,

Quoted 48 lines · Shameerali Kolothum Thodi
Quoted 11 lines

-----Original Message-----
From: Eric Auger <[email protected]>
Sent: Wednesday, January 29, 2025 7:56 AM
To: Matt Ochs <[email protected]>; Shameerali Kolothum Thodi <[email protected]>
Cc: [email protected]; Nathan Chen <[email protected]>; [email protected]; Nicolin Chen <[email protected]>; Ankit Agrawal <[email protected]>
Subject: Re: [PATCH] hw/arm/virt: Support larger highmem MMIO regions

Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

+ if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {

Not sure it is better to fallback to default size here instead of setting

error.

Quoted 8 lines
Quoted 1 line

I think if the user sets a value it shall be obeyed

Agreed.

Quoted 4 lines

Note that per the dynamic memory map algo, changing the size will also change the base address. See

virt_set_high_memmap(). By the wayn why do we forbid a smaller size?

That’s a good point, I will remove this check.

Is there really a use case where a user will want a smaller size than default?

Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

hw/arm/virt.c static void virt_machine_class_init(ObjectClass *oc, void *data) · line 3484

Quoted 7 lines
hw/arm/virt.c +7 -0
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+

I think this probably needs backward compatibility to keep migration

happy.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Isn't it? See the no_highmem_compact handling.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

I guess if we keep the same value as default we are good. The difference with highmem_compact is it was set by default from 7.2 onwards hence changing the mmio layout. Here by default you keep the same IIUC.

I’m not sure I see an issue since the code is directly modifying the size

value

Quoted 1 line

in the extended_memmap array.

I meant that if by default we keep the size value equal to 512G (the existing default value), I don't think we need to care about compats.

Yeah. If it has default size , it should be Ok I guess. But what if,

Your source is something like,

./qemu-new -machine virt-9.1,...,highmem-mmio-size=XXX

Quoted 8 lines

and has a target VM started with

./qemu-9.1 -machine virt,...

The migration will be still successful but will have memory map differences, right?

Or the above is not considered as a valid use case and the onus of making sure we are using it correctly with default size is on the user.

To me when you migrate the qemu cmd line is supposed to be the same on both src and dst. But worth to be tested.

Eric

Quoted 7 lines

Thanks,
SHameer

author
#7 lore raw
Quoted 27 lines · Eric Auger

Hi Shameer,

Quoted 23 lines · Shameerali Kolothum Thodi
Quoted 11 lines

-----Original Message-----
From: Eric Auger <[email protected]>
Sent: Wednesday, January 29, 2025 7:56 AM
To: Matt Ochs <[email protected]>; Shameerali Kolothum Thodi <[email protected]>
Cc: [email protected]; Nathan Chen <[email protected]>; [email protected]; Nicolin Chen <[email protected]>; Ankit Agrawal <[email protected]>
Subject: Re: [PATCH] hw/arm/virt: Support larger highmem MMIO regions

Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

+ if (size < extended_memmap[VIRT_HIGH_PCIE_MMIO].size) {

Not sure it is better to fallback to default size here instead of setting

error.

Quoted 8 lines
Quoted 1 line

I think if the user sets a value it shall be obeyed

Agreed.

Quoted 4 lines

Note that per the dynamic memory map algo, changing the size will also change the base address. See

virt_set_high_memmap(). By the wayn why do we forbid a smaller size?

That’s a good point, I will remove this check.

Is there really a use case where a user will want a smaller size than default?

I can’t really think of a use-case, so not including the check would likely fall under keeping the code smaller/simpler. Then again, I don’t have a strong opinion on not including it.

Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +7 -0
+    object_class_property_add(oc, "highmem-mmio-size", "size",
+                                   virt_get_highmem_mmio_size,
+                                   virt_set_highmem_mmio_size,
+                                   NULL, NULL);
+    object_class_property_set_description(oc, "highmem-mmio-size",
+                                          "Set extended MMIO memory map size");
+

I think this probably needs backward compatibility to keep migration

happy.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Isn't it? See the no_highmem_compact handling.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

I guess if we keep the same value as default we are good. The difference with highmem_compact is it was set by default from 7.2 onwards hence changing the mmio layout. Here by default you keep the same IIUC.

I’m not sure I see an issue since the code is directly modifying the size

value

Quoted 1 line

in the extended_memmap array.

I meant that if by default we keep the size value equal to 512G (the existing default value), I don't think we need to care about compats.

Yeah. If it has default size , it should be Ok I guess. But what if,

Your source is something like,

./qemu-new -machine virt-9.1,...,highmem-mmio-size=XXX

and has a target VM started with

Quoted 8 lines
Quoted 6 lines

./qemu-9.1 -machine virt,...

The migration will be still successful but will have memory map differences, right?

Or the above is not considered as a valid use case and the onus of making sure we are using it correctly with default size is on the user.

To me when you migrate the qemu cmd line is supposed to be the same on both src and dst. But worth to be tested.

I tested migration and encountered I/O issues (hangs, external aborts, etc) when the values were different, but no issues when the values were the same.

I don’t think the backward compatibility check alone would help here.

Are there migration facilities that evaluate source and destination configuration prior to migrating? If not, it’s up to the orchestrator of the migration to ensure the source and destination values are the same.

#8 lore raw
In reply to Matthew R. Ochs

Hi Matthew,

Quoted 23 lines · Matthew R. Ochs

The MMIO region size required to support virtualized environments with large PCI BAR regions can exceed the hardcoded limit configured in QEMU. For example, a VM with multiple NVIDIA Grace-Hopper GPUs passed through requires more MMIO memory than the amount provided by VIRT_HIGH_PCIE_MMIO (currently 512GB). Instead of updating VIRT_HIGH_PCIE_MMIO, introduce a new parameter, highmem-mmio-size, that specifies the MMIO size required to support the VM configuration.

Example usage with 1TB MMIO region size:

	-machine virt,gic-version=3,highmem-mmio-size=1099511627776
---
  docs/system/arm/virt.rst |  4 ++++
  hw/arm/virt.c            | 36 ++++++++++++++++++++++++++++++++++++
  2 files changed, 40 insertions(+)
hw/arm/virt.c +0 -0
index 49eb0355ef0c..43d47ffedd9a 100644

hw/arm/virt.c static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp) · line 2781

Quoted 9 lines
hw/arm/virt.c +6 -0
@@ -2773,6 +2773,35 @@ static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp)
      vms->highmem_mmio = value;
  }
 
+static void virt_get_highmem_mmio_size(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size = extended_memmap[VIRT_HIGH_PCIE_MMIO].size;
+
+    visit_type_size(v, name, &size, errp);

Since you correctly use visit_type_size(), maybe use in commit description example "highmem-mmio-size=1TB" rather than 1099511627776?

Quoted 1 line
hw/arm/virt.c +1 -0
+}
author
#9 lore raw

On Jan 29, 2025, at 2:25 AM, Philippe Mathieu-Daudé <[email protected]> wrote:

Hi Matthew,

On 28/1/25 17:02, Matthew R. Ochs wrote:
The MMIO region size required to support virtualized environments with large PCI BAR regions can exceed the hardcoded limit configured in QEMU. For example, a VM with multiple NVIDIA Grace-Hopper GPUs passed through requires more MMIO memory than the amount provided by VIRT_HIGH_PCIE_MMIO (currently 512GB). Instead of updating VIRT_HIGH_PCIE_MMIO, introduce a new parameter, highmem-mmio-size, that specifies the MMIO size required to support the VM configuration.
Example usage with 1TB MMIO region size:
-machine virt,gic-version=3,highmem-mmio-size=1099511627776

---
 docs/system/arm/virt.rst |  4 ++++
 hw/arm/virt.c            | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
hw/arm/virt.c +5 -0
index 49eb0355ef0c..43d47ffedd9a 100644
@@ -2773,6 +2773,35 @@ static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp)
     vms->highmem_mmio = value;
 }
 +static void virt_get_highmem_mmio_size(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    uint64_t size = extended_memmap[VIRT_HIGH_PCIE_MMIO].size;
+
+    visit_type_size(v, name, &size, errp);
 

Since you correctly use visit_type_size(), maybe use in commit description example "highmem-mmio-size=1TB" rather than 1099511627776?

Yes, this will be updated in v2.