Re: [tip:x86/tdx 8/12] vmlinux.o: warning: objtool: __tdx_hypercall+0x128: __tdx_hypercall_failed() is missing a __noreturn annotation

From: Michael Matz
Date: Thu Sep 14 2023 - 10:52:48 EST


Hey,

On Thu, 14 Sep 2023, Peter Zijlstra wrote:

> > > > It appears the __noreturn must be annotated to the function declaration
> > > > but not the function body. I'll send out the fix as soon as I confirm
> > > > the fix with LKP.
> > >
> > > FWIW, the reason being that...
> > >
> > > The point of noreturn is that the caller should know to stop generating
> > > code. For that the declaration needs the attribute, because call sites
> > > typically do not have access to the function definition in C.
> >
> > BTW., arguably shouldn't the compiler generate a warning to begin with,
> > when it encounters a noreturn function definition whose prototype doesn't
> > have the attribute?
>
> Yeah, I would agree with that,

That makes sense, yeah. We actually have a warning -Wmissing-attributes
that would fit this usecase, but currently doesn't implement this case (it
only applies to aliases, not to decl vs. def).

> but I think the problem is that gnu
> attributes are all considered 'optional' and do not factor into the
> actual signature.

That actually depends on the attribute :) Most attributes are like that,
true, but some aren't optional in that sense as they influence the
callee-caller contract (e.g. those that change the ABI, like fastcall).
Those must then be part of the functions type.

'noreturn' is optional in that sense. But a warning might still be
warranted.


Ciao,
Michael.