suspend.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include <linux/pfn.h>
  9. #include <asm/system.h>
  10. /*
  11. * References to section boundaries
  12. */
  13. extern const void __nosave_begin, __nosave_end;
  14. int pfn_is_nosave(unsigned long pfn)
  15. {
  16. unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin));
  17. unsigned long nosave_end_pfn = PFN_DOWN(__pa(&__nosave_end));
  18. /* Always save lowcore pages (LC protection might be enabled). */
  19. if (pfn <= LC_PAGES)
  20. return 0;
  21. if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn)
  22. return 1;
  23. /* Skip memory holes and read-only pages (NSS, DCSS, ...). */
  24. if (tprot(PFN_PHYS(pfn)))
  25. return 1;
  26. return 0;
  27. }
  28. void save_processor_state(void)
  29. {
  30. /* swsusp_arch_suspend() actually saves all cpu register contents.
  31. * Machine checks must be disabled since swsusp_arch_suspend() stores
  32. * register contents to their lowcore save areas. That's the same
  33. * place where register contents on machine checks would be saved.
  34. * To avoid register corruption disable machine checks.
  35. * We must also disable machine checks in the new psw mask for
  36. * program checks, since swsusp_arch_suspend() may generate program
  37. * checks. Disabling machine checks for all other new psw masks is
  38. * just paranoia.
  39. */
  40. local_mcck_disable();
  41. /* Disable lowcore protection */
  42. __ctl_clear_bit(0,28);
  43. S390_lowcore.external_new_psw.mask &= ~PSW_MASK_MCHECK;
  44. S390_lowcore.svc_new_psw.mask &= ~PSW_MASK_MCHECK;
  45. S390_lowcore.io_new_psw.mask &= ~PSW_MASK_MCHECK;
  46. S390_lowcore.program_new_psw.mask &= ~PSW_MASK_MCHECK;
  47. }
  48. void restore_processor_state(void)
  49. {
  50. S390_lowcore.external_new_psw.mask |= PSW_MASK_MCHECK;
  51. S390_lowcore.svc_new_psw.mask |= PSW_MASK_MCHECK;
  52. S390_lowcore.io_new_psw.mask |= PSW_MASK_MCHECK;
  53. S390_lowcore.program_new_psw.mask |= PSW_MASK_MCHECK;
  54. /* Enable lowcore protection */
  55. __ctl_set_bit(0,28);
  56. local_mcck_enable();
  57. }