| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 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 |  | 
| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 9 | #include <linux/pfn.h> | 
| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 10 | #include <asm/system.h> | 
| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 11 |  | 
 | 12 | /* | 
 | 13 |  * References to section boundaries | 
 | 14 |  */ | 
 | 15 | extern const void __nosave_begin, __nosave_end; | 
 | 16 |  | 
| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 17 | int pfn_is_nosave(unsigned long pfn) | 
 | 18 | { | 
| Heiko Carstens | 2573a57 | 2009-09-22 22:58:50 +0200 | [diff] [blame] | 19 | 	unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin)); | 
 | 20 | 	unsigned long nosave_end_pfn = PFN_DOWN(__pa(&__nosave_end)); | 
| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 21 |  | 
| Heiko Carstens | 2573a57 | 2009-09-22 22:58:50 +0200 | [diff] [blame] | 22 | 	/* Always save lowcore pages (LC protection might be enabled). */ | 
 | 23 | 	if (pfn <= LC_PAGES) | 
 | 24 | 		return 0; | 
| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 25 | 	if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn) | 
 | 26 | 		return 1; | 
| Heiko Carstens | 2573a57 | 2009-09-22 22:58:50 +0200 | [diff] [blame] | 27 | 	/* Skip memory holes and read-only pages (NSS, DCSS, ...). */ | 
 | 28 | 	if (tprot(PFN_PHYS(pfn))) | 
| Heiko Carstens | c48ff64 | 2009-09-11 10:28:37 +0200 | [diff] [blame] | 29 | 		return 1; | 
 | 30 | 	return 0; | 
 | 31 | } | 
 | 32 |  | 
 | 33 | void save_processor_state(void) | 
 | 34 | { | 
 | 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. | 
 | 44 | 	 */ | 
 | 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; | 
 | 52 | } | 
 | 53 |  | 
 | 54 | void restore_processor_state(void) | 
 | 55 | { | 
 | 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(); | 
 | 63 | } |