summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/i386/i386/hibernate_machdep.c4
-rw-r--r--sys/kern/subr_hibernate.c33
-rw-r--r--sys/sys/hibernate.h4
3 files changed, 38 insertions, 3 deletions
diff --git a/sys/arch/i386/i386/hibernate_machdep.c b/sys/arch/i386/i386/hibernate_machdep.c
index cb7f194b1b6..96184a25c49 100644
--- a/sys/arch/i386/i386/hibernate_machdep.c
+++ b/sys/arch/i386/i386/hibernate_machdep.c
@@ -372,9 +372,11 @@ hibernate_suspend()
{
/*
* On i386, the only thing to do on hibernate suspend is
- * to write the image.
+ * to zero all the unused pages and write the image.
*/
+ uvm_pmr_zero_everything();
+
return hibernate_write_image();
}
diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c
index 69cfb2f25ca..1e01e618a8e 100644
--- a/sys/kern/subr_hibernate.c
+++ b/sys/kern/subr_hibernate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_hibernate.c,v 1.11 2011/07/09 01:30:39 mlarkin Exp $ */
+/* $OpenBSD: subr_hibernate.c,v 1.12 2011/07/09 03:10:27 mlarkin Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -819,3 +819,34 @@ hibernate_check_overlap(paddr_t r1s, paddr_t r1e, paddr_t r2s, paddr_t r2e)
return (0);
}
+
+/*
+ * hibernate_compare_signature
+ *
+ * Compare two hibernate_infos to determine if they are the same (eg,
+ * we should be performing a hibernate resume on this machine.
+ * Not all fields are checked - just enough to verify that the machine
+ * has the same memory configuration and kernel as the one that
+ * wrote the signature previously.
+ */
+int
+hibernate_compare_signature(union hibernate_info *mine,
+ union hibernate_info *disk)
+{
+ u_int i;
+
+ if (mine->nranges != disk->nranges)
+ return (1);
+
+ if (strcmp(mine->kernel_version, disk->kernel_version) != 0)
+ return (1);
+
+ for (i=0; i< mine->nranges; i++) {
+ if ((mine->ranges[i].base != disk->ranges[i].base) ||
+ (mine->ranges[i].end != disk->ranges[i].end) )
+ return (1);
+ }
+
+ return (0);
+}
+
diff --git a/sys/sys/hibernate.h b/sys/sys/hibernate.h
index 5e3bfbfe4ef..6a4b7a4b15f 100644
--- a/sys/sys/hibernate.h
+++ b/sys/sys/hibernate.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate.h,v 1.10 2011/07/09 01:30:39 mlarkin Exp $ */
+/* $OpenBSD: hibernate.h,v 1.11 2011/07/09 03:10:27 mlarkin Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -121,6 +121,8 @@ size_t hibernate_deflate(paddr_t, size_t *);
int hibernate_write_signature(union hibernate_info *);
int hibernate_clear_signature(void);
+int hibernate_compare_signature(union hibernate_info *,
+ union hibernate_info *);
int hibernate_check_overlap(paddr_t, paddr_t, paddr_t, paddr_t);