diff mbox

[v2,09/10] target-arm/kvm.c: better error reporting

Message ID 1405007407-23549-10-git-send-email-alex.bennee@linaro.org
State New
Headers show

Commit Message

Alex Bennée July 10, 2014, 3:50 p.m. UTC
From: Alex Bennée <alex@bennee.com>

When we have a problem syncing CP registers between kvm<->qemu it's a
lot more useful to have the names of the registers in the log than just
a random abort() and core dump.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
v2
  - less verbose log message
  - fix checkpatch warnings

Comments

Peter Maydell Aug. 4, 2014, 1:03 p.m. UTC | #1
On 10 July 2014 16:50, Alex Bennée <alex.bennee@linaro.org> wrote:
> From: Alex Bennée <alex@bennee.com>
>
> When we have a problem syncing CP registers between kvm<->qemu it's a
> lot more useful to have the names of the registers in the log than just
> a random abort() and core dump.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

No particular objection but it seems out of place in this patchset.

-- PMM
diff mbox

Patch

diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 319784d..72e242d 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -279,6 +279,16 @@  void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
     memory_region_ref(kd->mr);
 }
 
+static void failed_cpreg_operation(ARMCPU *cpu, uint64_t regidx, int ret,
+                                   const char *func)
+{
+    uint32_t cpreg_id = kvm_to_cpreg_id(regidx);
+    ARMCPRegInfo *cpreg = g_hash_table_lookup(cpu->cp_regs, &cpreg_id);
+    qemu_log_mask(LOG_UNIMP,
+                  "%s: failed (%d) KVM reg op %"PRIx64" (%s)\n",
+                  func, ret, regidx, cpreg ? cpreg->name : "unknown");
+}
+
 bool write_kvmstate_to_list(ARMCPU *cpu)
 {
     CPUState *cs = CPU(cpu);
@@ -309,6 +319,7 @@  bool write_kvmstate_to_list(ARMCPU *cpu)
             abort();
         }
         if (ret) {
+            failed_cpreg_operation(cpu, regidx, ret, __func__);
             ok = false;
         }
     }
@@ -345,6 +356,7 @@  bool write_list_to_kvmstate(ARMCPU *cpu)
              * "you tried to set a register which is constant with
              * a different value from what it actually contains".
              */
+            failed_cpreg_operation(cpu, regidx, ret, __func__);
             ok = false;
         }
     }