Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e872045b authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Ingo Molnar
Browse files

x86/entry/64: Simplify reg restore code in the standard IRET paths



The old code restored all the registers with movq instead of pop.

In theory, this was done because some CPUs have higher movq
throughput, but any gain there would be tiny and is almost certainly
outweighed by the higher text size.

This saves 96 bytes of text.

Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.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/ad82520a207ccd851b04ba613f4f752b33ac05f7.1509609304.git.luto@kernel.org


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 8a055d7f
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -151,6 +151,27 @@ For 32-bit we have the following conventions - kernel is built with
	UNWIND_HINT_REGS offset=\offset extra=0
	UNWIND_HINT_REGS offset=\offset extra=0
	.endm
	.endm


	.macro POP_EXTRA_REGS
	popq %r15
	popq %r14
	popq %r13
	popq %r12
	popq %rbp
	popq %rbx
	.endm

	.macro POP_C_REGS
	popq %r11
	popq %r10
	popq %r9
	popq %r8
	popq %rax
	popq %rcx
	popq %rdx
	popq %rsi
	popq %rdi
	.endm

	.macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1
	.macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1
	.if \rstor_r11
	.if \rstor_r11
	movq 6*8(%rsp), %r11
	movq 6*8(%rsp), %r11
+6 −6
Original line number Original line Diff line number Diff line
@@ -618,9 +618,9 @@ GLOBAL(swapgs_restore_regs_and_return_to_usermode)
1:
1:
#endif
#endif
	SWAPGS
	SWAPGS
	RESTORE_EXTRA_REGS
	POP_EXTRA_REGS
	RESTORE_C_REGS
	POP_C_REGS
	REMOVE_PT_GPREGS_FROM_STACK 8
	addq	$8, %rsp	/* skip regs->orig_ax */
	INTERRUPT_RETURN
	INTERRUPT_RETURN




@@ -650,9 +650,9 @@ GLOBAL(restore_regs_and_return_to_kernel)
	ud2
	ud2
1:
1:
#endif
#endif
	RESTORE_EXTRA_REGS
	POP_EXTRA_REGS
	RESTORE_C_REGS
	POP_C_REGS
	REMOVE_PT_GPREGS_FROM_STACK 8
	addq	$8, %rsp	/* skip regs->orig_ax */
	INTERRUPT_RETURN
	INTERRUPT_RETURN


ENTRY(native_iret)
ENTRY(native_iret)