~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/power/hibernate_32.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/power/hibernate_32.c (Architecture alpha) and /arch/i386/power/hibernate_32.c (Architecture i386)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * Hibernation support specific for i386 - tem    
  4  *                                                
  5  * Copyright (c) 2006 Rafael J. Wysocki <rjw@s    
  6  */                                               
  7                                                   
  8 #include <linux/gfp.h>                            
  9 #include <linux/suspend.h>                        
 10 #include <linux/memblock.h>                       
 11 #include <linux/pgtable.h>                        
 12                                                   
 13 #include <asm/page.h>                             
 14 #include <asm/mmzone.h>                           
 15 #include <asm/sections.h>                         
 16 #include <asm/suspend.h>                          
 17                                                   
 18 /* Pointer to the temporary resume page tables    
 19 pgd_t *resume_pg_dir;                             
 20                                                   
 21 /* The following three functions are based on     
 22  * arch/x86/mm/init_32.c                          
 23  */                                               
 24                                                   
 25 /*                                                
 26  * Create a middle page table on a resume-safe    
 27  * the given global directory entry.  This onl    
 28  * in non-PAE compilation mode, since the midd    
 29  */                                               
 30 static pmd_t *resume_one_md_table_init(pgd_t *    
 31 {                                                 
 32         p4d_t *p4d;                               
 33         pud_t *pud;                               
 34         pmd_t *pmd_table;                         
 35                                                   
 36 #ifdef CONFIG_X86_PAE                             
 37         pmd_table = (pmd_t *)get_safe_page(GFP    
 38         if (!pmd_table)                           
 39                 return NULL;                      
 40                                                   
 41         set_pgd(pgd, __pgd(__pa(pmd_table) | _    
 42         p4d = p4d_offset(pgd, 0);                 
 43         pud = pud_offset(p4d, 0);                 
 44                                                   
 45         BUG_ON(pmd_table != pmd_offset(pud, 0)    
 46 #else                                             
 47         p4d = p4d_offset(pgd, 0);                 
 48         pud = pud_offset(p4d, 0);                 
 49         pmd_table = pmd_offset(pud, 0);           
 50 #endif                                            
 51                                                   
 52         return pmd_table;                         
 53 }                                                 
 54                                                   
 55 /*                                                
 56  * Create a page table on a resume-safe page a    
 57  * a middle page directory entry.                 
 58  */                                               
 59 static pte_t *resume_one_page_table_init(pmd_t    
 60 {                                                 
 61         if (pmd_none(*pmd)) {                     
 62                 pte_t *page_table = (pte_t *)g    
 63                 if (!page_table)                  
 64                         return NULL;              
 65                                                   
 66                 set_pmd(pmd, __pmd(__pa(page_t    
 67                                                   
 68                 BUG_ON(page_table != pte_offse    
 69                                                   
 70                 return page_table;                
 71         }                                         
 72                                                   
 73         return pte_offset_kernel(pmd, 0);         
 74 }                                                 
 75                                                   
 76 /*                                                
 77  * This maps the physical memory to kernel vir    
 78  * of max_low_pfn pages, by creating page tabl    
 79  * PAGE_OFFSET.  The page tables are allocated    
 80  */                                               
 81 static int resume_physical_mapping_init(pgd_t     
 82 {                                                 
 83         unsigned long pfn;                        
 84         pgd_t *pgd;                               
 85         pmd_t *pmd;                               
 86         pte_t *pte;                               
 87         int pgd_idx, pmd_idx;                     
 88                                                   
 89         pgd_idx = pgd_index(PAGE_OFFSET);         
 90         pgd = pgd_base + pgd_idx;                 
 91         pfn = 0;                                  
 92                                                   
 93         for (; pgd_idx < PTRS_PER_PGD; pgd++,     
 94                 pmd = resume_one_md_table_init    
 95                 if (!pmd)                         
 96                         return -ENOMEM;           
 97                                                   
 98                 if (pfn >= max_low_pfn)           
 99                         continue;                 
100                                                   
101                 for (pmd_idx = 0; pmd_idx < PT    
102                         if (pfn >= max_low_pfn    
103                                 break;            
104                                                   
105                         /* Map with big pages     
106                          * normal page tables.    
107                          * NOTE: We can mark e    
108                          */                       
109                         if (boot_cpu_has(X86_F    
110                                 set_pmd(pmd, p    
111                                 pfn += PTRS_PE    
112                         } else {                  
113                                 pte_t *max_pte    
114                                                   
115                                 pte = resume_o    
116                                 if (!pte)         
117                                         return    
118                                                   
119                                 max_pte = pte     
120                                 for (; pte < m    
121                                         if (pf    
122                                                   
123                                                   
124                                         set_pt    
125                                 }                 
126                         }                         
127                 }                                 
128         }                                         
129                                                   
130         return 0;                                 
131 }                                                 
132                                                   
133 static inline void resume_init_first_level_pag    
134 {                                                 
135 #ifdef CONFIG_X86_PAE                             
136         int i;                                    
137                                                   
138         /* Init entries of the first-level pag    
139         for (i = 0; i < PTRS_PER_PGD; i++)        
140                 set_pgd(pg_dir + i,               
141                         __pgd(__pa(empty_zero_    
142 #endif                                            
143 }                                                 
144                                                   
145 static int set_up_temporary_text_mapping(pgd_t    
146 {                                                 
147         pgd_t *pgd;                               
148         pmd_t *pmd;                               
149         pte_t *pte;                               
150                                                   
151         pgd = pgd_base + pgd_index(restore_jum    
152                                                   
153         pmd = resume_one_md_table_init(pgd);      
154         if (!pmd)                                 
155                 return -ENOMEM;                   
156                                                   
157         if (boot_cpu_has(X86_FEATURE_PSE)) {      
158                 set_pmd(pmd + pmd_index(restor    
159                 __pmd((jump_address_phys & PMD    
160         } else {                                  
161                 pte = resume_one_page_table_in    
162                 if (!pte)                         
163                         return -ENOMEM;           
164                 set_pte(pte + pte_index(restor    
165                 __pte((jump_address_phys & PAG    
166         }                                         
167                                                   
168         return 0;                                 
169 }                                                 
170                                                   
171 asmlinkage int swsusp_arch_resume(void)           
172 {                                                 
173         int error;                                
174                                                   
175         resume_pg_dir = (pgd_t *)get_safe_page    
176         if (!resume_pg_dir)                       
177                 return -ENOMEM;                   
178                                                   
179         resume_init_first_level_page_table(res    
180                                                   
181         error = set_up_temporary_text_mapping(    
182         if (error)                                
183                 return error;                     
184                                                   
185         error = resume_physical_mapping_init(r    
186         if (error)                                
187                 return error;                     
188                                                   
189         temp_pgt = __pa(resume_pg_dir);           
190                                                   
191         error = relocate_restore_code();          
192         if (error)                                
193                 return error;                     
194                                                   
195         /* We have got enough memory and from     
196         restore_image();                          
197         return 0;                                 
198 }                                                 
199                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php