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>,
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 v2] s390: clear registers, psw and prefix at vcpu reset
Date: Tue, 27 Nov 2012 09:33:53 +0100 [thread overview]
Message-ID: <1354005233-60955-1-git-send-email-jfrei@linux.vnet.ibm.com> (raw)
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>
---
changes v1->v2:
- moved cpu reset code from kvm.c to cpu.c
- only kvm initial_reset ioctl remains in kvm.c
- registered reset handler for s390 cpu reset, like x86 does it
target-s390x/cpu.c | 29 +++++++++++++++++++++++++++--
target-s390x/kvm.c | 9 ++++++++-
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 619b202..f74d6f6 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -24,10 +24,21 @@
#include "qemu-common.h"
#include "qemu-timer.h"
+#ifndef CONFIG_USER_ONLY
+#include "hw/s390x/sclp.h"
+
+/* TODO: remove me, when reset over QOM tree is implemented */
+static void s390_cpu_machine_reset_cb(void *opaque)
+{
+ S390CPU *cpu = opaque;
+ cpu_reset(CPU(cpu));
+}
+#endif
/* CPUClass::reset() */
static void s390_cpu_reset(CPUState *s)
{
+ int i;
S390CPU *cpu = S390_CPU(s);
S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
CPUS390XState *env = &cpu->env;
@@ -40,9 +51,22 @@ static void s390_cpu_reset(CPUState *s)
scc->parent_reset(s);
memset(env, 0, offsetof(CPUS390XState, breakpoints));
- /* FIXME: reset vector? */
+
+ 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->psw.mask = 0;
+ env->psw.addr = 0;
+ env->psa = 0;
tlb_flush(env, 1);
- s390_add_running_cpu(env);
}
static void s390_cpu_initfn(Object *obj)
@@ -56,6 +80,7 @@ static void s390_cpu_initfn(Object *obj)
cpu_exec_init(env);
#if !defined(CONFIG_USER_ONLY)
+ qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
qemu_get_timedate(&tm, 0);
env->tod_offset = TOD_UNIX_EPOCH +
(time2tod(mktimegm(&tm)) * 1000000000ULL);
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 94de764..d26555f 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -85,7 +85,14 @@ int kvm_arch_init_vcpu(CPUS390XState *env)
void kvm_arch_reset_vcpu(CPUS390XState *env)
{
- /* FIXME: add code to reset vcpu. */
+ /* The initial reset call is needed here to reset in-kernel
+ * vcpu data that we can't access directly from QEMU
+ * (i.e. with older kernels which don't support sync_regs/ONE_REG).
+ * Before this ioctl cpu_synchronize_state() is called in common kvm
+ * code (kvm-all) */
+ if (kvm_vcpu_ioctl(env, KVM_S390_INITIAL_RESET, NULL)) {
+ perror("Can't reset vcpu\n");
+ }
}
int kvm_arch_put_registers(CPUS390XState *env, int level)
--
1.7.12.4
next reply other threads:[~2012-11-27 8:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 8:33 Jens Freimann [this message]
2012-11-27 9:37 ` [Qemu-devel] [PATCH v2] s390: clear registers, psw and prefix at vcpu reset Alexander Graf
2012-11-27 17:13 ` Jens Freimann
2012-11-27 17:15 ` 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=1354005233-60955-1-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=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).