From patchwork Fri Nov 23 10:18:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/3] s390: clear registers, psw and prefix at vcpu reset From: Jens Freimann X-Patchwork-Id: 201284 Message-Id: <1353665892-35445-3-git-send-email-jfrei@linux.vnet.ibm.com> To: Alexander Graf Cc: Heinz Graalfs , qemu-devel , Viktor Mihajlovski , Christian Borntraeger , Jens Freimann , Cornelia Huck , Einar Lueck Date: Fri, 23 Nov 2012 11:18:11 +0100 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 @@ -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)