diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-04-13 02:49:13 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-04-13 02:49:13 +0000 |
commit | db682fd5779b081482c354010a642bb7e59f7a21 (patch) | |
tree | b56c1734748957414eb2ad9836cca1b453bc6881 /sys/arch/amd64/include/frameasm.h | |
parent | 2230c47a580f8020e6248e1a346ed6105b278152 (diff) |
Unrevert the FS.base diff: the issues were actually elsewhere
Additional testing by jasper@ and pea@
Diffstat (limited to 'sys/arch/amd64/include/frameasm.h')
-rw-r--r-- | sys/arch/amd64/include/frameasm.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/sys/arch/amd64/include/frameasm.h b/sys/arch/amd64/include/frameasm.h index 1091075d8af..57fb5bff2c8 100644 --- a/sys/arch/amd64/include/frameasm.h +++ b/sys/arch/amd64/include/frameasm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: frameasm.h,v 1.4 2011/04/10 03:56:38 guenther Exp $ */ +/* $OpenBSD: frameasm.h,v 1.5 2011/04/13 02:49:12 guenther Exp $ */ /* $NetBSD: frameasm.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ #ifndef _AMD64_MACHINE_FRAMEASM_H @@ -72,6 +72,37 @@ pushq %r11 ; \ pushq %r13 ; +/* + * Restore %ds, %es, %fs, and %gs, dealing with the FS.base MSR for + * %fs and doing the cli/swapgs for %gs. Uses %rax, %rcx, and %rdx + */ +#define INTR_RESTORE_SELECTORS \ + movq CPUVAR(CURPCB),%rdx /* for below */ ; \ + /* %es and %ds */ \ + movw TF_ES(%rsp),%es ; \ + movw $(GSEL(GUDATA_SEL, SEL_UPL)),%ax ; \ + movw %ax,%ds ; \ + /* Make sure both %fs and FS.base are the desired values */ \ + 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 */ ; \ + 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 + #define CHECK_ASTPENDING(reg) movq CPUVAR(CURPROC),reg ; \ cmpq $0, reg ; \ |