summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormlarkin <mlarkin@openbsd.org>2015-02-06 05:17:48 +0000
committermlarkin <mlarkin@openbsd.org>2015-02-06 05:17:48 +0000
commit78e2b1f82ed8a583cb98c89232861fbf885d5122 (patch)
treef32e183d40aecdb38655e8830f865268a075661a
parentDon't let errors leak the memory returned by getifaddrs(). (diff)
downloadwireguard-openbsd-78e2b1f82ed8a583cb98c89232861fbf885d5122.tar.xz
wireguard-openbsd-78e2b1f82ed8a583cb98c89232861fbf885d5122.zip
Fix a hibernate crash on some machines due to unmapping a page that
may not have been mapped previously (in the failure to hibernate case). Also ensure that the lowmem ptp is mapped in all cases (not just MP). ok kettenis
-rw-r--r--sys/arch/i386/i386/machdep.c4
-rw-r--r--sys/dev/acpi/acpi.c7
-rw-r--r--sys/kern/subr_hibernate.c13
3 files changed, 13 insertions, 11 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index f5920e352d3..76cdf11851a 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.564 2015/01/20 19:43:21 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.565 2015/02/06 05:17:48 mlarkin Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -3176,10 +3176,8 @@ init386(paddr_t first_avail)
panic("no BIOS memory map supplied");
#endif
-#if defined(MULTIPROCESSOR)
/* install the lowmem ptp after boot args for 1:1 mappings */
pmap_prealloc_lowmem_ptp(round_page((paddr_t)(bootargv + bootargc)));
-#endif
/*
* account all the memory passed in the map from /boot
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index b3d3e4ac46e..572faee5807 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.281 2015/01/17 04:18:49 deraadt Exp $ */
+/* $OpenBSD: acpi.c,v 1.282 2015/02/06 05:17:48 mlarkin Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -2200,8 +2200,11 @@ acpi_sleep_state(struct acpi_softc *sc, int state)
if (state == ACPI_STATE_S4) {
uvmpd_hibernate();
hibernate_suspend_bufcache();
- if (hibernate_alloc())
+ if (hibernate_alloc()) {
+ printf("%s: failed to allocate hibernate memory\n",
+ sc->sc_dev.dv_xname);
goto fail_alloc;
+ }
}
#endif /* HIBERNATE */
diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c
index b48306c5d70..fe9bf799a38 100644
--- a/sys/kern/subr_hibernate.c
+++ b/sys/kern/subr_hibernate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_hibernate.c,v 1.112 2015/01/12 07:11:41 deraadt Exp $ */
+/* $OpenBSD: subr_hibernate.c,v 1.113 2015/02/06 05:17:48 mlarkin Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -1398,8 +1398,6 @@ hibernate_write_chunks(union hibernate_info *hib)
inaddr & PMAP_PA_MASK,
PROT_READ);
- pmap_activate(curproc);
-
bcopy((caddr_t)hibernate_temp_page,
(caddr_t)hibernate_copy_page,
PAGE_SIZE);
@@ -1799,10 +1797,7 @@ hibernate_suspend(void)
DPRINTF("hibernate @ block %lld max-length %lu blocks\n",
hib.image_offset, ctod(end) - ctod(start));
- pmap_kenter_pa(HIBERNATE_HIBALLOC_PAGE, HIBERNATE_HIBALLOC_PAGE,
- PROT_READ | PROT_WRITE);
pmap_activate(curproc);
-
DPRINTF("hibernate: writing chunks\n");
if (hibernate_write_chunks(&hib)) {
DPRINTF("hibernate_write_chunks failed\n");
@@ -1838,6 +1833,10 @@ hibernate_alloc(void)
KASSERT(global_piglet_va == 0);
KASSERT(hibernate_temp_page == 0);
+ pmap_activate(curproc);
+ pmap_kenter_pa(HIBERNATE_HIBALLOC_PAGE, HIBERNATE_HIBALLOC_PAGE,
+ PROT_READ | PROT_WRITE);
+
/* Allocate a piglet, store its addresses in the supplied globals */
if (uvm_pmr_alloc_piglet(&global_piglet_va, &global_piglet_pa,
HIBERNATE_CHUNK_SIZE * 4, HIBERNATE_CHUNK_SIZE))
@@ -1866,6 +1865,8 @@ hibernate_alloc(void)
void
hibernate_free(void)
{
+ pmap_activate(curproc);
+
if (global_piglet_va)
uvm_pmr_free_piglet(global_piglet_va,
4 * HIBERNATE_CHUNK_SIZE);