Skip to contentSkip to conversation

target/arm/kvm: gic: Prevent creating userspace GICv3 with KVM

PATCH Applied Christoffer Dall 4 participants 5 messages Feb 1, 2018 – Feb 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm/kvm: gic: Prevent creating userspace GICv3 with KVM

KVM doesn't support emulating a GICv3 in userspace, only GICv2. We currently attempt this anyway, and as a result a KVM guest doesn't receive interrupts and the user is left wondering why. Report an error to the user if this particular combination is requested.

---
 target/arm/kvm_arm.h | 4 ++++
 1 file changed, 4 insertions(+)
target/arm/kvm_arm.h +4 -0
index ff53e9fafb..cfb7e5af72 100644
@@ -234,6 +234,10 @@ static inline const char *gicv3_class_name(void)
         exit(1);
 #endif
     } else {
+        if (kvm_enabled()) {
+            error_report("Userspace GICv3 is not supported with KVM");
+            exit(1);
+        }
         return "arm-gicv3";
     }
 }
Signature · 1 line
2.14.2
Reviewed-by on v1 1/1
#1 lore raw

Hi Christoffer,

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void)

Quoted 15 lines · Christoffer Dall

KVM doesn't support emulating a GICv3 in userspace, only GICv2. We currently attempt this anyway, and as a result a KVM guest doesn't receive interrupts and the user is left wondering why. Report an error to the user if this particular combination is requested.

---
 target/arm/kvm_arm.h | 4 ++++
 1 file changed, 4 insertions(+)
target/arm/kvm_arm.h +0 -0
index ff53e9fafb..cfb7e5af72 100644
@@ -234,6 +234,10 @@ static inline const char *gicv3_class_name(void)

Any reason why these functions are inlined in this include?

Also - not related to your patch - while gicv3_class_name() is self-explicit, gic_class_name() isn't (to me at least).

There are many check for gic_version 1/2/3 in virt.c, which we could clean using more generic functions such gic_class_name(int gic_version) and Co.

Alistair/Edgar:
Why the ZynqMP is not using the GICv3 for the APU? I remember hearing something about not fully implemented so not working correctly.

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void) · line 239

Quoted 6 lines
target/arm/kvm_arm.h +3 -0
         exit(1);
 #endif
     } else {
+        if (kvm_enabled()) {
+            error_report("Userspace GICv3 is not supported with KVM");
+            exit(1);

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void) · line 243

Quoted 5 lines
target/arm/kvm_arm.h +1 -0
+        }
         return "arm-gicv3";
     }
 }

Regards,

Phil.

#2 lore raw
Quoted 24 lines · Philippe Mathieu-Daudé

Hi Christoffer,

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void)

Quoted 15 lines · Christoffer Dall

KVM doesn't support emulating a GICv3 in userspace, only GICv2. We currently attempt this anyway, and as a result a KVM guest doesn't receive interrupts and the user is left wondering why. Report an error to the user if this particular combination is requested.

---
 target/arm/kvm_arm.h | 4 ++++
 1 file changed, 4 insertions(+)
target/arm/kvm_arm.h +0 -0
index ff53e9fafb..cfb7e5af72 100644
@@ -234,6 +234,10 @@ static inline const char *gicv3_class_name(void)

Any reason why these functions are inlined in this include?

Also - not related to your patch - while gicv3_class_name() is self-explicit, gic_class_name() isn't (to me at least).

Quoted 7 lines

There are many check for gic_version 1/2/3 in virt.c, which we could clean using more generic functions such gic_class_name(int gic_version) and Co.

Alistair/Edgar:
Why the ZynqMP is not using the GICv3 for the APU? I remember hearing something about not fully implemented so not working correctly.

The ZynqMP only has a GICv2.

Maybe you are thinking of the virtualisation features? Mainline doesn't have those fully implemented so they don't work correctly.

Alistair

Quoted 20 lines

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void) · line 239

Quoted 7 lines
target/arm/kvm_arm.h +3 -0
         exit(1);
 #endif
     } else {
+        if (kvm_enabled()) {
+            error_report("Userspace GICv3 is not supported with KVM");
+            exit(1);

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void) · line 243

Quoted 5 lines
target/arm/kvm_arm.h +1 -0
+        }
         return "arm-gicv3";
     }
 }

Regards,

Phil.

#3 lore raw
In reply to Philippe Mathieu-Daudé

Hi Philippe,

Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Christoffer Dall

KVM doesn't support emulating a GICv3 in userspace, only GICv2. We currently attempt this anyway, and as a result a KVM guest doesn't receive interrupts and the user is left wondering why. Report an error to the user if this particular combination is requested.

---
 target/arm/kvm_arm.h | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 7 lines

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void)

Quoted 5 lines
target/arm/kvm_arm.h +0 -0
index ff53e9fafb..cfb7e5af72 100644
@@ -234,6 +234,10 @@ static inline const char *gicv3_class_name(void)

Any reason why these functions are inlined in this include?

Not really sure what you mean? What do you think would be a better approach?

Quoted 3 lines

Also - not related to your patch - while gicv3_class_name() is self-explicit, gic_class_name() isn't (to me at least).

I think I tend to see 'gic' as GICv2 and 'gicv3' as GICv3 in QEMU, but I don't remember the details of how you make the GIC be a proper GICv2 vs. the 11mpcore version thingy.

Quoted 4 lines

There are many check for gic_version 1/2/3 in virt.c, which we could clean using more generic functions such gic_class_name(int gic_version) and Co.

Possibly. Do note, that checking "which version of the GIC does this board contain" is a separate thing from "which particular mechanism do I use to emulate the GIC".

Quoted 16 lines

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void) · line 239

Quoted 7 lines
target/arm/kvm_arm.h +3 -0
         exit(1);
 #endif
     } else {
+        if (kvm_enabled()) {
+            error_report("Userspace GICv3 is not supported with KVM");
+            exit(1);
Quoted 5 lines
target/arm/kvm_arm.h +1 -0
+        }
         return "arm-gicv3";
     }
 }

Thanks!
-Christoffer

#4 lore raw
In reply to Christoffer Dall
Quoted 15 lines · Christoffer Dall

KVM doesn't support emulating a GICv3 in userspace, only GICv2. We currently attempt this anyway, and as a result a KVM guest doesn't receive interrupts and the user is left wondering why. Report an error to the user if this particular combination is requested.

---
 target/arm/kvm_arm.h | 4 ++++
 1 file changed, 4 insertions(+)
target/arm/kvm_arm.h +0 -0
index ff53e9fafb..cfb7e5af72 100644

target/arm/kvm_arm.h static inline const char *gicv3_class_name(void) · line 242

Quoted 9 lines
target/arm/kvm_arm.h +4 -0
@@ -234,6 +234,10 @@ static inline const char *gicv3_class_name(void)
         exit(1);
 #endif
     } else {
+        if (kvm_enabled()) {
+            error_report("Userspace GICv3 is not supported with KVM");
+            exit(1);
+        }
         return "arm-gicv3";
     }

Applied to target-arm.next, thanks.

-- PMM