From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th3H5-0007GK-GT for qemu-devel@nongnu.org; Fri, 07 Dec 2012 14:07:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Th3H3-0006Td-UH for qemu-devel@nongnu.org; Fri, 07 Dec 2012 14:07:51 -0500 Received: from cantor2.suse.de ([195.135.220.15]:40377 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th3H3-0006TV-KE for qemu-devel@nongnu.org; Fri, 07 Dec 2012 14:07:49 -0500 Message-ID: <50C23E81.6020009@suse.de> Date: Fri, 07 Dec 2012 20:07:45 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1354888531-47836-1-git-send-email-jfrei@linux.vnet.ibm.com> <1354888531-47836-4-git-send-email-jfrei@linux.vnet.ibm.com> In-Reply-To: <1354888531-47836-4-git-send-email-jfrei@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/3] s390: add cpu reset handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jens Freimann Cc: Heinz Graalfs , Alexander Graf , qemu-devel , Christian Borntraeger , Cornelia Huck , Einar Lueck Am 07.12.2012 14:55, schrieb Jens Freimann: > Add a CPU reset handler to have all CPUs in a PoP compliant > state. >=20 > Signed-off-by: Jens Freimann > --- > target-s390x/cpu.c | 25 +++++++++++++++++++++++++ > target-s390x/kvm.c | 10 +++++++++- > 2 files changed, 34 insertions(+), 1 deletions(-) >=20 > diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c > index 619b202..a601380 100644 > --- a/target-s390x/cpu.c > +++ b/target-s390x/cpu.c > @@ -4,6 +4,7 @@ > * Copyright (c) 2009 Ulrich Hecht > * Copyright (c) 2011 Alexander Graf > * Copyright (c) 2012 SUSE LINUX Products GmbH > + * Copyright (c) 2012 IBM Corp. > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > @@ -18,12 +19,35 @@ > * You should have received a copy of the GNU Lesser General Public > * License along with this library; if not, see > * > + * Contributions after 2012-12-07 are licensed under the terms of the > + * GNU GPL, version 2 or (at your option) any later version. > + * > */ > =20 > #include "cpu.h" > +#include "hw/hw.h" > #include "qemu-common.h" > #include "qemu-timer.h" > =20 > +/* TODO: remove me, when reset over QOM tree is implemented */ > +static void s390_cpu_machine_reset_cb(void *opaque) > +{ > + S390CPU *cpu =3D opaque; > + CPUS390XState *env =3D &cpu->env; > + > + memset(env->regs, 0, sizeof(env->regs)); > + memset(env->aregs, 0, sizeof(env->aregs)); > + memset(env->cregs, 0, sizeof(env->cregs)); > + memset(env->fregs, 0, sizeof(env->fregs)); > + /* architectured initial values for CR 0 and 14 */ > + env->cregs[0] =3D 0xE0UL; > + env->cregs[14] =3D 0xC2000000UL; > + env->psw.addr =3D 0; > + /* set to z/Architecture mode */ > + env->psw.mask =3D 0x0000000180000000ULL; > + env->psa =3D 0; > + s390_del_running_cpu(env); > +} What's the connection between lack of reset over QOM tree and not calling the existing s390_cpu_reset() from s390_cpu_machine_reset_cb()? Are some CPUS390XState fields maybe misplaced? Regards, Andreas > =20 > /* CPUClass::reset() */ > static void s390_cpu_reset(CPUState *s) > @@ -56,6 +80,7 @@ static void s390_cpu_initfn(Object *obj) > =20 > cpu_exec_init(env); > #if !defined(CONFIG_USER_ONLY) > + qemu_register_reset(s390_cpu_machine_reset_cb, cpu); > qemu_get_timedate(&tm, 0); > env->tod_offset =3D TOD_UNIX_EPOCH + > (time2tod(mktimegm(&tm)) * 1000000000ULL); > diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c > index 94de764..3969a49 100644 > --- a/target-s390x/kvm.c > +++ b/target-s390x/kvm.c > @@ -85,7 +85,15 @@ int kvm_arch_init_vcpu(CPUS390XState *env) > =20 > void kvm_arch_reset_vcpu(CPUS390XState *env) > { > - /* FIXME: add code to reset vcpu. */ > + /* The initial reset call is needed here to reset in-kernel > + * vcpu data that we can't access directly from QEMU > + * (i.e. with older kernels which don't support sync_regs/ONE_REG)= . > + * Before this ioctl cpu_synchronize_state() is called in common k= vm > + * code (kvm-all) */ > + if (kvm_vcpu_ioctl(env, KVM_S390_INITIAL_RESET, NULL)) { > + perror("Can't reset vcpu\n"); > + } > + > } > =20 > int kvm_arch_put_registers(CPUS390XState *env, int level) >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg