diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-07-09 15:03:13 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-07-09 15:03:13 +0000 |
commit | b5a894c3e7287eb092c1442d1017d9249c338c69 (patch) | |
tree | 0c859f1f472cba5ca24a09a6f8a7e7ebbdbe2668 /sys/arch | |
parent | de77d6f734a41afdd25337d4c41dad6a46c12568 (diff) |
Don't use the suspending kernel's VA mapping for the piglet. It's far
easier and much less error-prone to just identity map it in the resuming
kernel as we have more control over the VA space layout there (otherwise
we are at the mercy of the suspending kernel's placement of the piglet VA).
This diff also increases the size of the piglet to 4 chunks, to avoid an
overwrite issue seen in m2k14 where the start of the kernel text was
overwritten with a bounced chunk before unpack.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/hibernate_machdep.c | 19 | ||||
-rw-r--r-- | sys/arch/i386/i386/hibernate_machdep.c | 20 | ||||
-rw-r--r-- | sys/arch/loongson/loongson/hibernate_machdep.c | 4 |
3 files changed, 23 insertions, 20 deletions
diff --git a/sys/arch/amd64/amd64/hibernate_machdep.c b/sys/arch/amd64/amd64/hibernate_machdep.c index 83ca556ae7b..5d8f8de31c5 100644 --- a/sys/arch/amd64/amd64/hibernate_machdep.c +++ b/sys/arch/amd64/amd64/hibernate_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.24 2014/07/09 14:35:24 mlarkin Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.25 2014/07/09 15:03:12 mlarkin Exp $ */ /* * Copyright (c) 2012 Mike Larkin <mlarkin@openbsd.org> @@ -235,8 +235,9 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, paddr_t image_start, paddr_t image_end) { int phys_page_number, i; - paddr_t pa, piglet_start, piglet_end; + paddr_t pa; vaddr_t kern_start_2m_va, kern_end_2m_va, page; + vaddr_t piglet_start_va, piglet_end_va; pt_entry_t *pde, npde; /* Identity map MMU pages */ @@ -310,15 +311,15 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, } /* - * Map the piglet + * Identity map the piglet using 2MB pages. */ phys_page_number = hib_info->piglet_pa / NBPD_L2; - piglet_start = hib_info->piglet_va; - piglet_end = piglet_start + HIBERNATE_CHUNK_SIZE * 3; - piglet_start &= ~(PAGE_MASK_2M); - piglet_end &= ~(PAGE_MASK_2M); - for (page = piglet_start; page <= piglet_end ; + /* VA == PA */ + piglet_start_va = hib_info->piglet_pa; + piglet_end_va = piglet_start_va + HIBERNATE_CHUNK_SIZE * 4; + + for (page = piglet_start_va; page <= piglet_end_va; page += NBPD_L2, phys_page_number++) { pa = (paddr_t)(phys_page_number * NBPD_L2); hibernate_enter_resume_mapping(page, pa, 1); @@ -336,7 +337,7 @@ int hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest) { if (dest >= hib_info->piglet_pa && - dest <= (hib_info->piglet_pa + 3 * HIBERNATE_CHUNK_SIZE)) + dest <= (hib_info->piglet_pa + 4 * HIBERNATE_CHUNK_SIZE)) return (1); return (0); diff --git a/sys/arch/i386/i386/hibernate_machdep.c b/sys/arch/i386/i386/hibernate_machdep.c index 2dc8911edeb..b3e249f8ec9 100644 --- a/sys/arch/i386/i386/hibernate_machdep.c +++ b/sys/arch/i386/i386/hibernate_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.34 2014/07/09 14:35:24 mlarkin Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.35 2014/07/09 15:03:12 mlarkin Exp $ */ /* * Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org> @@ -202,8 +202,9 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, paddr_t image_start, paddr_t image_end) { int phys_page_number, i; - paddr_t pa, piglet_start, piglet_end; + paddr_t pa; vaddr_t kern_start_4m_va, kern_end_4m_va, page; + vaddr_t piglet_start_va, piglet_end_va; /* Identity map PD, PT, and stack pages */ pmap_kenter_pa(HIBERNATE_PT_PAGE, HIBERNATE_PT_PAGE, VM_PROT_ALL); @@ -253,14 +254,15 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, } /* - * Map the piglet + * Identity map the piglet using 4MB pages. */ phys_page_number = hib_info->piglet_pa / NBPD; - piglet_start = hib_info->piglet_va; - piglet_end = piglet_start + HIBERNATE_CHUNK_SIZE * 3; - piglet_start &= ~(PAGE_MASK_4M); - piglet_end &= ~(PAGE_MASK_4M); - for (page = piglet_start; page <= piglet_end ; + + /* VA == PA */ + piglet_start_va = hib_info->piglet_pa; + piglet_end_va = piglet_start_va + HIBERNATE_CHUNK_SIZE * 4; + + for (page = piglet_start_va; page <= piglet_end_va; page += NBPD, phys_page_number++) { pa = (paddr_t)(phys_page_number * NBPD); hibernate_enter_resume_mapping(page, pa, 1); @@ -278,7 +280,7 @@ int hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest) { if (dest >= hib_info->piglet_pa && - dest <= (hib_info->piglet_pa + 3 * HIBERNATE_CHUNK_SIZE)) + dest <= (hib_info->piglet_pa + 4 * HIBERNATE_CHUNK_SIZE)) return (1); return (0); diff --git a/sys/arch/loongson/loongson/hibernate_machdep.c b/sys/arch/loongson/loongson/hibernate_machdep.c index 107ff45e5de..8faf1a61b59 100644 --- a/sys/arch/loongson/loongson/hibernate_machdep.c +++ b/sys/arch/loongson/loongson/hibernate_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.4 2014/05/31 06:30:16 mlarkin Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.5 2014/07/09 15:03:12 mlarkin Exp $ */ /* * Copyright (c) 2013 Paul Irofti. @@ -146,7 +146,7 @@ int hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest) { if (dest >= hib_info->piglet_pa && - dest <= (hib_info->piglet_pa + 3 * HIBERNATE_CHUNK_SIZE)) + dest <= (hib_info->piglet_pa + 4 * HIBERNATE_CHUNK_SIZE)) return (1); return (0); |