Commit | Line | Data |
---|---|---|
155af2f9 | 1 | /* |
c48ff644 | 2 | * Suspend support specific for s390. |
155af2f9 HJP |
3 | * |
4 | * Copyright IBM Corp. 2009 | |
5 | * | |
6 | * Author(s): Hans-Joachim Picht <hans@linux.vnet.ibm.com> | |
155af2f9 HJP |
7 | */ |
8 | ||
c48ff644 | 9 | #include <linux/pfn.h> |
c63b196a | 10 | #include <asm/system.h> |
c48ff644 HC |
11 | |
12 | /* | |
13 | * References to section boundaries | |
14 | */ | |
15 | extern const void __nosave_begin, __nosave_end; | |
16 | ||
c48ff644 HC |
17 | int pfn_is_nosave(unsigned long pfn) |
18 | { | |
2573a575 HC |
19 | unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin)); |
20 | unsigned long nosave_end_pfn = PFN_DOWN(__pa(&__nosave_end)); | |
c48ff644 | 21 | |
2573a575 HC |
22 | /* Always save lowcore pages (LC protection might be enabled). */ |
23 | if (pfn <= LC_PAGES) | |
24 | return 0; | |
c48ff644 HC |
25 | if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn) |
26 | return 1; | |
2573a575 HC |
27 | /* Skip memory holes and read-only pages (NSS, DCSS, ...). */ |
28 | if (tprot(PFN_PHYS(pfn))) | |
c48ff644 HC |
29 | return 1; |
30 | return 0; | |
31 | } | |
155af2f9 | 32 | |
155af2f9 HJP |
33 | void save_processor_state(void) |
34 | { | |
c63b196a HC |
35 | /* swsusp_arch_suspend() actually saves all cpu register contents. |
36 | * Machine checks must be disabled since swsusp_arch_suspend() stores | |
37 | * register contents to their lowcore save areas. That's the same | |
38 | * place where register contents on machine checks would be saved. | |
39 | * To avoid register corruption disable machine checks. | |
40 | * We must also disable machine checks in the new psw mask for | |
41 | * program checks, since swsusp_arch_suspend() may generate program | |
42 | * checks. Disabling machine checks for all other new psw masks is | |
43 | * just paranoia. | |
155af2f9 | 44 | */ |
c63b196a HC |
45 | local_mcck_disable(); |
46 | /* Disable lowcore protection */ | |
47 | __ctl_clear_bit(0,28); | |
48 | S390_lowcore.external_new_psw.mask &= ~PSW_MASK_MCHECK; | |
49 | S390_lowcore.svc_new_psw.mask &= ~PSW_MASK_MCHECK; | |
50 | S390_lowcore.io_new_psw.mask &= ~PSW_MASK_MCHECK; | |
51 | S390_lowcore.program_new_psw.mask &= ~PSW_MASK_MCHECK; | |
155af2f9 HJP |
52 | } |
53 | ||
155af2f9 HJP |
54 | void restore_processor_state(void) |
55 | { | |
c63b196a HC |
56 | S390_lowcore.external_new_psw.mask |= PSW_MASK_MCHECK; |
57 | S390_lowcore.svc_new_psw.mask |= PSW_MASK_MCHECK; | |
58 | S390_lowcore.io_new_psw.mask |= PSW_MASK_MCHECK; | |
59 | S390_lowcore.program_new_psw.mask |= PSW_MASK_MCHECK; | |
60 | /* Enable lowcore protection */ | |
61 | __ctl_set_bit(0,28); | |
62 | local_mcck_enable(); | |
155af2f9 | 63 | } |