linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: vmlinux.lds.S: Fix appended dtb not properly aligned
@ 2021-03-16 15:45 Paul Cercueil
  2021-03-16 17:02 ` Bjørn Mork
  2021-03-16 21:59 ` Thomas Bogendoerfer
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Cercueil @ 2021-03-16 15:45 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: od, linux-mips, linux-kernel, Paul Cercueil, Bjørn Mork

Commit 6654111c893f ("MIPS: vmlinux.lds.S: align raw appended dtb to 8
bytes") changed the alignment from STRUCT_ALIGNMENT bytes to 8 bytes.

The commit's message makes it sound like it was actually done on
purpose, but this is not the case. The commit was written when raw
appended dtb were not aligned at all. The STRUCT_ALIGN() was added a few
days before, in commit 7a05293af39f ("MIPS: boot/compressed: Copy DTB to
aligned address"). The true purpose of the commit was not to align
specifically to 8 bytes, but to make sure that the generated vmlinux'
size was properly padded to the alignment required for DTBs.

While the switch to 8-byte alignment worked for vmlinux-appended dtb
blobs, it broke vmlinuz-appended dtb blobs, as the decompress routine
moves the blob to a STRUCT_ALIGNMENT aligned address.

Fix this by changing the raw appended dtb blob alignment from 8 bytes
back to STRUCT_ALIGNMENT bytes in vmlinux.lds.S.

Fixes: 6654111c893f ("MIPS: vmlinux.lds.S: align raw appended dtb to 8 bytes")
Cc: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 arch/mips/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 1234834cc4c4..1f98947fe715 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -176,7 +176,7 @@ SECTIONS
 	.fill : {
 		FILL(0);
 		BYTE(0);
-		. = ALIGN(8);
+		STRUCT_ALIGN();
 	}
 	__appended_dtb = .;
 	/* leave space for appended DTB */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: vmlinux.lds.S: Fix appended dtb not properly aligned
  2021-03-16 15:45 [PATCH] MIPS: vmlinux.lds.S: Fix appended dtb not properly aligned Paul Cercueil
@ 2021-03-16 17:02 ` Bjørn Mork
  2021-03-16 21:59 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 3+ messages in thread
From: Bjørn Mork @ 2021-03-16 17:02 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Thomas Bogendoerfer, od, linux-mips, linux-kernel

Paul Cercueil <paul@crapouillou.net> writes:

> Commit 6654111c893f ("MIPS: vmlinux.lds.S: align raw appended dtb to 8
> bytes") changed the alignment from STRUCT_ALIGNMENT bytes to 8 bytes.

Ouch.  That was not my intention.  I see that there was a mixup with my
initial patch. My last version used STRUCT_ALIGNMENT, but might have
been lost since I sent it only as an attachment during the discussion.

Sorry for not catching this.  And thanks for fixing.


Bjørn

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: vmlinux.lds.S: Fix appended dtb not properly aligned
  2021-03-16 15:45 [PATCH] MIPS: vmlinux.lds.S: Fix appended dtb not properly aligned Paul Cercueil
  2021-03-16 17:02 ` Bjørn Mork
@ 2021-03-16 21:59 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2021-03-16 21:59 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: od, linux-mips, linux-kernel, Bjørn Mork

On Tue, Mar 16, 2021 at 03:45:15PM +0000, Paul Cercueil wrote:
> Commit 6654111c893f ("MIPS: vmlinux.lds.S: align raw appended dtb to 8
> bytes") changed the alignment from STRUCT_ALIGNMENT bytes to 8 bytes.
> 
> The commit's message makes it sound like it was actually done on
> purpose, but this is not the case. The commit was written when raw
> appended dtb were not aligned at all. The STRUCT_ALIGN() was added a few
> days before, in commit 7a05293af39f ("MIPS: boot/compressed: Copy DTB to
> aligned address"). The true purpose of the commit was not to align
> specifically to 8 bytes, but to make sure that the generated vmlinux'
> size was properly padded to the alignment required for DTBs.
> 
> While the switch to 8-byte alignment worked for vmlinux-appended dtb
> blobs, it broke vmlinuz-appended dtb blobs, as the decompress routine
> moves the blob to a STRUCT_ALIGNMENT aligned address.
> 
> Fix this by changing the raw appended dtb blob alignment from 8 bytes
> back to STRUCT_ALIGNMENT bytes in vmlinux.lds.S.
> 
> Fixes: 6654111c893f ("MIPS: vmlinux.lds.S: align raw appended dtb to 8 bytes")
> Cc: Bjørn Mork <bjorn@mork.no>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  arch/mips/kernel/vmlinux.lds.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

applied to mips-fixes.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-16 22:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 15:45 [PATCH] MIPS: vmlinux.lds.S: Fix appended dtb not properly aligned Paul Cercueil
2021-03-16 17:02 ` Bjørn Mork
2021-03-16 21:59 ` Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).