All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] target-ppc: SPR_BOOKE_ESR not set on FP exceptions
@ 2016-07-28 23:32 alarson
  2016-07-29  5:40 ` David Gibson
  0 siblings, 1 reply; 4+ messages in thread
From: alarson @ 2016-07-28 23:32 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc; +Cc: David Gibson, agraf

The target-ppc/excp_helper.c:powerpc_excp() case POWERPC_EXCP_FP fails
to set "env->spr[SPR_BOOKE_ESR] = ESR_FP;".  I can submit a patch for
that, or anyone can add it, but I notice that in the other cases where
SPR_BOOKE_ESR is set, the "msr" is ALSO set.  Since the "msr" is used
to initialize SRR1, there is a possibility of inadvertently enabling
BookE MSR bits indirectly.  Given that this code is not performance
sensitive, I think it would be safer to set EITHER msr or the ESR, but
not BOTH.  For example:

            if (excp_model == POWERPC_EXCP_BOOKE)
                env->spr[SPR_BOOKE_ESR] = ESR_FP;
            else
                msr |= 0x00100000;

I did a quick check of the bits set in the POWERPC_EXCP_PROGRAM case.
The classic PPC sets SRR1 bits 11--15 depending on the exception.  In
Book E these correspond to bits 43--47, of which (according to my
EREF) only 45 and 46 are currently defined.  BookE MSR bits 45 (Wait
state enable) and 46 (Critical Enable) correspond to classic SRR1 bits
13 (exception is TRAP) and 14 ("SRR0 is not faulting instruction").
If I understand the current code, given this aliasing then when a TRAP
exception occurs on a book E processor it will effectively enable wait
state, and an FP exception (which sets bit 14/46) will set "Critical
Enable".  I'm not sure that either of these features is currently
implemented so this may not have a downstream effect, but never the
less it seems incorrect.

I can submit a patch for the ESR_FP, and/or a change to have the
"either or but not both" settings of MSR and ESR.  Please let me know
which you'd prefer.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] target-ppc: SPR_BOOKE_ESR not set on FP exceptions
  2016-07-28 23:32 [Qemu-devel] target-ppc: SPR_BOOKE_ESR not set on FP exceptions alarson
@ 2016-07-29  5:40 ` David Gibson
  2016-07-29 13:04   ` alarson
  0 siblings, 1 reply; 4+ messages in thread
From: David Gibson @ 2016-07-29  5:40 UTC (permalink / raw)
  To: alarson; +Cc: qemu-devel, qemu-ppc, agraf

[-- Attachment #1: Type: text/plain, Size: 2488 bytes --]

On Thu, Jul 28, 2016 at 06:32:27PM -0500, alarson@ddci.com wrote:
> The target-ppc/excp_helper.c:powerpc_excp() case POWERPC_EXCP_FP fails
> to set "env->spr[SPR_BOOKE_ESR] = ESR_FP;".  I can submit a patch for
> that,

Ok, please do.

> or anyone can add it, but I notice that in the other cases where
> SPR_BOOKE_ESR is set, the "msr" is ALSO set.  Since the "msr" is used
> to initialize SRR1, there is a possibility of inadvertently enabling
> BookE MSR bits indirectly.

> Given that this code is not performance
> sensitive, I think it would be safer to set EITHER msr or the ESR, but
> not BOTH.  For example:
> 
>             if (excp_model == POWERPC_EXCP_BOOKE)
>                 env->spr[SPR_BOOKE_ESR] = ESR_FP;
>             else
>                 msr |= 0x00100000;

That does seem sensible, assuming those srr1 bits are no correct for
BookE, which they're not IIRC (ESR takes their place).

> I did a quick check of the bits set in the POWERPC_EXCP_PROGRAM case.
> The classic PPC sets SRR1 bits 11--15 depending on the exception.  In
> Book E these correspond to bits 43--47,

Um.. what?  I'm not understanding where this bit shift is coming
from.  The exception code is setting MSR directly, so it should be the
same bit numbers, although they might have a different meaning on
BookE to BookS.

> of which (according to my
> EREF) only 45 and 46 are currently defined.  BookE MSR bits 45 (Wait
> state enable) and 46 (Critical Enable) correspond to classic SRR1 bits
> 13 (exception is TRAP) and 14 ("SRR0 is not faulting instruction").
> If I understand the current code, given this aliasing then when a TRAP
> exception occurs on a book E processor it will effectively enable wait
> state, and an FP exception (which sets bit 14/46) will set "Critical
> Enable".  I'm not sure that either of these features is currently
> implemented so this may not have a downstream effect, but never the
> less it seems incorrect.

I'm not sure about your analysis of which bits are affect, but yes
this definitely does seem wrong.

> I can submit a patch for the ESR_FP, and/or a change to have the
> "either or but not both" settings of MSR and ESR.  Please let me know
> which you'd prefer.

Both fixes please, as separate patches.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] target-ppc: SPR_BOOKE_ESR not set on FP exceptions
  2016-07-29  5:40 ` David Gibson
@ 2016-07-29 13:04   ` alarson
  2016-08-01  4:35     ` David Gibson
  0 siblings, 1 reply; 4+ messages in thread
From: alarson @ 2016-07-29 13:04 UTC (permalink / raw)
  To: David Gibson; +Cc: agraf, qemu-devel, qemu-ppc

David Gibson <david@gibson.dropbear.id.au> wrote on 07/29/2016 12:40:15 
AM:

> From: David Gibson <david@gibson.dropbear.id.au>
> To: alarson@ddci.com
> Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, agraf@suse.de
> Date: 07/29/2016 12:38 AM
> Subject: Re: target-ppc: SPR_BOOKE_ESR not set on FP exceptions
> 
> On Thu, Jul 28, 2016 at 06:32:27PM -0500, alarson@ddci.com wrote:
...
> > I did a quick check of the bits set in the POWERPC_EXCP_PROGRAM case.
> > The classic PPC sets SRR1 bits 11--15 depending on the exception.  In
> > Book E these correspond to bits 43--47,
> 
> Um.. what?  I'm not understanding where this bit shift is coming
> from. 

Sorry, I was looking at an old "classic" 32-bit manual for the SRR1 
exception definition and a 64-bit manual for the BookE.  They are
the same bits.  MSB0 bit numbering bytes again :-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] target-ppc: SPR_BOOKE_ESR not set on FP exceptions
  2016-07-29 13:04   ` alarson
@ 2016-08-01  4:35     ` David Gibson
  0 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2016-08-01  4:35 UTC (permalink / raw)
  To: alarson; +Cc: agraf, qemu-devel, qemu-ppc

[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]

On Fri, Jul 29, 2016 at 08:04:04AM -0500, alarson@ddci.com wrote:
> David Gibson <david@gibson.dropbear.id.au> wrote on 07/29/2016 12:40:15 
> AM:
> 
> > From: David Gibson <david@gibson.dropbear.id.au>
> > To: alarson@ddci.com
> > Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, agraf@suse.de
> > Date: 07/29/2016 12:38 AM
> > Subject: Re: target-ppc: SPR_BOOKE_ESR not set on FP exceptions
> > 
> > On Thu, Jul 28, 2016 at 06:32:27PM -0500, alarson@ddci.com wrote:
> ...
> > > I did a quick check of the bits set in the POWERPC_EXCP_PROGRAM case.
> > > The classic PPC sets SRR1 bits 11--15 depending on the exception.  In
> > > Book E these correspond to bits 43--47,
> > 
> > Um.. what?  I'm not understanding where this bit shift is coming
> > from. 
> 
> Sorry, I was looking at an old "classic" 32-bit manual for the SRR1 
> exception definition and a 64-bit manual for the BookE.  They are
> the same bits.  MSB0 bit numbering bytes again :-)

Ok.  Can you re-do your analysis and submit a patch to fix this?

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-01  4:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-28 23:32 [Qemu-devel] target-ppc: SPR_BOOKE_ESR not set on FP exceptions alarson
2016-07-29  5:40 ` David Gibson
2016-07-29 13:04   ` alarson
2016-08-01  4:35     ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.