aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/suspend.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/kernel/suspend.c')
-rw-r--r--arch/s390/kernel/suspend.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/arch/s390/kernel/suspend.c b/arch/s390/kernel/suspend.c
new file mode 100644
index 000000000000..086bee970cae
--- /dev/null
+++ b/arch/s390/kernel/suspend.c
@@ -0,0 +1,73 @@
1/*
2 * Suspend support specific for s390.
3 *
4 * Copyright IBM Corp. 2009
5 *
6 * Author(s): Hans-Joachim Picht <hans@linux.vnet.ibm.com>
7 */
8
9#include <linux/suspend.h>
10#include <linux/reboot.h>
11#include <linux/pfn.h>
12#include <linux/mm.h>
13#include <asm/sections.h>
14#include <asm/system.h>
15#include <asm/ipl.h>
16
17/*
18 * References to section boundaries
19 */
20extern const void __nosave_begin, __nosave_end;
21
22/*
23 * check if given pfn is in the 'nosave' or in the read only NSS section
24 */
25int pfn_is_nosave(unsigned long pfn)
26{
27 unsigned long nosave_begin_pfn = __pa(&__nosave_begin) >> PAGE_SHIFT;
28 unsigned long nosave_end_pfn = PAGE_ALIGN(__pa(&__nosave_end))
29 >> PAGE_SHIFT;
30 unsigned long eshared_pfn = PFN_DOWN(__pa(&_eshared)) - 1;
31 unsigned long stext_pfn = PFN_DOWN(__pa(&_stext));
32
33 if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn)
34 return 1;
35 if (pfn >= stext_pfn && pfn <= eshared_pfn) {
36 if (ipl_info.type == IPL_TYPE_NSS)
37 return 1;
38 } else if ((tprot(pfn * PAGE_SIZE) && pfn > 0))
39 return 1;
40 return 0;
41}
42
43void save_processor_state(void)
44{
45 /* swsusp_arch_suspend() actually saves all cpu register contents.
46 * Machine checks must be disabled since swsusp_arch_suspend() stores
47 * register contents to their lowcore save areas. That's the same
48 * place where register contents on machine checks would be saved.
49 * To avoid register corruption disable machine checks.
50 * We must also disable machine checks in the new psw mask for
51 * program checks, since swsusp_arch_suspend() may generate program
52 * checks. Disabling machine checks for all other new psw masks is
53 * just paranoia.
54 */
55 local_mcck_disable();
56 /* Disable lowcore protection */
57 __ctl_clear_bit(0,28);
58 S390_lowcore.external_new_psw.mask &= ~PSW_MASK_MCHECK;
59 S390_lowcore.svc_new_psw.mask &= ~PSW_MASK_MCHECK;
60 S390_lowcore.io_new_psw.mask &= ~PSW_MASK_MCHECK;
61 S390_lowcore.program_new_psw.mask &= ~PSW_MASK_MCHECK;
62}
63
64void restore_processor_state(void)
65{
66 S390_lowcore.external_new_psw.mask |= PSW_MASK_MCHECK;
67 S390_lowcore.svc_new_psw.mask |= PSW_MASK_MCHECK;
68 S390_lowcore.io_new_psw.mask |= PSW_MASK_MCHECK;
69 S390_lowcore.program_new_psw.mask |= PSW_MASK_MCHECK;
70 /* Enable lowcore protection */
71 __ctl_set_bit(0,28);
72 local_mcck_enable();
73}