public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Gabriel Paubert <paubert@iram•es>
To: Segher Boessenkool <segher@kernel•crashing.org>
Cc: Michael Ellerman <mpe@ellerman•id.au>,
	paulus@samba•org, linuxppc-dev@lists•ozlabs.org
Subject: Re: [PATCH] powerpc: Avoid panic during boot due to divide by zero in init_cache_info()
Date: Sun, 5 Mar 2017 17:58:37 +0100	[thread overview]
Message-ID: <20170305165837.GA2019@visitor2.iram.es> (raw)
In-Reply-To: <20170305123737.GM31469@gate.crashing.org>

On Sun, Mar 05, 2017 at 06:37:37AM -0600, Segher Boessenkool wrote:
> On Sun, Mar 05, 2017 at 09:26:47PM +1100, Michael Ellerman wrote:
> > > I see a panic in early boot when building with a recent gcc toolchain.
> > > The issue is a divide by zero, which is undefined. Older toolchains
> > > let us get away with it:
> > >
> > > int foo(int a) { return a / 0; }
> > >
> > > foo:
> > > 	li 9,0
> > > 	divw 3,3,9
> > > 	extsw 3,3
> > > 	blr
> > >
> > > But newer ones catch it:
> > >
> > > foo:
> > > 	trap
> > >
> > > Add a check to avoid the divide by zero.
> > 
> > Erk sorry. One of the static checkers spotted it, but I hadn't got
> > around to fixing it because it seemed to not actually blow up, guess
> > not.
> 
> The PowerPC divw etc. instructions do not trap by themselves, but recent
> GCC inserts trap instructions on code paths that are always undefined
> behaviour (like, dividing by zero).


Is it systematic or does it depend from, e.g., optimization levels?

Is there anything in the standards about this feature?

    Gabriel

  reply	other threads:[~2017-03-05 17:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 23:54 [PATCH] powerpc: Avoid panic during boot due to divide by zero in init_cache_info() Anton Blanchard
2017-03-05  0:25 ` Benjamin Herrenschmidt
2017-03-05  0:27   ` Benjamin Herrenschmidt
2017-03-05 10:26 ` Michael Ellerman
2017-03-05 12:37   ` Segher Boessenkool
2017-03-05 16:58     ` Gabriel Paubert [this message]
2017-03-05 17:24       ` Segher Boessenkool
2017-03-05 23:09         ` Benjamin Herrenschmidt
2017-03-06  0:10           ` Segher Boessenkool
2017-03-06  0:20             ` Benjamin Herrenschmidt
2017-03-06 12:03         ` Gabriel Paubert
2017-03-06 14:17           ` Segher Boessenkool
2017-03-06 15:18             ` David Laight
2017-03-05 10:36 ` Michael Ellerman
2017-03-08  7:25 ` Michael Ellerman

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=20170305165837.GA2019@visitor2.iram.es \
    --to=paubert@iram$(echo .)es \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=mpe@ellerman$(echo .)id.au \
    --cc=paulus@samba$(echo .)org \
    --cc=segher@kernel$(echo .)crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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