qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Alexander Graf <agraf@suse.de>
Cc: Scott Wood <scottwood@freescale.com>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 04/15] ppc/booke: fix crit/mcheck/debug exceptions
Date: Fri, 21 Dec 2012 20:15:41 -0600	[thread overview]
Message-ID: <1356142552-13453-5-git-send-email-scottwood@freescale.com> (raw)
In-Reply-To: <1356142552-13453-1-git-send-email-scottwood@freescale.com>

Book E does not play games with certain bits of xSRR1 being MSR save
bits and others being error status.  xSRR1 is the old MSR, period.
This was causing things like MSR[CE] to be lost, even in the saved
version, as soon as you take an exception.

rfci/rfdi/rfmci are fixed to pass the actual xSRR1 register contents,
rather than the register number.

Put FIXME comments on the hack that is "asrr0/1".  The whole point of
separate exception levels is so that you can, for example, take a machine
check or debug interrupt without corrupting critical-level operations.
The right xSRR0/1 set needs to be chosen based on CPU type flags.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 target-ppc/excp_helper.c |   31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/target-ppc/excp_helper.c b/target-ppc/excp_helper.c
index 5e34ad0..41037a7 100644
--- a/target-ppc/excp_helper.c
+++ b/target-ppc/excp_helper.c
@@ -84,7 +84,11 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
                   " => %08x (%02x)\n", env->nip, excp, env->error_code);
 
     /* new srr1 value excluding must-be-zero bits */
-    msr = env->msr & ~0x783f0000ULL;
+    if (excp_model == POWERPC_EXCP_BOOKE) {
+        msr = env->msr;
+    } else {
+        msr = env->msr & ~0x783f0000ULL;
+    }
 
     /* new interrupt handler msr */
     new_msr = env->msr & ((target_ulong)1 << MSR_ME);
@@ -145,6 +149,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
             srr1 = SPR_40x_SRR3;
             break;
         case POWERPC_EXCP_BOOKE:
+            /* FIXME: choose one or the other based on CPU type */
             srr0 = SPR_BOOKE_MCSRR0;
             srr1 = SPR_BOOKE_MCSRR1;
             asrr0 = SPR_BOOKE_CSRR0;
@@ -275,6 +280,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
     case POWERPC_EXCP_DEBUG:     /* Debug interrupt                          */
         switch (excp_model) {
         case POWERPC_EXCP_BOOKE:
+            /* FIXME: choose one or the other based on CPU type */
             srr0 = SPR_BOOKE_DSRR0;
             srr1 = SPR_BOOKE_DSRR1;
             asrr0 = SPR_BOOKE_CSRR0;
@@ -836,8 +842,13 @@ static inline void do_rfi(CPUPPCState *env, target_ulong nip, target_ulong msr,
 
 void helper_rfi(CPUPPCState *env)
 {
-    do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1],
-           ~((target_ulong)0x783F0000), 1);
+    if (env->excp_model == POWERPC_EXCP_BOOKE) {
+        do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1],
+               ~((target_ulong)0), 0);
+    } else {
+        do_rfi(env, env->spr[SPR_SRR0], env->spr[SPR_SRR1],
+               ~((target_ulong)0x783F0000), 1);
+    }
 }
 
 #if defined(TARGET_PPC64)
@@ -864,20 +875,22 @@ void helper_40x_rfci(CPUPPCState *env)
 
 void helper_rfci(CPUPPCState *env)
 {
-    do_rfi(env, env->spr[SPR_BOOKE_CSRR0], SPR_BOOKE_CSRR1,
-           ~((target_ulong)0x3FFF0000), 0);
+    do_rfi(env, env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
+           ~((target_ulong)0), 0);
 }
 
 void helper_rfdi(CPUPPCState *env)
 {
-    do_rfi(env, env->spr[SPR_BOOKE_DSRR0], SPR_BOOKE_DSRR1,
-           ~((target_ulong)0x3FFF0000), 0);
+    /* FIXME: choose CSRR1 or DSRR1 based on cpu type */
+    do_rfi(env, env->spr[SPR_BOOKE_DSRR0], env->spr[SPR_BOOKE_DSRR1],
+           ~((target_ulong)0), 0);
 }
 
 void helper_rfmci(CPUPPCState *env)
 {
-    do_rfi(env, env->spr[SPR_BOOKE_MCSRR0], SPR_BOOKE_MCSRR1,
-           ~((target_ulong)0x3FFF0000), 0);
+    /* FIXME: choose CSRR1 or MCSRR1 based on cpu type */
+    do_rfi(env, env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1],
+           ~((target_ulong)0), 0);
 }
 #endif
 
-- 
1.7.9.5

  parent reply	other threads:[~2012-12-22  2:16 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-22  2:15 [Qemu-devel] [PATCH 00/15] openpic: cleanups and fixes Scott Wood
2012-12-22  2:15 ` [Qemu-devel] [PATCH 01/15] openpic: fix debug prints Scott Wood
2013-01-03 17:31   ` Alexander Graf
2013-01-03 19:41     ` Scott Wood
2012-12-22  2:15 ` [Qemu-devel] [PATCH 02/15] openpic: lower interrupt when reading the MSI register Scott Wood
2013-01-03 17:52   ` Alexander Graf
2012-12-22  2:15 ` [Qemu-devel] [PATCH 03/15] openpic: fix sense and priority bits Scott Wood
2013-01-03 17:51   ` Alexander Graf
2013-01-03 20:12     ` Scott Wood
2012-12-22  2:15 ` Scott Wood [this message]
2013-01-03 17:57   ` [Qemu-devel] [PATCH 04/15] ppc/booke: fix crit/mcheck/debug exceptions Alexander Graf
2012-12-22  2:15 ` [Qemu-devel] [PATCH 05/15] openpic: make register names correspond better with hw docs Scott Wood
2013-01-03 18:18   ` Alexander Graf
2012-12-22  2:15 ` [Qemu-devel] [PATCH 06/15] openpic: rework critical interrupt support Scott Wood
2013-01-03 18:31   ` Alexander Graf
2013-01-03 23:07     ` Scott Wood
2013-01-04  8:04       ` Alexander Graf
2013-01-04 20:46       ` [Qemu-devel] [Qemu-ppc] " Blue Swirl
2013-01-04 20:49         ` Scott Wood
2013-01-04 21:17           ` Blue Swirl
2013-01-04 21:25             ` Scott Wood
2012-12-22  2:15 ` [Qemu-devel] [PATCH 07/15] openpic: make ctpr signed Scott Wood
2013-01-03 18:33   ` Alexander Graf
2012-12-22  2:15 ` [Qemu-devel] [PATCH 08/15] openpic/fsl: critical interrupts ignore mask before v4.1 Scott Wood
2013-01-03 18:37   ` Alexander Graf
2012-12-22  2:15 ` [Qemu-devel] [PATCH 09/15] openpic: always call IRQ_check from IRQ_get_next Scott Wood
2013-01-03 18:42   ` Alexander Graf
2013-01-03 20:09     ` Scott Wood
2012-12-22  2:15 ` [Qemu-devel] [PATCH 10/15] Revert "openpic: Accelerate pending irq search" Scott Wood
2012-12-22  2:15 ` [Qemu-devel] [PATCH 11/15] openpic: use standard bitmap operations Scott Wood
2013-01-03 18:49   ` Alexander Graf
2012-12-22  2:15 ` [Qemu-devel] [PATCH 12/15] openpic: IRQ_check: search the queue a word at a time Scott Wood
2013-01-03 18:53   ` Alexander Graf
2013-01-03 20:07     ` Scott Wood
2013-01-03 20:31       ` Alexander Graf
2013-01-03 20:32         ` Scott Wood
2013-01-03 20:57           ` Alexander Graf
2013-01-03 21:52             ` Scott Wood
2012-12-22  2:15 ` [Qemu-devel] [PATCH 13/15] openpic: add some bounds checking for IRQ numbers Scott Wood
2013-01-03 18:55   ` Alexander Graf
2013-01-03 19:54     ` [Qemu-devel] [Qemu-ppc] " Scott Wood
2013-01-03 21:07       ` Alexander Graf
2013-01-03 21:20         ` Scott Wood
2012-12-22  2:15 ` [Qemu-devel] [PATCH 14/15] openpic: move IACK to its own function Scott Wood
2013-01-03 18:59   ` Alexander Graf
2012-12-22  2:15 ` [Qemu-devel] [PATCH 15/15] openpic: fix CTPR and de-assertion of interrupts Scott Wood
2013-01-03 19:00   ` 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=1356142552-13453-5-git-send-email-scottwood@freescale.com \
    --to=scottwood@freescale.com \
    --cc=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).