summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2010-02-23 21:54:54 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2010-02-23 21:54:54 +0000
commitf8e879f6de7c7d6b9eeb636b82caa7b8ac9c2b7e (patch)
treeff55a214bcac0920a66ecedf8d012f017c3b446a
parent9360448f266342987218b969e2e26dd78333f98f (diff)
Restore MTRRs on resume.
ok oga@, pirofti@
-rw-r--r--sys/arch/amd64/amd64/acpi_machdep.c7
-rw-r--r--sys/arch/amd64/amd64/amd64_mem.c17
-rw-r--r--sys/arch/i386/i386/acpi_machdep.c7
-rw-r--r--sys/arch/i386/i386/i686_mem.c17
-rw-r--r--sys/arch/i386/i386/k6_mem.c29
5 files changed, 57 insertions, 20 deletions
diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c
index abeae9a1998..d5323d15cb5 100644
--- a/sys/arch/amd64/amd64/acpi_machdep.c
+++ b/sys/arch/amd64/amd64/acpi_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_machdep.c,v 1.32 2009/11/29 21:21:06 deraadt Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.33 2010/02/23 21:54:53 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -20,6 +20,7 @@
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
+#include <sys/memrange.h>
#include <uvm/uvm_extern.h>
@@ -246,6 +247,10 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
fpuinit(&cpu_info_primary);
+ /* Re-initialise memory range handling */
+ if (mem_range_softc.mr_op != NULL)
+ mem_range_softc.mr_op->initAP(&mem_range_softc);
+
#if NIOAPIC > 0
ioapic_enable();
#endif
diff --git a/sys/arch/amd64/amd64/amd64_mem.c b/sys/arch/amd64/amd64/amd64_mem.c
index 2ee77dee8c1..086c8c7410c 100644
--- a/sys/arch/amd64/amd64/amd64_mem.c
+++ b/sys/arch/amd64/amd64/amd64_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amd64_mem.c,v 1.2 2009/11/29 17:11:30 kettenis Exp $ */
+/* $OpenBSD: amd64_mem.c,v 1.3 2010/02/23 21:54:53 kettenis Exp $ */
/*-
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -64,14 +64,14 @@ char *mem_owner_bios = "BIOS";
void amd64_mrinit(struct mem_range_softc *sc);
int amd64_mrset(struct mem_range_softc *sc,
struct mem_range_desc *mrd, int *arg);
-void amd64_mrAPinit(struct mem_range_softc *sc);
-void amd64_mrreload(struct mem_range_softc *sc);
+void amd64_mrinit_cpu(struct mem_range_softc *sc);
+void amd64_mrreload_cpu(struct mem_range_softc *sc);
struct mem_range_ops amd64_mrops = {
amd64_mrinit,
amd64_mrset,
- amd64_mrAPinit,
- amd64_mrreload
+ amd64_mrinit_cpu,
+ amd64_mrreload_cpu
};
/* XXX for AP startup hook */
@@ -592,17 +592,18 @@ amd64_mrinit(struct mem_range_softc *sc)
}
/*
- * Initialise MTRRs on an AP after the BSP has run the init code.
+ * Initialise MTRRs on an AP after the BSP has run the init code (or
+ * re-initialise the MTRRs on the BSP after suspend).
*/
void
-amd64_mrAPinit(struct mem_range_softc *sc)
+amd64_mrinit_cpu(struct mem_range_softc *sc)
{
amd64_mrstoreone(sc); /* set MTRRs to match BSP */
wrmsr(MSR_MTRRdefType, mtrrdef); /* set MTRR behaviour to match BSP */
}
void
-amd64_mrreload(struct mem_range_softc *sc)
+amd64_mrreload_cpu(struct mem_range_softc *sc)
{
disable_intr(); /* disable interrupts */
amd64_mrstoreone(sc); /* set MTRRs to match BSP */
diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c
index 42ca7069e00..5b4fdb640cb 100644
--- a/sys/arch/i386/i386/acpi_machdep.c
+++ b/sys/arch/i386/i386/acpi_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_machdep.c,v 1.27 2009/11/29 21:21:06 deraadt Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.28 2010/02/23 21:54:53 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -20,6 +20,7 @@
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
+#include <sys/memrange.h>
#include <uvm/uvm_extern.h>
@@ -274,6 +275,10 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
npxinit(&cpu_info_primary);
+ /* Re-initialise memory range handling */
+ if (mem_range_softc.mr_op != NULL)
+ mem_range_softc.mr_op->initAP(&mem_range_softc);
+
#if NIOAPIC > 0
ioapic_enable();
#endif
diff --git a/sys/arch/i386/i386/i686_mem.c b/sys/arch/i386/i386/i686_mem.c
index 42bc25698e0..49958669c3c 100644
--- a/sys/arch/i386/i386/i686_mem.c
+++ b/sys/arch/i386/i386/i686_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i686_mem.c,v 1.11 2009/11/29 17:11:30 kettenis Exp $ */
+/* $OpenBSD: i686_mem.c,v 1.12 2010/02/23 21:54:53 kettenis Exp $ */
/*-
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -64,14 +64,14 @@ char *mem_owner_bios = "BIOS";
void i686_mrinit(struct mem_range_softc *sc);
int i686_mrset(struct mem_range_softc *sc,
struct mem_range_desc *mrd, int *arg);
-void i686_mrAPinit(struct mem_range_softc *sc);
-void i686_mrreload(struct mem_range_softc *sc);
+void i686_mrinit_cpu(struct mem_range_softc *sc);
+void i686_mrreload_cpu(struct mem_range_softc *sc);
struct mem_range_ops i686_mrops = {
i686_mrinit,
i686_mrset,
- i686_mrAPinit,
- i686_mrreload
+ i686_mrinit_cpu,
+ i686_mrreload_cpu
};
/* XXX for AP startup hook */
@@ -592,17 +592,18 @@ i686_mrinit(struct mem_range_softc *sc)
}
/*
- * Initialise MTRRs on an AP after the BSP has run the init code.
+ * Initialise MTRRs on an AP after the BSP has run the init code (or
+ * re-initialise the MTRRs on the BSP after suspend).
*/
void
-i686_mrAPinit(struct mem_range_softc *sc)
+i686_mrinit_cpu(struct mem_range_softc *sc)
{
i686_mrstoreone(sc); /* set MTRRs to match BSP */
wrmsr(MSR_MTRRdefType, mtrrdef); /* set MTRR behaviour to match BSP */
}
void
-i686_mrreload(struct mem_range_softc *sc)
+i686_mrreload_cpu(struct mem_range_softc *sc)
{
disable_intr(); /* disable interrupts */
i686_mrstoreone(sc); /* set MTRRs to match BSP */
diff --git a/sys/arch/i386/i386/k6_mem.c b/sys/arch/i386/i386/k6_mem.c
index 591ee2f4266..b0d3b402a06 100644
--- a/sys/arch/i386/i386/k6_mem.c
+++ b/sys/arch/i386/i386/k6_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: k6_mem.c,v 1.10 2009/11/29 17:11:30 kettenis Exp $ */
+/* $OpenBSD: k6_mem.c,v 1.11 2010/02/23 21:54:53 kettenis Exp $ */
/*-
* Copyright (c) 1999 Brian Fundakowski Feldman
* All rights reserved.
@@ -62,12 +62,13 @@
void k6_mrinit(struct mem_range_softc *sc);
int k6_mrset(struct mem_range_softc *, struct mem_range_desc *, int *);
+void k6_mrinit_cpu(struct mem_range_softc *sc);
static __inline int k6_mrmake(struct mem_range_desc *, u_int32_t *);
struct mem_range_ops k6_mrops = {
k6_mrinit,
k6_mrset,
- NULL,
+ k6_mrinit_cpu,
NULL
};
@@ -173,3 +174,27 @@ out:
return 0;
}
+
+/*
+ * Re-initialise the MTRRs on the BSP after suspend.
+ */
+void
+k6_mrinit_cpu(struct mem_range_softc *sc)
+{
+ u_int64_t reg;
+ u_int32_t mtrr;
+ int d;
+
+ for (d = 0; d < sc->mr_ndesc; d++) {
+ k6_mrmake(&sc->mr_desc[d], &mtrr);
+
+ disable_intr();
+ wbinvd();
+ reg = rdmsr(UWCCR);
+ reg &= ~(0xffffffff << (32 * d));
+ reg |= mtrr << (32 * d);
+ wrmsr(UWCCR, reg);
+ wbinvd();
+ enable_intr();
+ }
+}