All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@mips.com>
To: Aleksandar Markovic <Aleksandar.Markovic@rt-rk.com>
Cc: Miodrag Dinic <Miodrag.Dinic@imgtec.com>,
	Paul Burton <Paul.Burton@imgtec.com>,
	Petar Jovanovic <Petar.Jovanovic@imgtec.com>,
	"Raghu Gandham" <Raghu.Gandham@imgtec.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Aleksandar Markovic <Aleksandar.Markovic@imgtec.com>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>,
	Douglas Leung <Douglas.Leung@imgtec.com>,
	Goran Ferenc <Goran.Ferenc@imgtec.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Maciej Rozycki <Maciej.Rozycki@imgtec.com>,
	Manuel Lauss <manuel.lauss@gmail.com>,
	"Masahiro Yamada" <yamada.masahiro@socionext.com>
Subject: Re: [PATCH 1/2] MIPS: math-emu: Update debugfs FP exception stats for certain instructions
Date: Thu, 12 Oct 2017 15:44:34 +0100	[thread overview]
Message-ID: <20171012144434.GF15235@jhogan-linux> (raw)
In-Reply-To: <683c-59df7500-1-10d973a0@9889400>

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

On Thu, Oct 12, 2017 at 03:57:50PM +0200, Aleksandar Markovic wrote:
> 
> > Subject: Re: [PATCH 1/2] MIPS: math-emu: Update debugfs FP exception stats for certain instructions
> > Date: Thursday, October 12, 2017 12:17 CEST
> > From: James Hogan <james.hogan@mips.com>>@badag02.ba.imgtec.org>
> > > ...
> > > if ((ctx->fcr31 >> 5) & ctx->fcr31 & FPU_CSR_ALL_E)
> > > ...
> >
> > But just before that condition it does:
> >
> > ctx->fcr31 = (ctx->fcr31 & ~FPU_CSR_ALL_X) | rcsr;
> > I.e. it clears the X bits used in the condition, and overrides them,
> > based on rcsr, which is initialised to 0 and is only set after the
> > copcsr label and in a couple of other cases I don't think we'd be
> > hitting for MADDF.
> >
> 
> The code is odd and deceiving here. Let's see the whole "copcsr label"
> code segment: copcsr:if (ieee754_cxtest(IEEE754_INEXACT)) {  MIPS_FPU_EMU_INC_STATS(ieee754_inexact);  rcsr |= FPU_CSR_INE_X | FPU_CSR_INE_S;}if (ieee754_cxtest(IEEE754_UNDERFLOW)) {  MIPS_FPU_EMU_INC_STATS(ieee754_underflow);  rcsr |= FPU_CSR_UDF_X | FPU_CSR_UDF_S;}if (ieee754_cxtest(IEEE754_OVERFLOW)) {  MIPS_FPU_EMU_INC_STATS(ieee754_overflow);  rcsr |= FPU_CSR_OVF_X | FPU_CSR_OVF_S;}  if (ieee754_cxtest(IEEE754_INVALID_OPERATION)) {  MIPS_FPU_EMU_INC_STATS(ieee754_invalidop);  rcsr |= FPU_CSR_INV_X | FPU_CSR_INV_S;} ctx->fcr31 = (ctx->fcr31 & ~FPU_CSR_ALL_X) | rcsr;if ((ctx->fcr31 >> 5) & ctx->fcr31 & FPU_CSR_ALL_E) {  /*printk ("SIGFPE: FPU csr = %08x\n",  ctx->fcr31); */  return SIGFPE;}

Note: thats the one in fpux_emu(), not fpu_emu() which this patch
modifies. In fpu_emu() the copying of bits from rcsr to fcr32 and the
SIGFPE checking takes place outside of the switch, after other stuff can
modify rcsr.

> 
> 
> Value of rcsr will be dictated by series of invocations to ieee754_cxtest(),
> which, in fact, means that exception bits will be copied from fcr31 to rcsr.
> 
> Then, fcr31 exception bits are cleared and set to the values they had just
> before clearing.
> 
> Obviously, this will not do anything in our scenarios.
> 
> However, the patch is about correct setting of debugfs stats, and this code
> segment correctly does this.

Right, but its not going to even get to copcsr until this patch, so the
SIGFPE handling is I think fixed by this patch, i.e. it isn't just about
the stats.

> 
> May I suggest that we accept my patch as is, and if anybody for any reason
> wants to deal further with related code, this should be done in a separate
> fix/patch?

This patch fixes something, I think it should
a) be clear in the commit message what is fixed
b) be tagged for stable (though that can always be done
retrospectively).

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2017-10-12 14:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06 17:28 [PATCH 0/2] MIPS: Minor FPU emulation fixes Aleksandar Markovic
2017-10-06 17:29 ` [PATCH 1/2] MIPS: math-emu: Update debugfs FP exception stats for certain instructions Aleksandar Markovic
2017-10-09 21:09   ` James Hogan
2017-10-09 21:09     ` James Hogan
2017-10-11 16:18     ` Aleksandar Markovic
2017-10-11 16:18       ` Aleksandar Markovic
2017-10-12 10:17       ` James Hogan
2017-10-12 14:32         ` Aleksandar Markovic
2017-10-12 14:32           ` Aleksandar Markovic
     [not found]         ` <683c-59df7500-1-10d973a0@9889400>
2017-10-12 14:44           ` James Hogan [this message]
2017-10-12 15:54             ` Aleksandar Markovic
2017-10-12 16:33               ` James Hogan
2017-10-06 17:29 ` [PATCH 2/2] MIPS: math-emu: Use preferred flavor of unsigned integer declarations Aleksandar Markovic
2017-10-09 16:59   ` James Hogan
2017-10-09 16:59     ` James Hogan

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=20171012144434.GF15235@jhogan-linux \
    --to=james.hogan@mips.com \
    --cc=Aleksandar.Markovic@imgtec.com \
    --cc=Aleksandar.Markovic@rt-rk.com \
    --cc=Douglas.Leung@imgtec.com \
    --cc=Goran.Ferenc@imgtec.com \
    --cc=Maciej.Rozycki@imgtec.com \
    --cc=Miodrag.Dinic@imgtec.com \
    --cc=Paul.Burton@imgtec.com \
    --cc=Petar.Jovanovic@imgtec.com \
    --cc=Raghu.Gandham@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=manuel.lauss@gmail.com \
    --cc=ralf@linux-mips.org \
    --cc=yamada.masahiro@socionext.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 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.