linux-stable/arch/x86
Andy Lutomirski cdeb604894 x86/asm/irq: Stop relying on magic JMP behavior for early_idt_handlers
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>
2015-05-24 08:35:03 +02:00
..
boot * Avoid garbage names in efivarfs due to buggy firmware by zero'ing 2015-05-06 08:30:24 +02:00
configs x86/build/defconfig: Enable USB_EHCI_TT_NEWSCHED=y 2015-02-19 02:21:14 +01:00
crypto crypto: x86/sha512_ssse3 - fixup for asm function prototype change 2015-04-24 20:09:01 +08:00
ia32 x86/entry: Define 'cpu_current_top_of_stack' for 64-bit code 2015-05-08 13:50:02 +02:00
include x86/asm/irq: Stop relying on magic JMP behavior for early_idt_handlers 2015-05-24 08:35:03 +02:00
kernel x86/asm/irq: Stop relying on magic JMP behavior for early_idt_handlers 2015-05-24 08:35:03 +02:00
kvm kvm: x86: fix kvmclock update protocol 2015-04-27 15:48:59 +02:00
lguest x86/asm/entry: Remove SYSCALL_VECTOR 2015-05-10 12:34:28 +02:00
lib x86/asm/uaccess: Get rid of copy_user_nocache_64.S 2015-05-14 07:25:35 +02:00
math-emu
mm Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-05-06 10:57:37 -07:00
net x86: bpf_jit: fix FROM_BE16 and FROM_LE16/32 instructions 2015-05-12 23:13:08 -04:00
oprofile x86/asm/entry: Change all 'user_mode_vm()' calls to 'user_mode()' 2015-03-23 11:14:17 +01:00
pci x86/PCI/ACPI: Make all resources except [io 0xcf8-0xcff] available on PCI bus 2015-04-30 22:17:34 +02:00
platform TTY/Serial patches for 4.1-rc1 2015-04-21 09:33:10 -07:00
power x86/asm, x86/power/hibernate: Use local labels in asm 2015-04-15 11:37:51 +02:00
purgatory Merge branches 'x86-build-for-linus', 'x86-cleanups-for-linus' and 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2014-12-10 12:35:46 -08:00
realmode Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-02-16 14:58:12 -08:00
syscalls xen: features and fixes for 4.1-rc0 2015-04-16 14:01:03 -05:00
tools x86, build: replace Perl script with Shell script 2015-01-26 13:37:18 -08:00
um Merge branch 'exec_domain_rip_v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc 2015-04-15 13:53:55 -07:00
vdso x86/vdso: Fix 'make bzImage' on older distros 2015-05-11 10:25:02 +02:00
video
xen x86/entry: Define 'cpu_current_top_of_stack' for 64-bit code 2015-05-08 13:50:02 +02:00
.gitignore
Kbuild
Kconfig Initial ACPI support for arm64: 2015-04-24 08:23:45 -07:00
Kconfig.cpu
Kconfig.debug x86, intel-mid: remove Intel MID specific serial support 2015-03-07 03:25:18 +01:00
Makefile x86: Pack loops tightly as well 2015-05-17 07:56:54 +02:00
Makefile.um kbuild: use relative path more to include Makefile 2015-04-02 16:42:08 +02:00
Makefile_32.cpu