Re: 3.1-rc6 boot problem reason searching

From: Andrew Lutomirski
Date: Thu Sep 15 2011 - 15:04:20 EST


On Thu, Sep 15, 2011 at 11:23 AM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, Sep 15, 2011 at 11:15 AM, Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> It *used* to have an alignment of 8 back before your patch to make the
>> pointers be relative due to the 64-bit pointers. But now all fields
>> are 32-bit, and it could easily have a size of just 12 bytes, getting
>> rid of the 'pad2' field, and getting rid of the '.balign 8's.
>
> IOW, maybe the correct patch is just the attached one.
>
> Werner, does this fix the boot for you? It gets rid of all the bogus
> alignment stuff, it's all wrong anyway, the altinstructions section
> entries are all 12 bytes long so it starts out sufficiently aligned,
> and it *stays* aligned because if anybody ever adds a non-12-byte
> entry that would be a huge bug regardless. So any extra alignment is
> just likely to be buggy and hide much bigger issues.
>
> This is COMPLETELY UNTESTED, just looking at the source.

If you want to apply it this late, fine with me. It looks generally
sane, but I haven't tested it.

OTOH, I have tested the attached minimal patch on 32-bit and 64-bit.

--Andy
commit b564a6aadb74d727c69ec47a40dcc81f17699214
Author: Andy Lutomirski <luto@xxxxxxx>
Date: Thu Sep 15 10:52:05 2011 -0700

x86: Fix altinstruction_entry alignment on 32-bit builds

The alignment should be 4 on 32 bit builds and 8 on 64-bit builds.
This fixes a failure to boot on some configurations.

Signed-off-by: Andy Lutomirski <luto@xxxxxxx>

diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
index 4554cc6..d00dc2a 100644
--- a/arch/x86/include/asm/alternative-asm.h
+++ b/arch/x86/include/asm/alternative-asm.h
@@ -16,7 +16,7 @@
#endif

.macro altinstruction_entry orig alt feature orig_len alt_len
- .align 8
+ _ASM_ALIGN
.long \orig - .
.long \alt - .
.word \feature