Skip to content

Commit 2fa5f04

Browse files
Wanpeng LiIngo Molnar
authored andcommitted
x86/entry/64: Fix context tracking state warning when load_gs_index fails
This warning: WARNING: CPU: 0 PID: 3331 at arch/x86/entry/common.c:45 enter_from_user_mode+0x32/0x50 CPU: 0 PID: 3331 Comm: ldt_gdt_64 Not tainted 4.8.0-rc7+ #13 Call Trace: dump_stack+0x99/0xd0 __warn+0xd1/0xf0 warn_slowpath_null+0x1d/0x20 enter_from_user_mode+0x32/0x50 error_entry+0x6d/0xc0 ? general_protection+0x12/0x30 ? native_load_gs_index+0xd/0x20 ? do_set_thread_area+0x19c/0x1f0 SyS_set_thread_area+0x24/0x30 do_int80_syscall_32+0x7c/0x220 entry_INT80_compat+0x38/0x50 ... can be reproduced by running the GS testcase of the ldt_gdt test unit in the x86 selftests. do_int80_syscall_32() will call enter_form_user_mode() to convert context tracking state from user state to kernel state. The load_gs_index() call can fail with user gsbase, gsbase will be fixed up and proceed if this happen. However, enter_from_user_mode() will be called again in the fixed up path though it is context tracking kernel state currently. This patch fixes it by just fixing up gsbase and telling lockdep that IRQs are off once load_gs_index() failed with user gsbase. Signed-off-by: Wanpeng Li <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 05fb3c1 commit 2fa5f04

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/entry/entry_64.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,6 @@ ENTRY(error_entry)
10021002
testb $3, CS+8(%rsp)
10031003
jz .Lerror_kernelspace
10041004

1005-
.Lerror_entry_from_usermode_swapgs:
10061005
/*
10071006
* We entered from user mode or we're pretending to have entered
10081007
* from user mode due to an IRET fault.
@@ -1045,7 +1044,8 @@ ENTRY(error_entry)
10451044
* gsbase and proceed. We'll fix up the exception and land in
10461045
* .Lgs_change's error handler with kernel gsbase.
10471046
*/
1048-
jmp .Lerror_entry_from_usermode_swapgs
1047+
SWAPGS
1048+
jmp .Lerror_entry_done
10491049

10501050
.Lbstep_iret:
10511051
/* Fix truncated RIP */

0 commit comments

Comments
 (0)