diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2022-09-02 09:02:38 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2022-09-02 09:02:38 +0000 |
commit | 310b77c814a387c12e3d0cb9c24909634c86a381 (patch) | |
tree | 30e543d1fabd58ef1df30e765500dd8388218e1d | |
parent | 172a26c3c71fc75d3c161dea31028d41ca2c66a7 (diff) |
Get the retguard region's phys address from pmap, instead of using linker
script symbols. This is needed since we don't have those symbols on all
archs where we want hibernate.
ok kettenis, and input and help from miod.
-rw-r--r-- | sys/arch/amd64/amd64/hibernate_machdep.c | 7 | ||||
-rw-r--r-- | sys/arch/amd64/conf/ld.script | 4 | ||||
-rw-r--r-- | sys/kern/subr_hibernate.c | 16 |
3 files changed, 19 insertions, 8 deletions
diff --git a/sys/arch/amd64/amd64/hibernate_machdep.c b/sys/arch/amd64/amd64/hibernate_machdep.c index 699a121571d..961d4300f58 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.48 2022/01/17 02:54:28 mlarkin Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.49 2022/09/02 09:02:37 mlarkin Exp $ */ /* * Copyright (c) 2012 Mike Larkin <mlarkin@openbsd.org> @@ -425,14 +425,13 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info, int hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest) { - extern char __retguard_start_phys, __retguard_end_phys; + extern paddr_t retguard_start_phys, retguard_end_phys; if (dest >= hib_info->piglet_pa && dest <= (hib_info->piglet_pa + 4 * HIBERNATE_CHUNK_SIZE)) return (HIB_SKIP); - if (dest >= ((paddr_t)&__retguard_start_phys) && - dest <= ((paddr_t)&__retguard_end_phys)) + if (dest >= retguard_start_phys && dest <= retguard_end_phys) return (HIB_MOVE); return (0); diff --git a/sys/arch/amd64/conf/ld.script b/sys/arch/amd64/conf/ld.script index eb9a549536e..18298f8b8c3 100644 --- a/sys/arch/amd64/conf/ld.script +++ b/sys/arch/amd64/conf/ld.script @@ -1,4 +1,4 @@ -/* $OpenBSD: ld.script,v 1.17 2021/03/07 23:10:54 mortimer Exp $ */ +/* $OpenBSD: ld.script,v 1.18 2022/09/02 09:02:37 mlarkin Exp $ */ /* * Copyright (c) 2009 Tobias Weingartner <weingart@tepid.org> @@ -101,11 +101,9 @@ SECTIONS .openbsd.randomdata : AT (__kernel_randomdata_phys) { __retguard_start = ABSOLUTE(.); - __retguard_start_phys = . + __kernel_virt_to_phys; *(.openbsd.randomdata.retguard .openbsd.randomdata.retguard.*) . = ALIGN(__ALIGN_SIZE); __retguard_end = ABSOLUTE(.); - __retguard_end_phys = . + __kernel_virt_to_phys; *(.openbsd.randomdata .openbsd.randomdata.*) } :rodata :openbsd_randomize =0xcccccccc . = ALIGN(0x1000); diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c index a3625636235..aff5b3569cb 100644 --- a/sys/kern/subr_hibernate.c +++ b/sys/kern/subr_hibernate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_hibernate.c,v 1.136 2022/09/01 21:50:19 mlarkin Exp $ */ +/* $OpenBSD: subr_hibernate.c,v 1.137 2022/09/02 09:02:37 mlarkin Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> @@ -102,6 +102,10 @@ int hib_debug = 99; extern long __guard_local; #endif /* ! NO_PROPOLICE */ +/* Retguard phys address (need to skip this region during unpack) */ +paddr_t retguard_start_phys, retguard_end_phys; +extern char __retguard_start, __retguard_end; + void hibernate_copy_chunk_to_piglet(paddr_t, vaddr_t, size_t); int hibernate_calc_rle(paddr_t, paddr_t); int hibernate_write_rle(union hibernate_info *, paddr_t, paddr_t, daddr_t *, @@ -1196,6 +1200,11 @@ hibernate_resume(void) goto fail; } + pmap_extract(pmap_kernel(), (vaddr_t)&__retguard_start, + &retguard_start_phys); + pmap_extract(pmap_kernel(), (vaddr_t)&__retguard_end, + &retguard_end_phys); + hibernate_preserve_entropy(&disk_hib); printf("Unpacking image...\n"); @@ -1921,6 +1930,11 @@ hibernate_suspend(void) return (1); } + pmap_extract(pmap_kernel(), (vaddr_t)&__retguard_start, + &retguard_start_phys); + pmap_extract(pmap_kernel(), (vaddr_t)&__retguard_end, + &retguard_end_phys); + /* Calculate block offsets in swap */ hib.image_offset = ctod(start); |