summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2012-01-31 17:51:30 +0000
committerjkim <jkim@FreeBSD.org>2012-01-31 17:51:30 +0000
commitb7e2f6b922e0f2152669e41acca1c6843ccf3c7b (patch)
tree91c04d307fd25744ae09ec7ba542b44fd15461a5 /sys/amd64
parent117fc9c016505122573f10f6143ed330110a35de (diff)
downloadFreeBSD-src-b7e2f6b922e0f2152669e41acca1c6843ccf3c7b.zip
FreeBSD-src-b7e2f6b922e0f2152669e41acca1c6843ccf3c7b.tar.gz
- Restore XCR0 before restoring extended FPU states.
- Update my copyright dates. Reviewed by: kib
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/acpica/acpi_switch.S30
-rw-r--r--sys/amd64/acpica/acpi_wakecode.S4
-rw-r--r--sys/amd64/acpica/acpi_wakeup.c3
3 files changed, 22 insertions, 15 deletions
diff --git a/sys/amd64/acpica/acpi_switch.S b/sys/amd64/acpica/acpi_switch.S
index 6091e2a..3529506 100644
--- a/sys/amd64/acpica/acpi_switch.S
+++ b/sys/amd64/acpica/acpi_switch.S
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
* Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
- * Copyright (c) 2008-2010 Jung-uk Kim <jkim@FreeBSD.org>
+ * Copyright (c) 2008-2012 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -95,7 +95,6 @@ ENTRY(acpi_restorecpu)
/* Restore CR0 except for FPU mode. */
movq PCB_CR0(%rdi), %rax
- movq %rax, %rcx
andq $~(CR0_EM | CR0_TS), %rax
movq %rax, %cr0
@@ -146,21 +145,26 @@ ENTRY(acpi_restorecpu)
/* Restore FPU state. */
fninit
- movq WAKEUP_CTX(fpusave),%rdi
- cmpl $0,use_xsave
- jne 1f
- fxrstor (%rdi)
+ movq WAKEUP_CTX(xsmask), %rax
+ testq %rax, %rax
+ jz 1f
+ movq %rax, %rdx
+ shrq $32, %rdx
+ movl $XCR0, %ecx
+/* xsetbv */
+ .byte 0x0f, 0x01, 0xd1
+ movq WAKEUP_CTX(fpusave), %rcx
+/* xrstor (%rcx) */
+ .byte 0x0f, 0xae, 0x29
jmp 2f
-1: movl xsave_mask,%eax
- movl xsave_mask+4,%edx
-/* xrstor (%rdi) */
- .byte 0x0f,0xae,0x2f
+1:
+ movq WAKEUP_CTX(fpusave), %rcx
+ fxrstor (%rcx)
2:
/* Reload CR0. */
- movq %rcx, %cr0
-
- movq WAKEUP_CTX(pcb),%rdi
+ movq PCB_CR0(%rdi), %rax
+ movq %rax, %cr0
/* Restore return address. */
movq PCB_RIP(%rdi), %rax
diff --git a/sys/amd64/acpica/acpi_wakecode.S b/sys/amd64/acpica/acpi_wakecode.S
index ed239c5..0f34d39 100644
--- a/sys/amd64/acpica/acpi_wakecode.S
+++ b/sys/amd64/acpica/acpi_wakecode.S
@@ -2,7 +2,7 @@
* Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
* Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
* Copyright (c) 2003 Peter Wemm
- * Copyright (c) 2008-2010 Jung-uk Kim <jkim@FreeBSD.org>
+ * Copyright (c) 2008-2012 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -284,6 +284,8 @@ wakeup_cstar:
.quad 0
wakeup_sfmask:
.quad 0
+wakeup_xsmask:
+ .quad 0
wakeup_cpu:
.long 0
dummy:
diff --git a/sys/amd64/acpica/acpi_wakeup.c b/sys/amd64/acpica/acpi_wakeup.c
index f862435..bc5e08f 100644
--- a/sys/amd64/acpica/acpi_wakeup.c
+++ b/sys/amd64/acpica/acpi_wakeup.c
@@ -2,7 +2,7 @@
* Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
* Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
* Copyright (c) 2003 Peter Wemm
- * Copyright (c) 2008-2010 Jung-uk Kim <jkim@FreeBSD.org>
+ * Copyright (c) 2008-2012 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -386,6 +386,7 @@ acpi_install_wakeup_handler(struct acpi_softc *sc)
WAKECODE_FIXUP(wakeup_lstar, uint64_t, rdmsr(MSR_LSTAR));
WAKECODE_FIXUP(wakeup_cstar, uint64_t, rdmsr(MSR_CSTAR));
WAKECODE_FIXUP(wakeup_sfmask, uint64_t, rdmsr(MSR_SF_MASK));
+ WAKECODE_FIXUP(wakeup_xsmask, uint64_t, xsave_mask);
/* Build temporary page tables below realmode code. */
pt4 = wakeaddr;
OpenPOWER on IntegriCloud