From: Linus Torvalds Date: Mon, 4 Aug 2014 23:56:16 +0000 (-0700) Subject: Merge branches 'x86-build-for-linus', 'x86-cleanups-for-linus' and 'x86-debug-for... X-Git-Tag: MMI-PSA29.97-13-9~11808 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=19d402c1e75077e2bcfe17f7fe5bcfc8deb74991;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git Merge branches 'x86-build-for-linus', 'x86-cleanups-for-linus' and 'x86-debug-for-linus' of git://git./linux/kernel/git/tip/tip Pull x86 build/cleanup/debug updates from Ingo Molnar: "Robustify the build process with a quirk to avoid GCC reordering related bugs. Two code cleanups. Simplify entry_64.S CFI annotations, by Jan Beulich" * 'x86-build-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86, build: Change code16gcc.h from a C header to an assembly header * 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86: Simplify __HAVE_ARCH_CMPXCHG tests x86/tsc: Get rid of custom DIV_ROUND() macro * 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/debug: Drop several unnecessary CFI annotations --- 19d402c1e75077e2bcfe17f7fe5bcfc8deb74991 diff --cc arch/x86/kernel/entry_64.S index c844f0816ab8,1e96c3628bf2,b25ca969edd2,f72c03a1ac54..2fac1343a90b --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@@@@ -830,46 -1040,13 -830,49 -829,49 +829,46 @@@@@ restore_args RESTORE_ARGS 1,8,1 irq_return: ++ INTERRUPT_RETURN - _ASM_EXTABLE(irq_return, bad_iret) ++ - #ifdef CONFIG_PARAVIRT ++ENTRY(native_iret) + /* + * Are we returning to a stack segment from the LDT? Note: in + * 64-bit mode SS:RSP on the exception stack is always valid. + */ + #ifdef CONFIG_X86_ESPFIX64 + testb $4,(SS-RIP)(%rsp) -- jnz irq_return_ldt +++ jnz native_irq_return_ldt + #endif + --irq_return_iret: -- INTERRUPT_RETURN -- _ASM_EXTABLE(irq_return_iret, bad_iret) -- --#ifdef CONFIG_PARAVIRT --ENTRY(native_iret) +++native_irq_return_iret: iretq --- _ASM_EXTABLE(native_iret, bad_iret) --#endif +++ _ASM_EXTABLE(native_irq_return_iret, bad_iret) + + #ifdef CONFIG_X86_ESPFIX64 --irq_return_ldt: +++native_irq_return_ldt: + pushq_cfi %rax + pushq_cfi %rdi + SWAPGS + movq PER_CPU_VAR(espfix_waddr),%rdi + movq %rax,(0*8)(%rdi) /* RAX */ + movq (2*8)(%rsp),%rax /* RIP */ + movq %rax,(1*8)(%rdi) + movq (3*8)(%rsp),%rax /* CS */ + movq %rax,(2*8)(%rdi) + movq (4*8)(%rsp),%rax /* RFLAGS */ + movq %rax,(3*8)(%rdi) + movq (6*8)(%rsp),%rax /* SS */ + movq %rax,(5*8)(%rdi) + movq (5*8)(%rsp),%rax /* RSP */ + movq %rax,(4*8)(%rdi) + andl $0xffff0000,%eax + popq_cfi %rdi + orq PER_CPU_VAR(espfix_stack),%rax + SWAPGS + movq %rax,%rsp + popq_cfi %rax -- jmp irq_return_iret +++ jmp native_irq_return_iret #endif .section .fixup,"ax" @@@@@ -933,39 -1110,13 -936,44 -935,44 +932,39 @@@@@ ENTRY(retint_kernel call preempt_schedule_irq jmp exit_intr #endif - CFI_ENDPROC END(common_interrupt) - /* - * End of kprobes section - */ - .popsection + + /* + * If IRET takes a fault on the espfix stack, then we + * end up promoting it to a doublefault. In that case, + * modify the stack to make it look like we just entered + * the #GP handler from user space, similar to bad_iret. + */ + #ifdef CONFIG_X86_ESPFIX64 + ALIGN + __do_double_fault: + XCPT_FRAME 1 RDI+8 + movq RSP(%rdi),%rax /* Trap on the espfix stack? */ + sarq $PGDIR_SHIFT,%rax + cmpl $ESPFIX_PGD_ENTRY,%eax + jne do_double_fault /* No, just deliver the fault */ + cmpl $__KERNEL_CS,CS(%rdi) + jne do_double_fault + movq RIP(%rdi),%rax -- cmpq $irq_return_iret,%rax --#ifdef CONFIG_PARAVIRT -- je 1f -- cmpq $native_iret,%rax --#endif +++ cmpq $native_irq_return_iret,%rax + jne do_double_fault /* This shouldn't happen... */ --1: + movq PER_CPU_VAR(kernel_stack),%rax + subq $(6*8-KERNEL_STACK_OFFSET),%rax /* Reset to original stack */ + movq %rax,RSP(%rdi) + movq $0,(%rax) /* Missing (lost) #GP error code */ + movq $general_protection,RIP(%rdi) + retq + CFI_ENDPROC + END(__do_double_fault) + #else + # define __do_double_fault do_double_fault + #endif /* * APIC interrupts. @@@@@ -1419,8 -1600,8 -1427,8 -1426,9 +1418,9 @@@@@ error_sti * compat mode. Check for these here too. */ error_kernelspace: +++ CFI_REL_OFFSET rcx, RCX+8 incl %ebx - leaq irq_return(%rip),%rcx -- leaq irq_return_iret(%rip),%rcx +++ leaq native_irq_return_iret(%rip),%rcx cmpq %rcx,RIP+8(%rsp) je error_swapgs movl %ecx,%eax /* zero extend */