Module Name: src
Committed By: maxv
Date: Sun Feb 25 11:57:44 UTC 2018
Modified Files:
src/sys/arch/amd64/amd64: amd64_trap.S
Log Message:
Ah. Don't use NENTRY() to declare check_swapgs, use LABEL() instead. NENTRY
puts the code in the .text section, so the effect of TEXT_USER_BEGIN was
overwritten, and check_swapgs was not put in the .text.user section.
As a result kernels running SVS would crash when jumping here - because we
execute this place with the user page table loaded, and in this page table
only .text.user is mapped.
While here, rename check_swapgs -> kernuser_reenter, because we do more
things than just SWAPGS.
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/amd64/amd64/amd64_trap.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/amd64_trap.S
diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.35 src/sys/arch/amd64/amd64/amd64_trap.S:1.36
--- src/sys/arch/amd64/amd64/amd64_trap.S:1.35 Sun Feb 25 08:28:55 2018
+++ src/sys/arch/amd64/amd64/amd64_trap.S Sun Feb 25 11:57:44 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: amd64_trap.S,v 1.35 2018/02/25 08:28:55 maxv Exp $ */
+/* $NetBSD: amd64_trap.S,v 1.36 2018/02/25 11:57:44 maxv Exp $ */
/*
* Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc.
@@ -273,22 +273,22 @@ IDTVEC_END(trap10)
* equivalent of iret, if it does this code would be needed
* in order to copy the user segment registers into the fault frame.
*/
-#define check_swapgs alltraps
+#define kernuser_reenter alltraps
#endif
IDTVEC(trap11) /* #NP() Segment not present */
TRAP_NJ(T_SEGNPFLT)
- jmp check_swapgs
+ jmp kernuser_reenter
IDTVEC_END(trap11)
IDTVEC(trap12) /* #SS() Stack exception */
TRAP_NJ(T_STKFLT)
- jmp check_swapgs
+ jmp kernuser_reenter
IDTVEC_END(trap12)
IDTVEC(trap13) /* #GP() General protection */
TRAP_NJ(T_PROTFLT)
- jmp check_swapgs
+ jmp kernuser_reenter
IDTVEC_END(trap13)
IDTVEC(trap14)
@@ -365,7 +365,7 @@ IDTVEC(intrspurious)
jmp .Lalltraps_checkusr
IDTVEC_END(intrspurious)
-#ifndef check_swapgs
+#ifndef kernuser_reenter
/*
* We need to worry about traps in kernel mode while the kernel %gs isn't
* loaded. These are either faults on iretq during return to user or loads to
@@ -374,7 +374,8 @@ IDTVEC_END(intrspurious)
* When such traps happen, we have CPL=0 and %gs=userland, and we must perform
* an additional swapgs to get %gs=kernel.
*/
-NENTRY(check_swapgs)
+ _ALIGN_TEXT
+LABEL(kernuser_reenter)
INTRENTRY_L(3f,1:)
2:
sti
@@ -406,7 +407,7 @@ NENTRY(check_swapgs)
/* None of the above cases */
jmp 2b /* normal kernel fault */
-END(check_swapgs)
+END(kernuser_reenter)
#endif
TEXT_USER_END