qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>,
	patches@linaro.org,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	Blue Swirl <blauwirbel@gmail.com>,
	Amit Shah <amit.shah@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH v2 4/8] target-sparc: Split cpu_put_psr into side-effect and no-side-effect parts
Date: Mon, 11 Jan 2016 12:40:24 +0000	[thread overview]
Message-ID: <1452516028-25218-5-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1452516028-25218-1-git-send-email-peter.maydell@linaro.org>

For inbound migration we really want to be able to set the PSR without
having any side effects, but cpu_put_psr() calls cpu_check_irqs() which
might try to deliver CPU interrupts. Split cpu_put_psr() into the
no-side-effect and side-effect parts.

This includes reordering the cpu_check_irqs() to the end of cpu_put_psr(),
because that function may actually end up calling cpu_interrupt(), which
does not seem like a good thing to happen in the middle of updating the PSR.

Suggested-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-sparc/cpu.h        |  1 +
 target-sparc/win_helper.c | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h
index 4aa689e..d963507 100644
--- a/target-sparc/cpu.h
+++ b/target-sparc/cpu.h
@@ -539,6 +539,7 @@ int cpu_sparc_exec(CPUState *cpu);
 /* win_helper.c */
 target_ulong cpu_get_psr(CPUSPARCState *env1);
 void cpu_put_psr(CPUSPARCState *env1, target_ulong val);
+void cpu_put_psr_raw(CPUSPARCState *env1, target_ulong val);
 #ifdef TARGET_SPARC64
 target_ulong cpu_get_ccr(CPUSPARCState *env1);
 void cpu_put_ccr(CPUSPARCState *env1, target_ulong val);
diff --git a/target-sparc/win_helper.c b/target-sparc/win_helper.c
index f01ae08..5b6d7b5 100644
--- a/target-sparc/win_helper.c
+++ b/target-sparc/win_helper.c
@@ -64,23 +64,28 @@ target_ulong cpu_get_psr(CPUSPARCState *env)
 #endif
 }
 
-void cpu_put_psr(CPUSPARCState *env, target_ulong val)
+void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val)
 {
     env->psr = val & PSR_ICC;
 #if !defined(TARGET_SPARC64)
     env->psref = (val & PSR_EF) ? 1 : 0;
     env->psrpil = (val & PSR_PIL) >> 8;
-#endif
-#if ((!defined(TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
-    cpu_check_irqs(env);
-#endif
-#if !defined(TARGET_SPARC64)
     env->psrs = (val & PSR_S) ? 1 : 0;
     env->psrps = (val & PSR_PS) ? 1 : 0;
     env->psret = (val & PSR_ET) ? 1 : 0;
-    cpu_set_cwp(env, val & PSR_CWP);
 #endif
     env->cc_op = CC_OP_FLAGS;
+#if !defined(TARGET_SPARC64)
+    cpu_set_cwp(env, val & PSR_CWP);
+#endif
+}
+
+void cpu_put_psr(CPUSPARCState *env, target_ulong val)
+{
+    cpu_put_psr_raw(env, val);
+#if ((!defined(TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
+    cpu_check_irqs(env);
+#endif
 }
 
 int cpu_cwp_inc(CPUSPARCState *env, int cwp)
-- 
1.9.1

  parent reply	other threads:[~2016-01-11 12:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 12:40 [Qemu-devel] [PATCH v2 0/8] target-sparc: Update to use VMStateDescription Peter Maydell
2016-01-11 12:40 ` [Qemu-devel] [PATCH v2 1/8] vmstate: introduce CPU_DoubleU arrays Peter Maydell
2016-01-11 12:40 ` [Qemu-devel] [PATCH v2 2/8] vmstate: Introduce VMSTATE_VARRAY_MULTPLY Peter Maydell
2016-01-11 12:40 ` [Qemu-devel] [PATCH v2 3/8] vmstate: define vmstate_info_uinttl Peter Maydell
2016-01-11 12:40 ` Peter Maydell [this message]
2016-01-11 12:40 ` [Qemu-devel] [PATCH v2 5/8] target-sparc: Don't flush TLB in cpu_load function Peter Maydell
2016-01-11 12:40 ` [Qemu-devel] [PATCH v2 6/8] target-sparc: Convert to VMStateDescription Peter Maydell
2016-01-11 12:40 ` [Qemu-devel] [PATCH v2 7/8] target-sparc: Use VMState arrays for SPARC64 TLB/MMU state Peter Maydell
2016-01-11 12:40 ` [Qemu-devel] [PATCH v2 8/8] target-sparc: Migrate CWP and PIL for SPARC64 Peter Maydell
2016-01-15 17:03 ` [Qemu-devel] [PATCH v2 0/8] target-sparc: Update to use VMStateDescription Mark Cave-Ayland
2016-01-15 17:07   ` Peter Maydell
2016-01-15 17:53     ` Mark Cave-Ayland

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=1452516028-25218-5-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=amit.shah@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).