From patchwork Fri Nov 23 10:18:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 201284 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 396B22C0081 for ; Fri, 23 Nov 2012 21:19:25 +1100 (EST) Received: from localhost ([::1]:52715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbqLz-0001e1-8T for incoming@patchwork.ozlabs.org; Fri, 23 Nov 2012 05:19:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbqLF-0000DR-Tr for qemu-devel@nongnu.org; Fri, 23 Nov 2012 05:18:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TbqLB-0006gT-PF for qemu-devel@nongnu.org; Fri, 23 Nov 2012 05:18:37 -0500 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:56333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbqLB-0006fq-Gv for qemu-devel@nongnu.org; Fri, 23 Nov 2012 05:18:33 -0500 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 23 Nov 2012 10:18:29 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 23 Nov 2012 10:18:27 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qANAIJB464094354 for ; Fri, 23 Nov 2012 10:18:19 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 qANAIQXO004933 for ; Fri, 23 Nov 2012 03:18:27 -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 qANAIQSZ004914; Fri, 23 Nov 2012 03:18:26 -0700 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id 92A601224439; Fri, 23 Nov 2012 11:18:26 +0100 (CET) From: Jens Freimann To: Alexander Graf Date: Fri, 23 Nov 2012 11:18:11 +0100 Message-Id: <1353665892-35445-3-git-send-email-jfrei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1353665892-35445-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1353665892-35445-1-git-send-email-jfrei@linux.vnet.ibm.com> x-cbid: 12112310-5024-0000-0000-000004793013 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.107 Cc: Heinz Graalfs , qemu-devel , Viktor Mihajlovski , Christian Borntraeger , Jens Freimann , Cornelia Huck , Einar Lueck Subject: [Qemu-devel] [PATCH 2/3] s390: clear registers, psw and prefix at vcpu reset 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 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)