Root/arch/s390/kernel/suspend.c

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/pfn.h>
10#include <asm/system.h>
11
12/*
13 * References to section boundaries
14 */
15extern const void __nosave_begin, __nosave_end;
16
17int pfn_is_nosave(unsigned long pfn)
18{
19    unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin));
20    unsigned long nosave_end_pfn = PFN_DOWN(__pa(&__nosave_end));
21
22    /* Always save lowcore pages (LC protection might be enabled). */
23    if (pfn <= LC_PAGES)
24        return 0;
25    if (pfn >= nosave_begin_pfn && pfn < nosave_end_pfn)
26        return 1;
27    /* Skip memory holes and read-only pages (NSS, DCSS, ...). */
28    if (tprot(PFN_PHYS(pfn)))
29        return 1;
30    return 0;
31}
32
33void 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
54void 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}
64

Archive Download this file



interactive