From: Jens Freimann <jfrei@linux.vnet.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: Heinz Graalfs <graalfs@linux.vnet.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>,
Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Einar Lueck <elelueck@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 2/3] s390: clear registers, psw and prefix at vcpu reset
Date: Fri, 23 Nov 2012 11:18:11 +0100 [thread overview]
Message-ID: <1353665892-35445-3-git-send-email-jfrei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1353665892-35445-1-git-send-email-jfrei@linux.vnet.ibm.com>
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 <jfrei@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
@@ -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
next prev parent reply other threads:[~2012-11-23 10:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-23 10:18 [Qemu-devel] [PATCH 0/3] s390: vcpu reset, -cpu ? and minor sclp fix Jens Freimann
2012-11-23 10:18 ` [Qemu-devel] [PATCH 1/3] S390: Basic CPU model support Jens Freimann
2012-11-23 15:25 ` Andreas Färber
2012-11-23 10:18 ` Jens Freimann [this message]
2012-11-23 13:40 ` [Qemu-devel] [PATCH 2/3] s390: clear registers, psw and prefix at vcpu reset Alexander Graf
2012-11-23 14:17 ` Jens Freimann
2012-11-23 14:32 ` Christian Borntraeger
2012-11-23 14:34 ` Alexander Graf
2012-11-23 14:52 ` Jens Freimann
2012-11-23 15:02 ` Peter Maydell
2012-11-23 15:13 ` Alexander Graf
2012-11-23 10:18 ` [Qemu-devel] [PATCH 3/3] sclp: Fix uninitialized var in handle_write_event_buf() Jens Freimann
2012-11-23 13:42 ` Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353665892-35445-3-git-send-email-jfrei@linux.vnet.ibm.com \
--to=jfrei@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=elelueck@linux.vnet.ibm.com \
--cc=graalfs@linux.vnet.ibm.com \
--cc=mihajlov@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).