All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Luis Chamberlain <mcgrof@kernel.org>,
	Petr Pavlu <petr.pavlu@suse.com>,
	 Sami Tolvanen <samitolvanen@google.com>,
	 Daniel Gomez <da.gomez@samsung.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 Helge Deller <deller@gmx.de>,
	linux-modules@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-parisc@vger.kernel.org
Subject: Unaligned accesses when loading modules
Date: Tue, 14 Jan 2025 19:07:30 +0100 (CET)	[thread overview]
Message-ID: <1665d54c-178f-ff72-e627-776e7c76798b@redhat.com> (raw)

Hi

On PA-RISC, with the kernel 6.12.9, I get unaligned pointer warnings when 
a module is loaded. The warnings are caused by the fact that the 
.gnu.linkonce.this_module section is not aligned to the appropriate 
boundary. If I dump the module content with "objdump -h configs.ko", I get 
this. Note that the .gnu.linkonce.this_module has "File off 000042d2" and 
"Algn 2**4".

On x86-64, the same misalignment can be seen, but it doesn't cause 
warnings because unaligned pointers are handled in hardware.

This seems to be a bug in the linker, because when I compile an old kernel 
with a new linker, I also get the misalignment. Do you have an idea how to 
work around this bug?

Mikulas


kernel-6.12.9, binutils from Debian ports:

configs.ko:     file format elf64-hppa-linux

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         00000040  0000000000000000  0000000000000000  00000040  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .init.text    00000070  0000000000000000  0000000000000000  00000080  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  2 .exit.text    00000028  0000000000000000  0000000000000000  000000f0  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  3 .rodata       00004015  0000000000000000  0000000000000000  00000118  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .rodata.str1.8 00000010  0000000000000000  0000000000000000  0000412d  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .PARISC.unwind 00000030  0000000000000000  0000000000000000  0000413d  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  6 .modinfo      000000a1  0000000000000000  0000000000000000  0000416d  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .note.gnu.build-id 00000024  0000000000000000  0000000000000000  0000420e  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .note.Linux   00000030  0000000000000000  0000000000000000  00004232  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .data         00000000  0000000000000030  0000000000000030  00004262  2**0
                  CONTENTS, ALLOC, LOAD, DATA
 10 .exit.data    00000008  0000000000000000  0000000000000000  00004262  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
 11 .init.data    00000008  0000000000000000  0000000000000000  0000426a  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
 12 .data.rel.ro  00000060  0000000000000000  0000000000000000  00004272  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
 13 .gnu.linkonce.this_module 000002d0  0000000000000000  0000000000000000  000042d2  2**4
                  CONTENTS, ALLOC, LOAD, RELOC, DATA, LINK_ONCE_DISCARD
 14 .bss          00000000  0000000000000000  0000000000000000  000045a2  2**0
                  ALLOC
 15 .comment      00000039  0000000000000000  0000000000000000  000045a2  2**0
                  CONTENTS, READONLY
 16 .note.GNU-stack 00000000  0000000000000000  0000000000000000  000045db  2**0
                  CONTENTS, READONLY

With the kernel 6.10, I get this - the ".gnu.linkonce.this_module" 
sections has "File off 00004210" and "Algn 2**4" - so, it is properly 
aligned.

kernel 6.10, older binutils:

configs.ko:     file format elf64-hppa-linux

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .note.gnu.build-id 00000024  0000000000000000  0000000000000000  00000040  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .note.Linux   00000030  0000000000000000  0000000000000000  00000064  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .text         00000040  0000000000000000  0000000000000000  00000098  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  3 .init.text    00000070  0000000000000000  0000000000000000  000000d8  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  4 .exit.text    00000028  0000000000000000  0000000000000000  00000148  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  5 .rodata       00003f45  0000000000000000  0000000000000000  00000170  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .rodata.str1.8 00000010  0000000000000000  0000000000000000  000040b8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .PARISC.unwind 00000030  0000000000000000  0000000000000000  000040c8  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
  8 .modinfo      000000a1  0000000000000000  0000000000000000  000040f8  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .data         00000007  00000000000000a1  00000000000000a1  00004199  2**0
                  CONTENTS, ALLOC, LOAD, DATA
 10 .exit.data    00000008  0000000000000000  0000000000000000  000041a0  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
 11 .init.data    00000008  0000000000000000  0000000000000000  000041a8  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
 12 .data.rel.ro  00000060  0000000000000000  0000000000000000  000041b0  2**3
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
 13 .gnu.linkonce.this_module 000002d0  0000000000000000  0000000000000000  00004210  2**4
                  CONTENTS, ALLOC, LOAD, RELOC, DATA, LINK_ONCE_DISCARD
 14 .bss          00000000  0000000000000000  0000000000000000  000044e0  2**0
                  ALLOC
 15 .comment      00000026  0000000000000000  0000000000000000  000044e0  2**0
                  CONTENTS, READONLY
 16 .note.GNU-stack 00000000  0000000000000000  0000000000000000  00004506  2**0
                  CONTENTS, READONLY


             reply	other threads:[~2025-01-14 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14 18:07 Mikulas Patocka [this message]
2025-01-14 22:37 ` Unaligned accesses when loading modules Sami Tolvanen
2025-01-15 18:02   ` Mikulas Patocka
2025-01-16  7:59     ` Jan Beulich
2025-01-16 15:29       ` Mikulas Patocka
2025-01-16 16:00         ` Jan Beulich
2025-01-17  2:00           ` Maciej W. Rozycki

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=1665d54c-178f-ff72-e627-776e7c76798b@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=da.gomez@samsung.com \
    --cc=deller@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=samitolvanen@google.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.