From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
Heinz Graalfs <graalfs@linux.vnet.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>,
"Jason J. herne" <jjherne@us.ibm.com>
Subject: [Qemu-devel] [PATCH 2/3] s390/migration: Qemu S390 special register migration
Date: Wed, 21 Nov 2012 15:46:04 +0100 [thread overview]
Message-ID: <1353509165-26865-3-git-send-email-borntraeger@de.ibm.com> (raw)
In-Reply-To: <1353509165-26865-1-git-send-email-borntraeger@de.ibm.com>
From: "Jason J. herne" <jjherne@us.ibm.com>
Use the KVM ONE_REG capability to save and restore the following special S390
cpu registers: clock comparator, tod clock programmable register and the cpu
timer. Save/loading of these registers is required to enable guest migration on
the S390 platform.
Signed-off-by: Jason J. herne <jjherne@us.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
target-s390x/cpu.h | 4 ++++
target-s390x/machine.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index ba695dd..de77335 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -92,6 +92,10 @@ typedef struct CPUS390XState {
int ext_index;
+ uint64_t ckc;
+ uint64_t cputm;
+ uint32_t todpr;
+
CPU_COMMON
/* reset does memset(0) up to here */
diff --git a/target-s390x/machine.c b/target-s390x/machine.c
index 02706fd..925afb5 100644
--- a/target-s390x/machine.c
+++ b/target-s390x/machine.c
@@ -18,6 +18,7 @@ static void cpu_pre_save(void *opaque)
{
CPUS390XState *env = opaque;
struct kvm_fpu fpu;
+ struct kvm_one_reg reg;
int i, r;
if (!kvm_enabled()) {
@@ -30,12 +31,31 @@ static void cpu_pre_save(void *opaque)
env->fregs[i].ll = fpu.fprs[i];
}
env->fpc = fpu.fpc;
+
+ /* Retreive cpu timer value from kvm */
+ reg.id = KVM_REG_S390_CPU_TIMER;
+ reg.addr = (__u64)&(env->cputm);
+ r = kvm_vcpu_ioctl(env, KVM_GET_ONE_REG, ®);
+ assert(r == 0);
+
+ /* Retreive clock comparator value from kvm */
+ reg.id = KVM_REG_S390_CLOCK_COMP;
+ reg.addr = (__u64)&(env->ckc);
+ r = kvm_vcpu_ioctl(env, KVM_GET_ONE_REG, ®);
+ assert(r == 0);
+
+ /* Retreive clock comparator value from kvm */
+ reg.id = KVM_REG_S390_TODPR;
+ reg.addr = (__u64)&(env->todpr);
+ r = kvm_vcpu_ioctl(env, KVM_GET_ONE_REG, ®);
+ assert(r == 0);
}
static int cpu_post_load(void *opaque, int version_id)
{
CPUS390XState *env = opaque;
struct kvm_fpu fpu;
+ struct kvm_one_reg reg;
int i, r;
if (!kvm_enabled()) {
@@ -50,6 +70,24 @@ static int cpu_post_load(void *opaque, int version_id)
r = kvm_vcpu_ioctl(env, KVM_SET_FPU, &fpu);
assert(r == 0);
+ /* Tell KVM what the new cpu timer value is */
+ reg.id = KVM_REG_S390_CPU_TIMER;
+ reg.addr = (__u64)&(env->cputm);
+ r = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, ®);
+ assert(r == 0);
+
+ /* Tell KVM what the new clock comparator value is */
+ reg.id = KVM_REG_S390_CLOCK_COMP;
+ reg.addr = (__u64)&(env->ckc);
+ r = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, ®);
+ assert(r == 0);
+
+ /* Tell KVM what the new todpr value is */
+ reg.id = KVM_REG_S390_TODPR;
+ reg.addr = (__u64)&(env->todpr);
+ r = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, ®);
+ assert(r == 0);
+
return 0;
}
#else
@@ -93,6 +131,9 @@ static const VMStateDescription vmstate_cpu = {
VMSTATE_UINT64(psw.addr, CPUS390XState),
VMSTATE_UINT64(psa, CPUS390XState),
VMSTATE_UINT32(fpc, CPUS390XState),
+ VMSTATE_UINT32(todpr, CPUS390XState),
+ VMSTATE_UINT64(cputm, CPUS390XState),
+ VMSTATE_UINT64(ckc, CPUS390XState),
VMSTATE_UINT32_ARRAY(aregs, CPUS390XState, 16),
VMSTATE_UINT64_ARRAY(cregs, CPUS390XState, 16),
VMSTATE_END_OF_LIST()
--
1.7.10.1
next prev parent reply other threads:[~2012-11-21 14:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 14:46 [Qemu-devel] [RFC/PATCH 0/3] Initial migration patches for s390 Christian Borntraeger
2012-11-21 14:46 ` [Qemu-devel] [PATCH 1/3] s390/migration: Provide a cpu save for initial life migration work Christian Borntraeger
2012-11-21 14:56 ` Alexander Graf
2012-11-21 14:59 ` Christian Borntraeger
2012-11-21 15:02 ` Alexander Graf
2012-11-21 15:03 ` Christian Borntraeger
2012-11-21 15:06 ` Alexander Graf
2012-11-21 15:08 ` Christian Borntraeger
2012-11-21 15:22 ` Jan Kiszka
2012-11-21 15:27 ` Christian Borntraeger
2012-11-21 15:32 ` Jan Kiszka
2012-11-21 14:46 ` Christian Borntraeger [this message]
2012-11-21 14:57 ` [Qemu-devel] [PATCH 2/3] s390/migration: Qemu S390 special register migration Alexander Graf
2012-11-21 14:46 ` [Qemu-devel] [PATCH 3/3] s390/migration: Add code to support SCLP live migration Christian Borntraeger
2012-11-21 14:58 ` Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353509165-26865-3-git-send-email-borntraeger@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=agraf@suse.de \
--cc=graalfs@linux.vnet.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=jjherne@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).