From: Ingo Molnar Date: Wed, 8 Apr 2015 07:01:54 +0000 (+0200) Subject: Merge tag 'v4.0-rc7' into x86/asm, to resolve conflicts X-Git-Tag: v4.9.8~4513^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4bcc7827b02feea2c762fa6d46a1bffb300d7403;p=platform%2Fkernel%2Flinux-rpi3.git Merge tag 'v4.0-rc7' into x86/asm, to resolve conflicts Conflicts: arch/x86/kernel/entry_64.S Signed-off-by: Ingo Molnar --- 4bcc7827b02feea2c762fa6d46a1bffb300d7403 diff --cc arch/x86/kernel/entry_64.S index f4270ff,f0095a7..65485b3 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@@ -699,14 -792,28 +699,28 @@@ retint_swapgs: /* return to user-spac shr $__VIRTUAL_MASK_SHIFT, %rcx jnz opportunistic_sysret_failed - cmpq $__USER_CS,(CS-R11)(%rsp) /* CS must match SYSRET */ + cmpq $__USER_CS,CS(%rsp) /* CS must match SYSRET */ jne opportunistic_sysret_failed - movq (R11-ARGOFFSET)(%rsp), %r11 - cmpq %r11,(EFLAGS-ARGOFFSET)(%rsp) /* R11 == RFLAGS */ + movq R11(%rsp),%r11 + cmpq %r11,EFLAGS(%rsp) /* R11 == RFLAGS */ jne opportunistic_sysret_failed - testq $X86_EFLAGS_RF,%r11 /* sysret can't restore RF */ + /* + * SYSRET can't restore RF. SYSRET can restore TF, but unlike IRET, + * restoring TF results in a trap from userspace immediately after + * SYSRET. This would cause an infinite loop whenever #DB happens + * with register state that satisfies the opportunistic SYSRET + * conditions. For example, single-stepping this user code: + * + * movq $stuck_here,%rcx + * pushfq + * popq %r11 + * stuck_here: + * + * would never get past 'stuck_here'. + */ + testq $(X86_EFLAGS_RF|X86_EFLAGS_TF), %r11 jnz opportunistic_sysret_failed /* nothing to check for RSP */