Skip to contentSkip to conversation

hw/intc/arm_gicv3: Simplify gicv3_class_name() logic

PATCH In review Philippe Mathieu-Daudé 4 participants 4 messages Sep 5, 2023 – Sep 8, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/intc/arm_gicv3: Simplify gicv3_class_name() logic

Simplify gicv3_class_name() logic. No functional change intended.

---
 hw/intc/arm_gicv3_common.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/intc/arm_gicv3_common.c +4 -5
index 2ebf880ead..8863f06b67 100644
@@ -612,13 +612,12 @@ type_init(register_types)
 
 const char *gicv3_class_name(void)
 {
-    if (kvm_irqchip_in_kernel()) {
-        return "kvm-arm-gicv3";
-    } else {
-        if (kvm_enabled()) {
+    if (kvm_enabled()) {
+        if (!kvm_irqchip_in_kernel()) {
             error_report("Userspace GICv3 is not supported with KVM");
             exit(1);
         }
-        return "arm-gicv3";
+        return "kvm-arm-gicv3";
     }
+    return "arm-gicv3";
 }
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 3 lines · Philippe Mathieu-Daudé

Simplify gicv3_class_name() logic. No functional change intended.

Quoted 30 lines
---
 hw/intc/arm_gicv3_common.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/intc/arm_gicv3_common.c +4 -5
index 2ebf880ead..8863f06b67 100644
@@ -612,13 +612,12 @@ type_init(register_types)
 
 const char *gicv3_class_name(void)
 {
-    if (kvm_irqchip_in_kernel()) {
-        return "kvm-arm-gicv3";
-    } else {
-        if (kvm_enabled()) {
+    if (kvm_enabled()) {
+        if (!kvm_irqchip_in_kernel()) {
             error_report("Userspace GICv3 is not supported with KVM");
             exit(1);
         }
-        return "arm-gicv3";
+        return "kvm-arm-gicv3";
     }
+    return "arm-gicv3";
 }
Signature · 1 line
2.41.0
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 20 lines · Philippe Mathieu-Daudé

Simplify gicv3_class_name() logic. No functional change intended.

---
 hw/intc/arm_gicv3_common.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/intc/arm_gicv3_common.c +0 -4
index 2ebf880ead..8863f06b67 100644
@@ -612,13 +612,12 @@ type_init(register_types)
 
 const char *gicv3_class_name(void)
 {
-    if (kvm_irqchip_in_kernel()) {
-        return "kvm-arm-gicv3";
-    } else {
-        if (kvm_enabled()) {

hw/intc/arm_gicv3_common.c type_init(register_types) · line 623

Quoted 10 lines
hw/intc/arm_gicv3_common.c +4 -1
+    if (kvm_enabled()) {
+        if (!kvm_irqchip_in_kernel()) {
             error_report("Userspace GICv3 is not supported with KVM");
             exit(1);
         }
-        return "arm-gicv3";
+        return "kvm-arm-gicv3";
     }
+    return "arm-gicv3";
 }

This doesn't seem to me to be obviously clearer or simpler than the current code, which is the same basic logic as the GICv2 gic_class_name(), but with the extra condition of "report the error for the case we don't support yet". In particular the major condition for "should we be using kvm-arm-gicv3" is not "are we using KVM?" but "are we using the KVM in-kernel irqchip?".

thanks
-- PMM