Blame SOURCES/kvm-hw-intc-arm_gicv3_its-Implement-a-minimalist-reset.patch

9bac43
From ef9a83242e22841ce988c14870fd9391dc832a99 Mon Sep 17 00:00:00 2001
9bac43
From: Auger Eric <eric.auger@redhat.com>
9bac43
Date: Tue, 28 Nov 2017 15:14:06 +0100
9bac43
Subject: [PATCH 5/9] hw/intc/arm_gicv3_its: Implement a minimalist reset
9bac43
9bac43
RH-Author: Auger Eric <eric.auger@redhat.com>
9bac43
Message-id: <1511882048-11256-6-git-send-email-eric.auger@redhat.com>
9bac43
Patchwork-id: 77943
9bac43
O-Subject: [RHV7.5 qemu-kvm-ma PATCH 5/7] hw/intc/arm_gicv3_its: Implement a minimalist reset
9bac43
Bugzilla: 1513323
9bac43
RH-Acked-by: Andrew Jones <drjones@redhat.com>
9bac43
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
RH-Acked-by: Wei Huang <wei@redhat.com>
9bac43
9bac43
At the moment the ITS is not properly reset and this causes
9bac43
various bugs on save/restore. We implement a minimalist reset
9bac43
through individual register writes but for kernel versions
9bac43
before v4.15 this fails voiding the vITS cache. We cannot
9bac43
claim we have a comprehensive reset (hence the error message)
9bac43
but that's better than nothing.
9bac43
9bac43
Signed-off-by: Eric Auger <eric.auger@redhat.com>
9bac43
9bac43
---
9bac43
v5 -> v6:
9bac43
- add class_size
9bac43
9bac43
v4 -> v5:
9bac43
- correct error message
9bac43
9bac43
v2 -> v3:
9bac43
- individual register writes performed in kvm_arm_its_reset
9bac43
- check KVM_DEV_ARM_VGIC_GRP_ITS_REGS support
9bac43
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 hw/intc/arm_gicv3_its_kvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
9bac43
 1 file changed, 42 insertions(+)
9bac43
9bac43
diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
9bac43
index b1b322b..1c663ac 100644
9bac43
--- a/hw/intc/arm_gicv3_its_kvm.c
9bac43
+++ b/hw/intc/arm_gicv3_its_kvm.c
9bac43
@@ -28,6 +28,16 @@
9bac43
 
9bac43
 #define TYPE_KVM_ARM_ITS "arm-its-kvm"
9bac43
 #define KVM_ARM_ITS(obj) OBJECT_CHECK(GICv3ITSState, (obj), TYPE_KVM_ARM_ITS)
9bac43
+#define KVM_ARM_ITS_CLASS(klass) \
9bac43
+     OBJECT_CLASS_CHECK(KVMARMITSClass, (klass), TYPE_KVM_ARM_ITS)
9bac43
+#define KVM_ARM_ITS_GET_CLASS(obj) \
9bac43
+     OBJECT_GET_CLASS(KVMARMITSClass, (obj), TYPE_KVM_ARM_ITS)
9bac43
+
9bac43
+typedef struct KVMARMITSClass {
9bac43
+    GICv3ITSCommonClass parent_class;
9bac43
+    void (*parent_reset)(DeviceState *dev);
9bac43
+} KVMARMITSClass;
9bac43
+
9bac43
 
9bac43
 static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid)
9bac43
 {
9bac43
@@ -186,6 +196,34 @@ static void kvm_arm_its_post_load(GICv3ITSState *s)
9bac43
                       GITS_CTLR, &s->ctlr, true, &error_abort);
9bac43
 }
9bac43
 
9bac43
+static void kvm_arm_its_reset(DeviceState *dev)
9bac43
+{
9bac43
+    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
9bac43
+    KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s);
9bac43
+    int i;
9bac43
+
9bac43
+    c->parent_reset(dev);
9bac43
+
9bac43
+    error_report("ITS KVM: full reset is not supported by QEMU");
9bac43
+
9bac43
+    if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
9bac43
+                               GITS_CTLR)) {
9bac43
+        return;
9bac43
+    }
9bac43
+
9bac43
+    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
9bac43
+                      GITS_CTLR, &s->ctlr, true, &error_abort);
9bac43
+
9bac43
+    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
9bac43
+                      GITS_CBASER, &s->cbaser, true, &error_abort);
9bac43
+
9bac43
+    for (i = 0; i < 8; i++) {
9bac43
+        kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
9bac43
+                          GITS_BASER + i * 8, &s->baser[i], true,
9bac43
+                          &error_abort);
9bac43
+    }
9bac43
+}
9bac43
+
9bac43
 static Property kvm_arm_its_props[] = {
9bac43
     DEFINE_PROP_LINK("parent-gicv3", GICv3ITSState, gicv3, "kvm-arm-gicv3",
9bac43
                      GICv3State *),
9bac43
@@ -196,12 +234,15 @@ static void kvm_arm_its_class_init(ObjectClass *klass, void *data)
9bac43
 {
9bac43
     DeviceClass *dc = DEVICE_CLASS(klass);
9bac43
     GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass);
9bac43
+    KVMARMITSClass *ic = KVM_ARM_ITS_CLASS(klass);
9bac43
 
9bac43
     dc->realize = kvm_arm_its_realize;
9bac43
     dc->props   = kvm_arm_its_props;
9bac43
+    ic->parent_reset = dc->reset;
9bac43
     icc->send_msi = kvm_its_send_msi;
9bac43
     icc->pre_save = kvm_arm_its_pre_save;
9bac43
     icc->post_load = kvm_arm_its_post_load;
9bac43
+    dc->reset = kvm_arm_its_reset;
9bac43
 }
9bac43
 
9bac43
 static const TypeInfo kvm_arm_its_info = {
9bac43
@@ -209,6 +250,7 @@ static const TypeInfo kvm_arm_its_info = {
9bac43
     .parent = TYPE_ARM_GICV3_ITS_COMMON,
9bac43
     .instance_size = sizeof(GICv3ITSState),
9bac43
     .class_init = kvm_arm_its_class_init,
9bac43
+    .class_size = sizeof(KVMARMITSClass),
9bac43
 };
9bac43
 
9bac43
 static void kvm_arm_its_register_types(void)
9bac43
-- 
9bac43
1.8.3.1
9bac43