fadump.c (a5a05b91c7f36c180c32e27fa41890957c31bad1) | fadump.c (68fa6478e3b1fab7077d390070ed455aed93905c) |
---|---|
1/* 2 * Firmware Assisted dump: A robust mechanism to get reliable kernel crash 3 * dump with assistance from firmware. This approach does not use kexec, 4 * instead firmware assists in booting the kdump kernel while preserving 5 * memory contents. The most of the code implementation has been adapted 6 * from phyp assisted dump implementation written by Linas Vepstas and 7 * Manish Ahuja 8 * --- 1138 unchanged lines hidden (view full) --- 1147 /* Invalidate the registration only if dump is active. */ 1148 if (fw_dump.dump_active) { 1149 init_fadump_mem_struct(&fdm, 1150 be64_to_cpu(fdm_active->cpu_state_data.destination_address)); 1151 fadump_invalidate_dump(&fdm); 1152 } 1153} 1154 | 1/* 2 * Firmware Assisted dump: A robust mechanism to get reliable kernel crash 3 * dump with assistance from firmware. This approach does not use kexec, 4 * instead firmware assists in booting the kdump kernel while preserving 5 * memory contents. The most of the code implementation has been adapted 6 * from phyp assisted dump implementation written by Linas Vepstas and 7 * Manish Ahuja 8 * --- 1138 unchanged lines hidden (view full) --- 1147 /* Invalidate the registration only if dump is active. */ 1148 if (fw_dump.dump_active) { 1149 init_fadump_mem_struct(&fdm, 1150 be64_to_cpu(fdm_active->cpu_state_data.destination_address)); 1151 fadump_invalidate_dump(&fdm); 1152 } 1153} 1154 |
1155static void fadump_free_reserved_memory(unsigned long start_pfn, 1156 unsigned long end_pfn) 1157{ 1158 unsigned long pfn; 1159 unsigned long time_limit = jiffies + HZ; 1160 1161 pr_info("freeing reserved memory (0x%llx - 0x%llx)\n", 1162 PFN_PHYS(start_pfn), PFN_PHYS(end_pfn)); 1163 1164 for (pfn = start_pfn; pfn < end_pfn; pfn++) { 1165 free_reserved_page(pfn_to_page(pfn)); 1166 1167 if (time_after(jiffies, time_limit)) { 1168 cond_resched(); 1169 time_limit = jiffies + HZ; 1170 } 1171 } 1172} 1173 |
|
1155/* | 1174/* |
1175 * Skip memory holes and free memory that was actually reserved. 1176 */ 1177static void fadump_release_reserved_area(unsigned long start, unsigned long end) 1178{ 1179 struct memblock_region *reg; 1180 unsigned long tstart, tend; 1181 unsigned long start_pfn = PHYS_PFN(start); 1182 unsigned long end_pfn = PHYS_PFN(end); 1183 1184 for_each_memblock(memory, reg) { 1185 tstart = max(start_pfn, memblock_region_memory_base_pfn(reg)); 1186 tend = min(end_pfn, memblock_region_memory_end_pfn(reg)); 1187 if (tstart < tend) { 1188 fadump_free_reserved_memory(tstart, tend); 1189 1190 if (tend == end_pfn) 1191 break; 1192 1193 start_pfn = tend + 1; 1194 } 1195 } 1196} 1197 1198/* |
|
1156 * Release the memory that was reserved in early boot to preserve the memory 1157 * contents. The released memory will be available for general use. 1158 */ 1159static void fadump_release_memory(unsigned long begin, unsigned long end) 1160{ | 1199 * Release the memory that was reserved in early boot to preserve the memory 1200 * contents. The released memory will be available for general use. 1201 */ 1202static void fadump_release_memory(unsigned long begin, unsigned long end) 1203{ |
1161 unsigned long addr; | |
1162 unsigned long ra_start, ra_end; 1163 1164 ra_start = fw_dump.reserve_dump_area_start; 1165 ra_end = ra_start + fw_dump.reserve_dump_area_size; 1166 | 1204 unsigned long ra_start, ra_end; 1205 1206 ra_start = fw_dump.reserve_dump_area_start; 1207 ra_end = ra_start + fw_dump.reserve_dump_area_size; 1208 |
1167 for (addr = begin; addr < end; addr += PAGE_SIZE) { 1168 /* 1169 * exclude the dump reserve area. Will reuse it for next 1170 * fadump registration. 1171 */ 1172 if (addr <= ra_end && ((addr + PAGE_SIZE) > ra_start)) 1173 continue; 1174 1175 free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT)); 1176 } | 1209 /* 1210 * exclude the dump reserve area. Will reuse it for next 1211 * fadump registration. 1212 */ 1213 if (begin < ra_end && end > ra_start) { 1214 if (begin < ra_start) 1215 fadump_release_reserved_area(begin, ra_start); 1216 if (end > ra_end) 1217 fadump_release_reserved_area(ra_end, end); 1218 } else 1219 fadump_release_reserved_area(begin, end); |
1177} 1178 1179static void fadump_invalidate_release_mem(void) 1180{ 1181 unsigned long reserved_area_start, reserved_area_end; 1182 unsigned long destination_address; 1183 1184 mutex_lock(&fadump_mutex); --- 257 unchanged lines hidden --- | 1220} 1221 1222static void fadump_invalidate_release_mem(void) 1223{ 1224 unsigned long reserved_area_start, reserved_area_end; 1225 unsigned long destination_address; 1226 1227 mutex_lock(&fadump_mutex); --- 257 unchanged lines hidden --- |