From patchwork Wed Nov 21 14:46:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 200787 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A7DDB2C008F for ; Thu, 22 Nov 2012 01:46:26 +1100 (EST) Received: from localhost ([::1]:58236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbBZI-00081w-TE for incoming@patchwork.ozlabs.org; Wed, 21 Nov 2012 09:46:24 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbBZ1-0007fx-9I for qemu-devel@nongnu.org; Wed, 21 Nov 2012 09:46:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TbBYr-0001rD-BG for qemu-devel@nongnu.org; Wed, 21 Nov 2012 09:46:07 -0500 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:60893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbBYr-0001r2-39 for qemu-devel@nongnu.org; Wed, 21 Nov 2012 09:45:57 -0500 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Nov 2012 14:45:55 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Nov 2012 14:45:50 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qALEjgOo46268480 for ; Wed, 21 Nov 2012 14:45:42 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qALEjnKL020076 for ; Wed, 21 Nov 2012 07:45:49 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qALEjnMl020066; Wed, 21 Nov 2012 07:45:49 -0700 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id F3D1C122443A; Wed, 21 Nov 2012 15:45:48 +0100 (CET) From: Christian Borntraeger To: Alexander Graf Date: Wed, 21 Nov 2012 15:46:04 +0100 Message-Id: <1353509165-26865-3-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1353509165-26865-1-git-send-email-borntraeger@de.ibm.com> References: <1353509165-26865-1-git-send-email-borntraeger@de.ibm.com> x-cbid: 12112114-0342-0000-0000-00000376888C X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.111 Cc: Christian Borntraeger , Jens Freimann , Heinz Graalfs , qemu-devel , "Jason J. herne" Subject: [Qemu-devel] [PATCH 2/3] s390/migration: Qemu S390 special register migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Jason J. herne" 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 Signed-off-by: Christian Borntraeger --- 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()