2006-09-29 08:57:47

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH RFC 1/4] Generic BUG handling.

> Some architectures (powerpc) implement WARN using the same mechanism;
> if the illegal instruction was the result of a WARN, then report_bug()
> returns 1; otherwise it returns 0.

In theory we could do that on x86 too (and skipping the instruction),
the only problem
is that the only guaranteed to fault opcode is ud2 :/. Ok maybe we could
reserve some int XXX vector.

% gid WARN_ON | grep -v arch | wc -l
299

-Andi


2006-09-29 09:10:34

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH RFC 1/4] Generic BUG handling.

On 29 Sep 2006 10:57:45 +0200
Andi Kleen <[email protected]> wrote:

> > Some architectures (powerpc) implement WARN using the same mechanism;
> > if the illegal instruction was the result of a WARN, then report_bug()
> > returns 1; otherwise it returns 0.
>
> In theory we could do that on x86 too (and skipping the instruction),
> the only problem
> is that the only guaranteed to fault opcode is ud2 :/. Ok maybe we could
> reserve some int XXX vector.
>
> % gid WARN_ON | grep -v arch | wc -l
> 299

powerpc sets a bit in the __LINE__ number to indicate that it was a
WARN_ON. That'll work on all architectures.

2006-09-29 09:13:21

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH RFC 1/4] Generic BUG handling.

On Fri, Sep 29, 2006 at 02:10:19AM -0700, Andrew Morton wrote:
> On 29 Sep 2006 10:57:45 +0200
> Andi Kleen <[email protected]> wrote:
>
> > > Some architectures (powerpc) implement WARN using the same mechanism;
> > > if the illegal instruction was the result of a WARN, then report_bug()
> > > returns 1; otherwise it returns 0.
> >
> > In theory we could do that on x86 too (and skipping the instruction),
> > the only problem
> > is that the only guaranteed to fault opcode is ud2 :/. Ok maybe we could
> > reserve some int XXX vector.
> >
> > % gid WARN_ON | grep -v arch | wc -l
> > 299
>
> powerpc sets a bit in the __LINE__ number to indicate that it was a
> WARN_ON. That'll work on all architectures.

We still would need an architecture dependent way to skip the opcode
though (just returning would raise it again). On x86

regs->eip += 2 (rip on x86-64)

should be enough

-Andi

2006-09-29 09:18:47

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH RFC 1/4] Generic BUG handling.

On 29 Sep 2006 11:13:19 +0200
Andi Kleen <[email protected]> wrote:

> On Fri, Sep 29, 2006 at 02:10:19AM -0700, Andrew Morton wrote:
> > On 29 Sep 2006 10:57:45 +0200
> > Andi Kleen <[email protected]> wrote:
> >
> > > > Some architectures (powerpc) implement WARN using the same mechanism;
> > > > if the illegal instruction was the result of a WARN, then report_bug()
> > > > returns 1; otherwise it returns 0.
> > >
> > > In theory we could do that on x86 too (and skipping the instruction),
> > > the only problem
> > > is that the only guaranteed to fault opcode is ud2 :/. Ok maybe we could
> > > reserve some int XXX vector.
> > >
> > > % gid WARN_ON | grep -v arch | wc -l
> > > 299
> >
> > powerpc sets a bit in the __LINE__ number to indicate that it was a
> > WARN_ON. That'll work on all architectures.
>
> We still would need an architecture dependent way to skip the opcode
> though (just returning would raise it again). On x86
>
> regs->eip += 2 (rip on x86-64)
>
> should be enough
>

We have all that now. Do:

if (report_bug(regs->eip) == BUG_TRAP_TYPE_WARN)
regs>eip += 2;

(The powerpc is_warning_bug() implementation needs to be hoisted into
generic code)