Skip to contentSkip to conversation

hw/riscv/virt.c: fix 'aclint' prop regression

PATCH In review Daniel Henrique Barboza 3 participants 5 messages Aug 11, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

cover hw/riscv/virt.c: fix 'aclint' prop regression

Richard, Alistair,

I came across this gitlab bug earlier today. The bug itself was opened yesterday:

https://gitlab.com/qemu-project/qemu/-/issues/1823

And turns out that this is a regression in the 'aclint' option that was introduced in 8.1.

I'm aware that we're already in rc3 and kind of late, but even so I marked this patch as 8.1 to let you decide whether it's worth spinning rc4 or not.

Daniel Henrique Barboza (1):
hw/riscv/virt.c: change 'aclint' TCG check

 hw/riscv/virt.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/1 hw/riscv/virt.c: change 'aclint' TCG check

The 'aclint' property is being conditioned with tcg acceleration in virt_machine_class_init(). But acceleration code starts later than the class init of the board, meaning that tcg_enabled() will be always be false during class_init(), and the option is never being declared even when declaring TCG accel:

$ ./build/qemu-system-riscv64 -M virt,accel=tcg,aclint=on
qemu-system-riscv64: Property 'virt-machine.aclint' not found

Fix it by moving the check from class_init() to machine_init(). Tune the description to mention that the option is TCG only.

Cc Philippe Mathieu-Daudé <[email protected]>
Fixes c0716c81b ("hw/riscv/virt: Restrict ACLINT to TCG")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1823

---
 hw/riscv/virt.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
hw/riscv/virt.c +13 -7
index d90286dc46..99c4e6314b 100644
@@ -1350,6 +1350,11 @@ static void virt_machine_init(MachineState *machine)
         exit(1);
     }
 
+    if (!tcg_enabled() && s->have_aclint) {
+        error_report("'aclint' is only available with TCG acceleration");
+        exit(1);
+    }
+
     /* Initialize sockets */
     mmio_irqchip = virtio_irqchip = pcie_irqchip = NULL;
     for (i = 0; i < socket_count; i++) {
@@ -1683,13 +1688,14 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
 #endif
 
-    if (tcg_enabled()) {
-        object_class_property_add_bool(oc, "aclint", virt_get_aclint,
-                                       virt_set_aclint);
-        object_class_property_set_description(oc, "aclint",
-                                              "Set on/off to enable/disable "
-                                              "emulating ACLINT devices");
-    }
+
+    object_class_property_add_bool(oc, "aclint", virt_get_aclint,
+                                   virt_set_aclint);
+    object_class_property_set_description(oc, "aclint",
+                                          "(TCG only) Set on/off to "
+                                          "enable/disable emulating "
+                                          "ACLINT devices");
+
     object_class_property_add_str(oc, "aia", virt_get_aia,
                                   virt_set_aia);
     object_class_property_set_description(oc, "aia",
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH for-8.1 1/1] hw/riscv/virt.c: change 'aclint' TCG check

Quoted 12 lines · Daniel Henrique Barboza

The 'aclint' property is being conditioned with tcg acceleration in virt_machine_class_init(). But acceleration code starts later than the class init of the board, meaning that tcg_enabled() will be always be false during class_init(), and the option is never being declared even when declaring TCG accel:

$ ./build/qemu-system-riscv64 -M virt,accel=tcg,aclint=on
qemu-system-riscv64: Property 'virt-machine.aclint' not found

Fix it by moving the check from class_init() to machine_init(). Tune the description to mention that the option is TCG only.

Quoted 7 lines
Cc Philippe Mathieu-Daudé <[email protected]>
Fixes c0716c81b ("hw/riscv/virt: Restrict ACLINT to TCG")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1823

---
  hw/riscv/virt.c | 20 +++++++++++++-------
  1 file changed, 13 insertions(+), 7 deletions(-)
Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH for-8.1 1/1] hw/riscv/virt.c: change 'aclint' TCG check

In reply to Daniel Henrique Barboza
Quoted 10 lines · Daniel Henrique Barboza

The 'aclint' property is being conditioned with tcg acceleration in virt_machine_class_init(). But acceleration code starts later than the class init of the board, meaning that tcg_enabled() will be always be false during class_init(), and the option is never being declared even when declaring TCG accel:

$ ./build/qemu-system-riscv64 -M virt,accel=tcg,aclint=on
qemu-system-riscv64: Property 'virt-machine.aclint' not found
Quoted 7 lines

Fix it by moving the check from class_init() to machine_init(). Tune the description to mention that the option is TCG only.

Cc Philippe Mathieu-Daudé <[email protected]>
Fixes c0716c81b ("hw/riscv/virt: Restrict ACLINT to TCG")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1823

Alistair

Quoted 46 lines
---
 hw/riscv/virt.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
hw/riscv/virt.c +13 -8
index d90286dc46..99c4e6314b 100644
@@ -1350,6 +1350,11 @@ static void virt_machine_init(MachineState *machine)
         exit(1);
     }
 
+    if (!tcg_enabled() && s->have_aclint) {
+        error_report("'aclint' is only available with TCG acceleration");
+        exit(1);
+    }
+
     /* Initialize sockets */
     mmio_irqchip = virtio_irqchip = pcie_irqchip = NULL;
     for (i = 0; i < socket_count; i++) {
@@ -1683,13 +1688,14 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
 #endif
 
-    if (tcg_enabled()) {
-        object_class_property_add_bool(oc, "aclint", virt_get_aclint,
-                                       virt_set_aclint);
-        object_class_property_set_description(oc, "aclint",
-                                              "Set on/off to enable/disable "
-                                              "emulating ACLINT devices");
-    }
+
+    object_class_property_add_bool(oc, "aclint", virt_get_aclint,
+                                   virt_set_aclint);
+    object_class_property_set_description(oc, "aclint",
+                                          "(TCG only) Set on/off to "
+                                          "enable/disable emulating "
+                                          "ACLINT devices");
+
     object_class_property_add_str(oc, "aia", virt_get_aia,
                                   virt_set_aia);
     object_class_property_set_description(oc, "aia",
--

2.41.0

#4 lore raw
In reply to Daniel Henrique Barboza
Quoted 6 lines · Daniel Henrique Barboza

Richard, Alistair,

I came across this gitlab bug earlier today. The bug itself was opened yesterday:

Quoted 8 lines

https://gitlab.com/qemu-project/qemu/-/issues/1823

And turns out that this is a regression in the 'aclint' option that was introduced in 8.1.

I'm aware that we're already in rc3 and kind of late, but even so I marked this patch as 8.1 to let you decide whether it's worth spinning rc4 or not.

Urgh! What a pain!

I'll fire off a PR now as this is worth fixing

Alistair

Quoted 11 lines

Daniel Henrique Barboza (1):
hw/riscv/virt.c: change 'aclint' TCG check

 hw/riscv/virt.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

--
2.41.0