summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_hibernate.c
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 /sys/kern/subr_hibernate.c
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
Diffstat (limited to 'sys/kern/subr_hibernate.c')
-rw-r--r--sys/kern/subr_hibernate.c13
1 files changed, 7 insertions, 6 deletions
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);