summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-04-17 16:02:34 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-04-17 16:02:34 +0000
commit916f161cd9b4c3fb17be9c3d32e0618df7e72911 (patch)
tree47c92610a5a1b18537f8eb1278d6805f235c3220
parent55b040815206d7dce82f59a01096792b5b766e98 (diff)
Don't try to cache the CPU's FS.base, as userland can make it a lie by
setting %fs, resulting in it not getting restored properly later ok mikeb@ deraadt@
-rw-r--r--sys/arch/amd64/amd64/cpu.c3
-rw-r--r--sys/arch/amd64/amd64/genassym.cf3
-rw-r--r--sys/arch/amd64/include/cpu.h3
-rw-r--r--sys/arch/amd64/include/frameasm.h14
4 files changed, 6 insertions, 17 deletions
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index 1221401cf42..f5444285b3d 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.47 2012/04/04 18:44:22 mikeb Exp $ */
+/* $OpenBSD: cpu.c,v 1.48 2012/04/17 16:02:33 guenther Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -681,7 +681,6 @@ cpu_init_msrs(struct cpu_info *ci)
wrmsr(MSR_CSTAR, (uint64_t)Xsyscall32);
wrmsr(MSR_SFMASK, PSL_NT|PSL_T|PSL_I|PSL_C);
- ci->ci_cur_fsbase = 0;
wrmsr(MSR_FSBASE, 0);
wrmsr(MSR_GSBASE, (u_int64_t)ci);
wrmsr(MSR_KERNELGSBASE, 0);
diff --git a/sys/arch/amd64/amd64/genassym.cf b/sys/arch/amd64/amd64/genassym.cf
index db292d709a4..5ae35085109 100644
--- a/sys/arch/amd64/amd64/genassym.cf
+++ b/sys/arch/amd64/amd64/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.28 2011/04/13 02:49:12 guenther Exp $
+# $OpenBSD: genassym.cf,v 1.29 2012/04/17 16:02:33 guenther Exp $
# Written by Artur Grabowski art@openbsd.org, Public Domain
include <sys/param.h>
@@ -99,7 +99,6 @@ member tss_rsp0
struct cpu_info
member CPU_INFO_SCRATCH ci_scratch
-member CPU_INFO_CUR_FSBASE ci_cur_fsbase
member CPU_INFO_SELF ci_self
member CPU_INFO_CPUID ci_cpuid
member CPU_INFO_APICID ci_apicid
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 8b4e3dcb6e8..e06bea011f5 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.72 2012/04/04 18:44:22 mikeb Exp $ */
+/* $OpenBSD: cpu.h,v 1.73 2012/04/17 16:02:33 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -72,7 +72,6 @@ struct cpu_info {
u_int32_t ci_randseed;
u_int64_t ci_scratch;
- u_int64_t ci_cur_fsbase;
struct proc *ci_fpcurproc;
struct proc *ci_fpsaveproc;
diff --git a/sys/arch/amd64/include/frameasm.h b/sys/arch/amd64/include/frameasm.h
index 83388ab874d..95a1e0faa25 100644
--- a/sys/arch/amd64/include/frameasm.h
+++ b/sys/arch/amd64/include/frameasm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: frameasm.h,v 1.6 2011/07/04 15:54:24 guenther Exp $ */
+/* $OpenBSD: frameasm.h,v 1.7 2012/04/17 16:02:33 guenther Exp $ */
/* $NetBSD: frameasm.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */
#ifndef _AMD64_MACHINE_FRAMEASM_H
@@ -65,22 +65,14 @@
movw $(GSEL(GUDATA_SEL, SEL_UPL)),%ax ; \
movw %ax,%ds ; \
/* Make sure both %fs and FS.base are the desired values */ \
+ movw TF_FS(%rsp),%fs ; \
movq PCB_FSBASE(%rdx),%rax ; \
cmpq $0,%rax ; \
- jne 96f ; \
- movw TF_FS(%rsp),%fs /* zero FS.base by setting %fs */ ; \
- jmp 98f ; \
-96: cmpq CPUVAR(CUR_FSBASE),%rax ; \
- jne 97f ; \
- movw %fs,%cx /* FS.base same, how about %fs? */ ; \
- cmpw TF_FS(%rsp),%cx ; \
- je 99f ; \
-97: movw TF_FS(%rsp),%fs /* set them both */ ; \
+ je 99f /* setting %fs has zeroed FS.base */ ; \
movq %rax,%rdx ; \
shrq $32,%rdx ; \
movl $MSR_FSBASE,%ecx ; \
wrmsr ; \
-98: movq %rax,CPUVAR(CUR_FSBASE) ; \
99: cli /* %fs done, so swapgs and do %gs */ ; \
swapgs ; \
movw TF_GS(%rsp),%gs