Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/acpi Save and restore xcr0 when doing ACPI slee...



details:   https://anonhg.NetBSD.org/src/rev/788763ad6083
branches:  trunk
changeset: 825995:788763ad6083
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Aug 10 13:13:03 2017 +0000

description:
Save and restore xcr0 when doing ACPI sleeps. Should fix PR/49174.

diffstat:

 sys/arch/x86/acpi/acpi_wakeup.c |  24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diffs (78 lines):

diff -r 83b3cf99bafd -r 788763ad6083 sys/arch/x86/acpi/acpi_wakeup.c
--- a/sys/arch/x86/acpi/acpi_wakeup.c   Thu Aug 10 12:51:22 2017 +0000
+++ b/sys/arch/x86/acpi/acpi_wakeup.c   Thu Aug 10 13:13:03 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_wakeup.c,v 1.45 2016/10/20 16:05:04 maxv Exp $    */
+/*     $NetBSD: acpi_wakeup.c,v 1.46 2017/08/10 13:13:03 maxv Exp $    */
 
 /*-
  * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.45 2016/10/20 16:05:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.46 2017/08/10 13:13:03 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -250,6 +250,7 @@
 void
 acpi_cpu_sleep(struct cpu_info *ci)
 {
+       uint64_t xcr0 = 0;
        int s;
 
        KASSERT(!CPU_IS_PRIMARY(ci));
@@ -259,12 +260,21 @@
        fpusave_cpu(true);
        x86_disable_intr();
 
+       /*
+        * XXX also need to save the PMCs, the dbregs, and probably a few
+        * MSRs too.
+        */
+       if (rcr4() & CR4_OSXSAVE)
+               xcr0 = rdxcr(0);
+
        if (acpi_md_sleep_prepare(-1))
                goto out;
 
        /* Execute Wakeup */
        cpu_init_msrs(ci, false);
        fpuinit(ci);
+       if (rcr4() & CR4_OSXSAVE)
+               wrxcr(0, xcr0);
 
 #if NLAPIC > 0
        lapic_enable();
@@ -285,6 +295,7 @@
 int
 acpi_md_sleep(int state)
 {
+       uint64_t xcr0 = 0;
        int s, ret = 0;
 #ifdef MULTIPROCESSOR
        struct cpu_info *ci;
@@ -315,12 +326,21 @@
        }
 #endif
 
+       /*
+        * XXX also need to save the PMCs, the dbregs, and probably a few
+        * MSRs too.
+        */
+       if (rcr4() & CR4_OSXSAVE)
+               xcr0 = rdxcr(0);
+
        if (acpi_md_sleep_prepare(state))
                goto out;
 
        /* Execute Wakeup */
        cpu_init_msrs(&cpu_info_primary, false);
        fpuinit(&cpu_info_primary);
+       if (rcr4() & CR4_OSXSAVE)
+               wrxcr(0, xcr0);
        i8259_reinit();
 #if NLAPIC > 0
        lapic_enable();



Home | Main Index | Thread Index | Old Index