summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/acpi_wakecode.S32
-rw-r--r--sys/arch/amd64/amd64/hibernate_machdep.c20
-rw-r--r--sys/arch/amd64/include/hibernate.h4
-rw-r--r--sys/arch/i386/i386/hibernate_machdep.c3
-rw-r--r--sys/arch/i386/include/hibernate.h4
-rw-r--r--sys/arch/loongson/include/hibernate.h4
6 files changed, 53 insertions, 14 deletions
diff --git a/sys/arch/amd64/amd64/acpi_wakecode.S b/sys/arch/amd64/amd64/acpi_wakecode.S
index 4eabf3e23c7..a9d3f4e778e 100644
--- a/sys/arch/amd64/amd64/acpi_wakecode.S
+++ b/sys/arch/amd64/amd64/acpi_wakecode.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_wakecode.S,v 1.42 2018/05/22 15:55:30 guenther Exp $ */
+/* $OpenBSD: acpi_wakecode.S,v 1.43 2018/06/21 07:33:30 mlarkin Exp $ */
/*
* Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
* Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
@@ -359,6 +359,36 @@ _C_LABEL(acpi_long_mode_resume):
*/
.code64
NENTRY(hibernate_resume_machdep)
+ /*
+ * On resume time page table, switch temporarily to the suspended
+ * kernel's old page table (needed to access the suspended kernel's
+ * retguard area)
+ */
+ movq .Lacpi_saved_cr3, %rax
+ movq %rax, %cr3
+
+ /*
+ * Now back on suspended kernel's page tables. Need to copy
+ * into rodata, so instead of fixing up the perms here and
+ * resetting them later, temporarily disable CR0.WP to allow
+ * us to write.
+ */
+ movq %cr0, %rax
+ andq $(~CR0_WP), %rax
+ movq %rax, %cr0
+
+ movq %rdi, %rsi
+ movq $__retguard_start, %rdi
+ movq $__retguard_end, %rcx
+ subq %rdi, %rcx
+ shrq $0x3, %rcx
+ rep movsq
+
+ /* Reenable CR0.WP */
+ movq %cr0, %rax
+ orq $(CR0_WP), %rax
+ movq %rax, %cr0
+
cli
/* Jump to the identity mapped version of ourself */
mov $.Lhibernate_resume_vector_2, %rax
diff --git a/sys/arch/amd64/amd64/hibernate_machdep.c b/sys/arch/amd64/amd64/hibernate_machdep.c
index c1d7b6a8a0e..f25fe027dde 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.41 2018/03/20 04:18:40 jmatthew Exp $ */
+/* $OpenBSD: hibernate_machdep.c,v 1.42 2018/06/21 07:33:30 mlarkin Exp $ */
/*
* Copyright (c) 2012 Mike Larkin <mlarkin@openbsd.org>
@@ -413,17 +413,27 @@ hibernate_populate_resume_pt(union hibernate_info *hib_info,
/*
* During inflate, certain pages that contain our bookkeeping information
- * (eg, the chunk table, scratch pages, etc) need to be skipped over and
- * not inflated into.
+ * (eg, the chunk table, scratch pages, retguard region, etc) need to be
+ * skipped over and not inflated into.
*
- * Returns 1 if the physical page at dest should be skipped, 0 otherwise
+ * Return values:
+ * HIB_MOVE: if the physical page at dest should be moved to the retguard save
+ * region in the piglet
+ * HIB_SKIP: if the physical page at dest should be skipped
+ * 0: otherwise (no special treatment needed)
*/
int
hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest)
{
+ extern char __retguard_start_phys, __retguard_end_phys;
+
if (dest >= hib_info->piglet_pa &&
dest <= (hib_info->piglet_pa + 4 * HIBERNATE_CHUNK_SIZE))
- return (1);
+ return (HIB_SKIP);
+
+ if (dest >= ((paddr_t)&__retguard_start_phys) &&
+ dest <= ((paddr_t)&__retguard_end_phys))
+ return (HIB_MOVE);
return (0);
}
diff --git a/sys/arch/amd64/include/hibernate.h b/sys/arch/amd64/include/hibernate.h
index cfcb812ff78..3052bff8729 100644
--- a/sys/arch/amd64/include/hibernate.h
+++ b/sys/arch/amd64/include/hibernate.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate.h,v 1.6 2014/07/09 11:37:16 mlarkin Exp $ */
+/* $OpenBSD: hibernate.h,v 1.7 2018/06/21 07:33:30 mlarkin Exp $ */
/*
* Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org>
@@ -26,7 +26,7 @@ void hibernate_enter_resume_mapping(vaddr_t, paddr_t, int);
int hibernate_inflate_skip(union hibernate_info *, paddr_t);
int hibernate_suspend(void);
void hibernate_switch_stack_machdep(void);
-void hibernate_resume_machdep(void);
+void hibernate_resume_machdep(vaddr_t);
void hibernate_activate_resume_pt_machdep(void);
void hibernate_enable_intr_machdep(void);
void hibernate_disable_intr_machdep(void);
diff --git a/sys/arch/i386/i386/hibernate_machdep.c b/sys/arch/i386/i386/hibernate_machdep.c
index f98d6c5a49e..c8164705183 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.51 2018/03/20 04:18:40 jmatthew Exp $ */
+/* $OpenBSD: hibernate_machdep.c,v 1.52 2018/06/21 07:33:30 mlarkin Exp $ */
/*
* Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org>
@@ -52,7 +52,6 @@ void hibernate_enter_resume_4k_pte(vaddr_t, paddr_t);
void hibernate_enter_resume_4k_pde(vaddr_t);
void hibernate_enter_resume_4m_pde(vaddr_t, paddr_t);
-extern void hibernate_resume_machdep(void);
extern void hibernate_flush(void);
extern caddr_t start, end;
extern int ndumpmem;
diff --git a/sys/arch/i386/include/hibernate.h b/sys/arch/i386/include/hibernate.h
index f170ed82992..6448e7dd902 100644
--- a/sys/arch/i386/include/hibernate.h
+++ b/sys/arch/i386/include/hibernate.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate.h,v 1.9 2014/05/31 06:30:16 mlarkin Exp $ */
+/* $OpenBSD: hibernate.h,v 1.10 2018/06/21 07:33:30 mlarkin Exp $ */
/*
* Copyright (c) 2011 Mike Larkin <mlarkin@openbsd.org>
@@ -26,7 +26,7 @@ void hibernate_enter_resume_mapping(vaddr_t, paddr_t, int);
int hibernate_inflate_skip(union hibernate_info *, paddr_t);
int hibernate_suspend(void);
void hibernate_switch_stack_machdep(void);
-void hibernate_resume_machdep(void);
+void hibernate_resume_machdep(vaddr_t);
void hibernate_activate_resume_pt_machdep(void);
void hibernate_enable_intr_machdep(void);
void hibernate_disable_intr_machdep(void);
diff --git a/sys/arch/loongson/include/hibernate.h b/sys/arch/loongson/include/hibernate.h
index bd267aa0a13..497a278971e 100644
--- a/sys/arch/loongson/include/hibernate.h
+++ b/sys/arch/loongson/include/hibernate.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate.h,v 1.2 2014/05/31 06:30:16 mlarkin Exp $ */
+/* $OpenBSD: hibernate.h,v 1.3 2018/06/21 07:33:30 mlarkin Exp $ */
/*
* Copyright (c) 2013 Paul Irofti.
@@ -27,7 +27,7 @@ void hibernate_enter_resume_mapping(vaddr_t, paddr_t, int);
int hibernate_inflate_skip(union hibernate_info *, paddr_t);
int hibernate_suspend(void);
void hibernate_switch_stack_machdep(void);
-void hibernate_resume_machdep(void);
+void hibernate_resume_machdep(vaddr_t);
void hibernate_activate_resume_pt_machdep(void);
void hibernate_enable_intr_machdep(void);
void hibernate_disable_intr_machdep(void);