linux/arch/x86
Andy Lutomirski 510458cb7d x86/asm/irq: Stop relying on magic JMP behavior for early_idt_handlers
commit 425be5679f upstream.

The early_idt_handlers asm code generates an array of entry
points spaced nine bytes apart.  It's not really clear from that
code or from the places that reference it what's going on, and
the code only works in the first place because GAS never
generates two-byte JMP instructions when jumping to global
labels.

Clean up the code to generate the correct array stride (member size)
explicitly. This should be considerably more robust against
screw-ups, as GAS will warn if a .fill directive has a negative
count.  Using '. =' to advance would have been even more robust
(it would generate an actual error if it tried to move
backwards), but it would pad with nulls, confusing anyone who
tries to disassemble the code.  The new scheme should be much
clearer to future readers.

While we're at it, improve the comments and rename the array and
common code.

Binutils may start relaxing jumps to non-weak labels.  If so,
this change will fix our build, and we may need to backport this
change.

Before, on x86_64:

  0000000000000000 <early_idt_handlers>:
     0:   6a 00                   pushq  $0x0
     2:   6a 00                   pushq  $0x0
     4:   e9 00 00 00 00          jmpq   9 <early_idt_handlers+0x9>
                          5: R_X86_64_PC32        early_idt_handler-0x4
  ...
    48:   66 90                   xchg   %ax,%ax
    4a:   6a 08                   pushq  $0x8
    4c:   e9 00 00 00 00          jmpq   51 <early_idt_handlers+0x51>
                          4d: R_X86_64_PC32       early_idt_handler-0x4
  ...
   117:   6a 00                   pushq  $0x0
   119:   6a 1f                   pushq  $0x1f
   11b:   e9 00 00 00 00          jmpq   120 <early_idt_handler>
                          11c: R_X86_64_PC32      early_idt_handler-0x4

After:

  0000000000000000 <early_idt_handler_array>:
     0:   6a 00                   pushq  $0x0
     2:   6a 00                   pushq  $0x0
     4:   e9 14 01 00 00          jmpq   11d <early_idt_handler_common>
  ...
    48:   6a 08                   pushq  $0x8
    4a:   e9 d1 00 00 00          jmpq   120 <early_idt_handler_common>
    4f:   cc                      int3
    50:   cc                      int3
  ...
   117:   6a 00                   pushq  $0x0
   119:   6a 1f                   pushq  $0x1f
   11b:   eb 03                   jmp    120 <early_idt_handler_common>
   11d:   cc                      int3
   11e:   cc                      int3
   11f:   cc                      int3

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Binutils <binutils@sourceware.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H.J. Lu <hjl.tools@gmail.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/ac027962af343b0c599cbfcf50b945ad2ef3d7a8.1432336324.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-22 17:01:21 -07:00
..
boot x86, build: replace Perl script with Shell script 2015-02-05 22:35:48 -08:00
configs
crypto crypto: aesni - fix memory usage in GCM decryption 2015-03-26 15:06:57 +01:00
ia32 x86_64, entry: Fix out of bounds read on sysenter 2014-11-14 08:59:47 -08:00
include x86/asm/irq: Stop relying on magic JMP behavior for early_idt_handlers 2015-06-22 17:01:21 -07:00
kernel x86/asm/irq: Stop relying on magic JMP behavior for early_idt_handlers 2015-06-22 17:01:21 -07:00
kvm KVM: MMU: fix CR4.SMEP=1, CR0.WP=0 with shadow pages 2015-06-06 08:19:31 -07:00
lguest x86, asmlinkage, lguest: Fix C functions used by inline assembler 2014-01-29 22:17:17 -08:00
lib x86, hash: Fix build failure with older binutils 2014-05-06 07:59:26 -07:00
math-emu x86: math-emu: Drop already-disabled print of build date 2014-01-27 23:14:12 +01:00
mm x86: mm: move mmap_sem unlock from mm_fault_error() to caller 2015-04-29 10:31:56 +02:00
net x86: bpf_jit: fix compilation of large bpf programs 2015-06-22 17:01:16 -07:00
oprofile
pci PCI: Add NEC variants to Stratus ftServer PCIe DMI check 2015-02-11 14:54:46 +08:00
platform x86/efi: Make efi virtual runtime map passing more robust 2014-04-14 06:50:02 -07:00
power nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:59:21 +02:00
realmode Merge commit 'f4bcd8ccddb02833340652e9f46f5127828eb79d' into x86/build 2014-01-29 09:07:00 -08:00
syscalls x86, x32: Use compat shims for io_{setup,submit} 2014-06-30 20:12:00 -07:00
tools x86, build: replace Perl script with Shell script 2015-02-05 22:35:48 -08:00
um x86, um: actually mark system call tables readonly 2015-01-27 08:18:58 -08:00
vdso x86/vdso: Fix the build on GCC5 2015-03-26 15:06:58 +01:00
video
xen x86/xen: don't copy bogus duplicate entries into kernel page tables 2014-10-05 14:52:17 -07:00
.gitignore
Kbuild
Kconfig x86/apic: Re-enable PCI_MSI support for non-SMP X86_32 2015-01-29 17:40:50 -08:00
Kconfig.cpu x86: Remove CONFIG_X86_OOSTORE 2014-03-11 10:16:18 -07:00
Kconfig.debug x86: Disable CONFIG_X86_DECODER_SELFTEST in allmod/allyesconfigs 2014-02-05 14:10:30 -08:00
Makefile x86-64, build: Fix stack protector Makefile breakage with 32-bit userland 2014-05-13 13:32:58 +02:00
Makefile.um
Makefile_32.cpu