Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147698312
D50414.1784109199.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D50414.1784109199.diff
View Options
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -91,14 +91,8 @@
jnz 2f
testb $CPUID_STDEXT_FSGSBASE,cpu_stdext_feature(%rip)
jz 2f
- movl %fs,%eax
- cmpl $KUF32SEL,%eax
- jne 1f
rdfsbase %rax
movq %rax,PCB_FSBASE(%r8)
-1: movl %gs,%eax
- cmpl $KUG32SEL,%eax
- jne 2f
movq %rdx,%r12
movl $MSR_KGSBASE,%ecx /* Read user gs base */
rdmsr
diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S
--- a/sys/amd64/amd64/exception.S
+++ b/sys/amd64/amd64/exception.S
@@ -479,22 +479,14 @@
jz 6f /* already running with kernel GS.base */
testb $CPUID_STDEXT_FSGSBASE,cpu_stdext_feature(%rip)
jz 2f
- cmpw $KUF32SEL,TF_FS(%rsp)
- jne 1f
rdfsbase %rax
-1: cmpw $KUG32SEL,TF_GS(%rsp)
- jne 2f
rdgsbase %rdx
2: swapgs
lfence
movq PCPU(CURPCB),%rdi
testb $CPUID_STDEXT_FSGSBASE,cpu_stdext_feature(%rip)
jz 4f
- cmpw $KUF32SEL,TF_FS(%rsp)
- jne 3f
movq %rax,PCB_FSBASE(%rdi)
-3: cmpw $KUG32SEL,TF_GS(%rsp)
- jne 4f
movq %rdx,PCB_GSBASE(%rdi)
orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* full iret from user #gp */
4: call handle_ibrs_entry
@@ -730,12 +722,8 @@
orl $PCB_FULL_IRET,PCB_FLAGS(%rdi)
testb $CPUID_STDEXT_FSGSBASE,cpu_stdext_feature(%rip)
jz 3f
- cmpw $KUF32SEL,TF_FS(%rsp)
- jne 2f
rdfsbase %rax
movq %rax,PCB_FSBASE(%rdi)
-2: cmpw $KUG32SEL,TF_GS(%rsp)
- jne 3f
movl $MSR_KGSBASE,%ecx
rdmsr
shlq $32,%rdx
@@ -842,12 +830,8 @@
orl $PCB_FULL_IRET,PCB_FLAGS(%rdi)
testb $CPUID_STDEXT_FSGSBASE,cpu_stdext_feature(%rip)
jz 3f
- cmpw $KUF32SEL,TF_FS(%rsp)
- jne 2f
rdfsbase %rax
movq %rax,PCB_FSBASE(%rdi)
-2: cmpw $KUG32SEL,TF_GS(%rsp)
- jne 3f
movl $MSR_KGSBASE,%ecx
rdmsr
shlq $32,%rdx
@@ -1177,15 +1161,12 @@
.globl ld_fs
ld_fs:
movw %ax,%fs
- cmpw $KUF32SEL,%ax
- jne 1f
movl $MSR_FSBASE,%ecx
movl PCB_FSBASE(%r8),%eax
movl PCB_FSBASE+4(%r8),%edx
.globl ld_fsbase
ld_fsbase:
wrmsr
-1:
/* Restore %gs and gsbase */
movw TF_GS(%rsp),%si
pushfq
@@ -1198,10 +1179,6 @@
.globl ld_gs
ld_gs:
movw %si,%gs
- /* Save user %gs base into %r14d:%r15d */
- rdmsr
- movl %eax,%r14d
- movl %edx,%r15d
/* Restore kernel %gs base */
movl %r12d,%eax
movl %r13d,%edx
@@ -1212,14 +1189,8 @@
* from the previously saved msr read.
*/
movl $MSR_KGSBASE,%ecx
- cmpw $KUG32SEL,%si
- jne 1f
movl PCB_GSBASE(%r8),%eax
movl PCB_GSBASE+4(%r8),%edx
- jmp ld_gsbase
-1:
- movl %r14d,%eax
- movl %r15d,%edx
.globl ld_gsbase
ld_gsbase:
wrmsr /* May trap if non-canonical, but only for TLS. */
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1789,10 +1789,8 @@
(pcb->pcb_flags & PCB_FULL_IRET) == 0) {
r = intr_disable();
if ((pcb->pcb_flags & PCB_FULL_IRET) == 0) {
- if (rfs() == _ufssel)
- pcb->pcb_fsbase = rdfsbase();
- if (rgs() == _ugssel)
- pcb->pcb_gsbase = rdmsr(MSR_KGSBASE);
+ pcb->pcb_fsbase = rdfsbase();
+ pcb->pcb_gsbase = rdmsr(MSR_KGSBASE);
}
set_pcb_flags_raw(pcb, flags);
intr_restore(r);
diff --git a/sys/amd64/ia32/ia32_exception.S b/sys/amd64/ia32/ia32_exception.S
--- a/sys/amd64/ia32/ia32_exception.S
+++ b/sys/amd64/ia32/ia32_exception.S
@@ -54,10 +54,10 @@
movq %rax,TF_RAX(%rsp)
movq %rdx,TF_RDX(%rsp)
movq %rcx,TF_RCX(%rsp)
+ movq %r15,TF_R15(%rsp)
call handle_ibrs_entry
sti
movq %rsi,TF_RSI(%rsp)
- movq %r8,TF_R8(%rsp)
movq %r9,TF_R9(%rsp)
movq %rbx,TF_RBX(%rsp)
movq %rbp,TF_RBP(%rsp)
@@ -66,7 +66,6 @@
movq %r12,TF_R12(%rsp)
movq %r13,TF_R13(%rsp)
movq %r14,TF_R14(%rsp)
- movq %r15,TF_R15(%rsp)
movl $TF_HASSEGS,TF_FLAGS(%rsp)
pushfq
andq $~(PSL_D | PSL_AC),(%rsp)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 15, 9:53 AM (12 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29142045
Default Alt Text
D50414.1784109199.diff (3 KB)
Attached To
Mode
D50414: amd64: do not handle fs/gs bases conditionally on the selector
Attached
Detach File
Event Timeline
Log In to Comment