Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: paulmck@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/60e90901eee611e59e958bfdbbe39969b4f88fe5.1435952415.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
02bc7768 a586f98e

+23 -46
+18 -46
arch/x86/entry/entry_64.S
··· 508 508 509 509 testb $3, CS(%rsp) 510 510 jz 1f 511 + 512 + /* 513 + * IRQ from user mode. Switch to kernel gsbase and inform context 514 + * tracking that we're in kernel mode. 515 + */ 511 516 SWAPGS 517 + #ifdef CONFIG_CONTEXT_TRACKING 518 + call enter_from_user_mode 519 + #endif 520 + 512 521 1: 513 522 /* 514 523 * Save previous stack pointer, optionally switch to interrupt stack. ··· 556 547 557 548 testb $3, CS(%rsp) 558 549 jz retint_kernel 550 + 559 551 /* Interrupt came from user space */ 560 - GLOBAL(retint_user) 561 - GET_THREAD_INFO(%rcx) 562 - 563 - /* %rcx: thread info. Interrupts are off. */ 564 - retint_with_reschedule: 565 - movl $_TIF_WORK_MASK, %edi 566 - retint_check: 567 552 LOCKDEP_SYS_EXIT_IRQ 568 - movl TI_flags(%rcx), %edx 569 - andl %edi, %edx 570 - jnz retint_careful 571 - 572 - retint_swapgs: /* return to user-space */ 573 - /* 574 - * The iretq could re-enable interrupts: 575 - */ 576 - DISABLE_INTERRUPTS(CLBR_ANY) 553 + GLOBAL(retint_user) 554 + mov %rsp,%rdi 555 + call prepare_exit_to_usermode 577 556 TRACE_IRQS_IRETQ 578 - 579 557 SWAPGS 580 558 jmp restore_regs_and_iret 581 559 ··· 640 644 popq %rax 641 645 jmp native_irq_return_iret 642 646 #endif 643 - 644 - /* edi: workmask, edx: work */ 645 - retint_careful: 646 - bt $TIF_NEED_RESCHED, %edx 647 - jnc retint_signal 648 - TRACE_IRQS_ON 649 - ENABLE_INTERRUPTS(CLBR_NONE) 650 - pushq %rdi 651 - SCHEDULE_USER 652 - popq %rdi 653 - GET_THREAD_INFO(%rcx) 654 - DISABLE_INTERRUPTS(CLBR_NONE) 655 - TRACE_IRQS_OFF 656 - jmp retint_check 657 - 658 - retint_signal: 659 - testl $_TIF_DO_NOTIFY_MASK, %edx 660 - jz retint_swapgs 661 - TRACE_IRQS_ON 662 - ENABLE_INTERRUPTS(CLBR_NONE) 663 - movq $-1, ORIG_RAX(%rsp) 664 - xorl %esi, %esi /* oldset */ 665 - movq %rsp, %rdi /* &pt_regs */ 666 - call do_notify_resume 667 - DISABLE_INTERRUPTS(CLBR_NONE) 668 - TRACE_IRQS_OFF 669 - GET_THREAD_INFO(%rcx) 670 - jmp retint_with_reschedule 671 - 672 647 END(common_interrupt) 673 648 674 649 /* ··· 1055 1088 SWAPGS 1056 1089 1057 1090 .Lerror_entry_from_usermode_after_swapgs: 1091 + #ifdef CONFIG_CONTEXT_TRACKING 1092 + call enter_from_user_mode 1093 + #endif 1094 + 1058 1095 .Lerror_entry_done: 1096 + 1059 1097 TRACE_IRQS_OFF 1060 1098 ret 1061 1099
+5
arch/x86/entry/entry_64_compat.S
··· 458 458 DISABLE_INTERRUPTS(CLBR_NONE) 459 459 TRACE_IRQS_OFF 460 460 461 + /* Now finish entering normal kernel mode. */ 462 + #ifdef CONFIG_CONTEXT_TRACKING 463 + call enter_from_user_mode 464 + #endif 465 + 461 466 /* And exit again. */ 462 467 jmp retint_user 463 468