@@ -1,3 +1,4 @@
+#include <linux/kvm.h>
#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/boards.h"
@@ -348,9 +349,38 @@ const char *gicv3_class_name(void)
exit(1);
}
+static GICTypeList *gic_capability_add(GICTypeList *head, GICType type)
+{
+ GICTypeList *item = g_new0(GICTypeList, 1);
+ item->value = type;
+ item->next = head;
+ return item;
+}
+
GICTypeList *qmp_query_gic_capability(Error **errp);
GICTypeList *qmp_query_gic_capability(Error **errp)
{
- return NULL;
+ /* We by default support emulated gicv2 */
+ GICTypeList *head = gic_capability_add(NULL, GIC_TYPE_GICV2);
+
+ /* TODO: add emulated gicv3 type when ready */
+
+#ifdef CONFIG_KVM
+ if (kvm_enabled()) {
+ /* Test KVM GICv2 */
+ if (kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V2,
+ true) >= 0) {
+ head = gic_capability_add(head, GIC_TYPE_GICV2_KVM);
+ }
+
+ /* Test KVM GICv3 */
+ if (kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3,
+ true) >= 0) {
+ head = gic_capability_add(head, GIC_TYPE_GICV3_KVM);
+ }
+ }
+#endif
+
+ return head;
}
For emulated ARM VM, only gicv2 is supported. We need to add gicv3 in when emulated gicv3 ready. For KVM accelerated ARM VM, we detect the capability bits using ioctls. Signed-off-by: Peter Xu <peterx@redhat.com> --- target-arm/machine.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)