Received: from eggs.gnu.org ([208.118.235.92]:41475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbtUW-0002si-Tq for qemu-devel@nongnu.org; Fri, 23 Nov 2012 08:40:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TbtUN-0001yB-Kd for qemu-devel@nongnu.org; Fri, 23 Nov 2012 08:40:24 -0500 Received: from cantor2.suse.de ([195.135.220.15]:44523 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbtUN-0001xM-BG for qemu-devel@nongnu.org; Fri, 23 Nov 2012 08:40:15 -0500 Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <1353665892-35445-3-git-send-email-jfrei@linux.vnet.ibm.com> Date: Fri, 23 Nov 2012 14:40:10 +0100 Content-Transfer-Encoding: 7bit Message-Id: References: <1353665892-35445-1-git-send-email-jfrei@linux.vnet.ibm.com> <1353665892-35445-3-git-send-email-jfrei@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH 2/3] s390: clear registers, psw and prefix at vcpu reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jens Freimann Cc: Heinz Graalfs , qemu-devel , Viktor Mihajlovski , Christian Borntraeger , Cornelia Huck , Einar Lueck On 23.11.2012, at 11:18, Jens Freimann wrote: > When resetting vcpus on s390/kvm we have to clear registers, psw > and prefix as described in the z/Architecture PoP, otherwise a > reboot won't work. IPL PSW and prefix are set later on by the > s390-ipl device reset code. > > Signed-off-by: Jens Freimann > --- > target-s390x/kvm.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c > index 94de764..b1b791e 100644 > --- a/target-s390x/kvm.c > +++ b/target-s390x/kvm.c This needs to go into generic vcpu reset code. Alex > @@ -85,7 +85,31 @@ int kvm_arch_init_vcpu(CPUS390XState *env) > > void kvm_arch_reset_vcpu(CPUS390XState *env) > { > - /* FIXME: add code to reset vcpu. */ > + int i; > + > + /* The initial reset call is needed here to reset in-kernel > + * vcpu data that we can't access directly from QEMU. Before > + * this ioctl cpu_synchronize_state() is called in common kvm > + * code (kvm-all). What remains is clearing registers and psw > + * in QEMU cpu state */ > + if (kvm_vcpu_ioctl(env, KVM_S390_INITIAL_RESET, NULL)) { > + perror("Can't reset vcpu\n"); > + } > + env->halted = 1; > + env->exception_index = EXCP_HLT; > + for (i = 0; i < 16; i++) { > + env->regs[i] = 0; > + env->aregs[i] = 0; > + env->cregs[i] = 0; > + env->fregs[i].ll = 0; > + } > + /* architectured initial values for CR 0 and 14 */ > + env->cregs[0] = 0xE0UL; > + env->cregs[14] = 0xC2000000UL; > + env->fpc = 0; > + env->psw.mask = 0; > + env->psw.addr = 0; > + env->psa = 0; > } > > int kvm_arch_put_registers(CPUS390XState *env, int level) > -- > 1.7.12.4 >