Re: [PATCH 1/3] module: deal with alignment issues in built-inmodule versions

From: Dmitry Torokhov
Date: Thu Feb 17 2011 - 13:01:42 EST


On Thu, Feb 17, 2011 at 09:45:37AM -0800, Linus Torvalds wrote:
> On Thu, Feb 17, 2011 at 9:31 AM, Dmitry Torokhov <dtor@xxxxxxxxxx> wrote:
> >
> > From what I understand __attribute__ ((aligned(x))) only guarantees
> > minimum alignment, not exact (gapless) alignment. GCC seems to lay out
> > pointers in the section without gaps on all arches that we have.
>
> I still don't see the problem.
>
> Have you actually _tried_ just adding the proper alignment to before
> the __modver thing in include/asm-generic/vmlinux.lds.h ?
>
> As far as I can tell, the bug is really simple:
> - the section is not aligned
> - but we told the compiler that that structure is aligned
>
> End result: there is a gap between the section start and the first structure.
>
> And the fix seems obvious: just make sure that the section is
> sufficiently aligned.
>
> IOW, why isn't the proper fix the obvious trivial one (attached)?
>

The problem is that on m68k size of the struct module_version_attribute
is not evenly divisible by sizeof(void *), thus when we lay out the
__modver section we align on 4 bytes but when we iterate we think that
the alignment is 2.

I/Geert tried adding __attribute__ (aligned(sizeof(void *))) to the type
definition itself so we have matching alignment everywhere, but DaveM
said that this only guarantees minimum alignment and that using
structures like we do shown to break from time to time in kprobes and
that only pointers worked reliably.

Thanks.

--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/