[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 032/108] s390x/kvm: rework KVM synchronize to traci
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 032/108] s390x/kvm: rework KVM synchronize to tracing for some ONEREGS |
Date: |
Wed, 6 Aug 2014 15:38:42 -0500 |
From: Christian Borntraeger <address@hidden>
Some ONE_REGS on s390 are not protected by a capability. Older kernels
might not provide those and return an error. Fortunately these registers
are only critical for the migration path. There is no need to error out
on reset and normal runtime. Furthermore, these kernels don't provide
a proper dirty bitmap anyway, so let's use tracing for those errors.
Also provide generic one reg helper to simplify the code.
Signed-off-by: Christian Borntraeger <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
(cherry picked from commit 860643bc5aa902f9b736c57b66e301ef08a2b68e)
Signed-off-by: Michael Roth <address@hidden>
---
target-s390x/kvm.c | 143 ++++++++++++++++++++++++-----------------------------
trace-events | 4 ++
2 files changed, 69 insertions(+), 78 deletions(-)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 2b2dcdc..daaabbd 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -36,6 +36,7 @@
#include "sysemu/device_tree.h"
#include "qapi/qmp/qjson.h"
#include "monitor/monitor.h"
+#include "trace.h"
/* #define DEBUG_KVM */
@@ -128,14 +129,42 @@ void kvm_arch_reset_vcpu(CPUState *cpu)
}
}
+static int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source)
+{
+ struct kvm_one_reg reg;
+ int r;
+
+ reg.id = id;
+ reg.addr = (uint64_t) source;
+ r = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
+ if (r) {
+ trace_kvm_failed_reg_set(id, strerror(errno));
+ }
+ return r;
+}
+
+static int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target)
+{
+ struct kvm_one_reg reg;
+ int r;
+
+ reg.id = id;
+ reg.addr = (uint64_t) target;
+ r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
+ if (r) {
+ trace_kvm_failed_reg_get(id, strerror(errno));
+ }
+ return r;
+}
+
+
int kvm_arch_put_registers(CPUState *cs, int level)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
- struct kvm_one_reg reg;
struct kvm_sregs sregs;
struct kvm_regs regs;
- int ret;
+ int r;
int i;
/* always save the PSW and the GPRS*/
@@ -151,9 +180,9 @@ int kvm_arch_put_registers(CPUState *cs, int level)
for (i = 0; i < 16; i++) {
regs.gprs[i] = env->regs[i];
}
- ret = kvm_vcpu_ioctl(cs, KVM_SET_REGS, ®s);
- if (ret < 0) {
- return ret;
+ r = kvm_vcpu_ioctl(cs, KVM_SET_REGS, ®s);
+ if (r < 0) {
+ return r;
}
}
@@ -162,47 +191,27 @@ int kvm_arch_put_registers(CPUState *cs, int level)
return 0;
}
- reg.id = KVM_REG_S390_CPU_TIMER;
- reg.addr = (__u64)&(env->cputm);
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
- if (ret < 0) {
- return ret;
- }
-
- reg.id = KVM_REG_S390_CLOCK_COMP;
- reg.addr = (__u64)&(env->ckc);
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
- if (ret < 0) {
- return ret;
- }
-
- reg.id = KVM_REG_S390_TODPR;
- reg.addr = (__u64)&(env->todpr);
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
- if (ret < 0) {
- return ret;
- }
+ /*
+ * These ONE_REGS are not protected by a capability. As they are only
+ * necessary for migration we just trace a possible error, but don't
+ * return with an error return code.
+ */
+ kvm_set_one_reg(cs, KVM_REG_S390_CPU_TIMER, &env->cputm);
+ kvm_set_one_reg(cs, KVM_REG_S390_CLOCK_COMP, &env->ckc);
+ kvm_set_one_reg(cs, KVM_REG_S390_TODPR, &env->todpr);
if (cap_async_pf) {
- reg.id = KVM_REG_S390_PFTOKEN;
- reg.addr = (__u64)&(env->pfault_token);
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
- if (ret < 0) {
- return ret;
+ r = kvm_set_one_reg(cs, KVM_REG_S390_PFTOKEN, &env->pfault_token);
+ if (r < 0) {
+ return r;
}
-
- reg.id = KVM_REG_S390_PFCOMPARE;
- reg.addr = (__u64)&(env->pfault_compare);
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
- if (ret < 0) {
- return ret;
+ r = kvm_set_one_reg(cs, KVM_REG_S390_PFCOMPARE, &env->pfault_compare);
+ if (r < 0) {
+ return r;
}
-
- reg.id = KVM_REG_S390_PFSELECT;
- reg.addr = (__u64)&(env->pfault_select);
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
- if (ret < 0) {
- return ret;
+ r = kvm_set_one_reg(cs, KVM_REG_S390_PFSELECT, &env->pfault_select);
+ if (r < 0) {
+ return r;
}
}
@@ -220,9 +229,9 @@ int kvm_arch_put_registers(CPUState *cs, int level)
sregs.acrs[i] = env->aregs[i];
sregs.crs[i] = env->cregs[i];
}
- ret = kvm_vcpu_ioctl(cs, KVM_SET_SREGS, &sregs);
- if (ret < 0) {
- return ret;
+ r = kvm_vcpu_ioctl(cs, KVM_SET_SREGS, &sregs);
+ if (r < 0) {
+ return r;
}
}
@@ -240,7 +249,6 @@ int kvm_arch_get_registers(CPUState *cs)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
- struct kvm_one_reg reg;
struct kvm_sregs sregs;
struct kvm_regs regs;
int i, r;
@@ -288,46 +296,25 @@ int kvm_arch_get_registers(CPUState *cs)
env->psa = cs->kvm_run->s.regs.prefix;
}
- /* One Regs */
- reg.id = KVM_REG_S390_CPU_TIMER;
- reg.addr = (__u64)&(env->cputm);
- r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
- if (r < 0) {
- return r;
- }
-
- reg.id = KVM_REG_S390_CLOCK_COMP;
- reg.addr = (__u64)&(env->ckc);
- r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
- if (r < 0) {
- return r;
- }
-
- reg.id = KVM_REG_S390_TODPR;
- reg.addr = (__u64)&(env->todpr);
- r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
- if (r < 0) {
- return r;
- }
+ /*
+ * These ONE_REGS are not protected by a capability. As they are only
+ * necessary for migration we just trace a possible error, but don't
+ * return with an error return code.
+ */
+ kvm_get_one_reg(cs, KVM_REG_S390_CPU_TIMER, &env->cputm);
+ kvm_get_one_reg(cs, KVM_REG_S390_CLOCK_COMP, &env->ckc);
+ kvm_get_one_reg(cs, KVM_REG_S390_TODPR, &env->todpr);
if (cap_async_pf) {
- reg.id = KVM_REG_S390_PFTOKEN;
- reg.addr = (__u64)&(env->pfault_token);
- r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
+ r = kvm_get_one_reg(cs, KVM_REG_S390_PFTOKEN, &env->pfault_token);
if (r < 0) {
return r;
}
-
- reg.id = KVM_REG_S390_PFCOMPARE;
- reg.addr = (__u64)&(env->pfault_compare);
- r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
+ r = kvm_get_one_reg(cs, KVM_REG_S390_PFCOMPARE, &env->pfault_compare);
if (r < 0) {
return r;
}
-
- reg.id = KVM_REG_S390_PFSELECT;
- reg.addr = (__u64)&(env->pfault_select);
- r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
+ r = kvm_get_one_reg(cs, KVM_REG_S390_PFSELECT, &env->pfault_select);
if (r < 0) {
return r;
}
diff --git a/trace-events b/trace-events
index d97a7cf..37e52ff 100644
--- a/trace-events
+++ b/trace-events
@@ -1223,3 +1223,7 @@ xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen
PV Device MMIO space (ad
# hw/pci/pci_host.c
pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs,
unsigned val) "%s %02u:%u @0x%x -> 0x%x"
pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs,
unsigned val) "%s %02u:%u @0x%x <- 0x%x"
+
+# target-s390/kvm.c
+kvm_failed_reg_get(uint64_t id, const char *msg) "Warning: Unable to retrieve
ONEREG %" PRIu64 " from KVM: %s"
+kvm_failed_reg_set(uint64_t id, const char *msg) "Warning: Unable to set
ONEREG %" PRIu64 " to KVM: %s"
--
1.9.1
- [Qemu-stable] [PATCH 022/108] usb: sanity check setup_index+setup_len in post_load, (continued)
- [Qemu-stable] [PATCH 022/108] usb: sanity check setup_index+setup_len in post_load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 023/108] virtio-scsi: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 014/108] virtio: avoid buffer overrun on incoming migration, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 029/108] po/Makefile: fix $SRC_PATH reference, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 027/108] block: Prevent coroutine stack overflow when recursing in bdrv_open_backing_file., Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 028/108] s390x: empty function stubs in preparation for __KVM_HAVE_GUEST_DEBUG, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 016/108] openpic: avoid buffer overrun on incoming migration, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 030/108] acpi: fix tables for no-hpet configuration, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 031/108] stellaris_enet: block migration, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 033/108] target-i386: fix set of registers zeroed on reset, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 032/108] s390x/kvm: rework KVM synchronize to tracing for some ONEREGS,
Michael Roth <=
- [Qemu-stable] [PATCH 035/108] target-arm: A64: Handle blr lr, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 036/108] target-arm: Make vbar_write 64bit friendly on 32bit hosts, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 037/108] linux-user/elfload.c: Fix incorrect ARM HWCAP bits, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 039/108] linux-user/elfload.c: Fix A64 code which was incorrectly acting like A32, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 038/108] linux-user/elfload.c: Update ARM HWCAP bits, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 026/108] arm: translate.c: Fix smlald Instruction, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 042/108] Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()", Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 041/108] configure: remove bashism, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 043/108] pci-assign: limit # of msix vectors, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 040/108] spapr_pci: Fix number of returned vectors in ibm, change-msi, Michael Roth, 2014/08/06