lkml.org 
[lkml]   [2017]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 07/18] x86/asm/64: Merge the fast and slow SYSRET paths
On Fri, Oct 27, 2017 at 1:11 PM, Borislav Petkov <bp@suse.de> wrote:
> On Thu, Oct 26, 2017 at 01:26:39AM -0700, Andy Lutomirski wrote:
>> They did almost the same thing. Remove a bunch of pointless
>> instructions (mostly hidden in macros) and reduce cognitive load by
>> merging them.
>>
>> Signed-off-by: Andy Lutomirski <luto@kernel.org>
>> ---
>> arch/x86/entry/entry_64.S | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
>> index 9dafafa3e0ec..c855ee91a3a5 100644
>> --- a/arch/x86/entry/entry_64.S
>> +++ b/arch/x86/entry/entry_64.S
>> @@ -220,10 +220,9 @@ entry_SYSCALL_64_fastpath:
>> TRACE_IRQS_ON /* user mode is traced as IRQs on */
>> movq RIP(%rsp), %rcx
>> movq EFLAGS(%rsp), %r11
>> - RESTORE_C_REGS_EXCEPT_RCX_R11
>> - movq RSP(%rsp), %rsp
>> + addq $6*8, %rsp /* skip extra regs -- they were preserved */
>> UNWIND_HINT_EMPTY
>> - USERGS_SYSRET64
>> + jmp .Lpop_c_regs_except_rcx_r11_and_sysret
>>
>> 1:
>> /*
>> @@ -315,6 +314,7 @@ syscall_return_via_sysret:
>> /* rcx and r11 are already restored (see code above) */
>> UNWIND_HINT_EMPTY
>> POP_EXTRA_REGS
>> +.Lpop_c_regs_except_rcx_r11_and_sysret:
>
> .Lpop_regs_sysret I guess.
>

I'm inclined to leave it. I first wrote it without the long name and
then I had to re-read the code to make sure I got the register state
right. The long name serves as documentation that we need rcx and r11
to have special contents. There's only one place that jumps there and
it's in the same function.

\
 
 \ /
  Last update: 2017-11-01 12:29    [W:1.120 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site