Re: [PATCH] x86/alternatives: Fix optimize_nops() checking

From: Linus Torvalds
Date: Wed Jan 10 2018 - 15:20:51 EST


On Wed, Jan 10, 2018 at 12:05 PM, Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> I did this:
>
> alternative("", "xor %%rdi, %%rdi; .byte 0xe9; .long 2f; 2: jmp startup_64", X86_FEATURE_K8);

No, that's not valid. That could never work anyway. The ".long 2f"
would be the absolute address in the alternative section, but opcode
E9 takes a relative 32-bit offset.

So the error you get isn't because relocations wouldn't work in
alternatives, it's because you tried to fit an absolute 64-biy value
in a 32-bit relocation, and it was wrong _regardless_ of which section
you were in.

Linus