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 <jf...@linux.vnet.ibm.com> > --- > 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 >