@@ -80,38 +80,20 @@ void machine_kexec(struct kimage *image)
8080}
8181
8282#ifdef CONFIG_CRASH_RESERVE
83- void __init reserve_crashkernel (void )
84- {
85- unsigned long long crash_size , crash_base , total_mem_sz ;
86- int ret ;
8783
88- total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size ();
89- /* use common parsing */
90- ret = parse_crashkernel (boot_command_line , total_mem_sz ,
91- & crash_size , & crash_base , NULL , NULL );
92- if (ret == 0 && crash_size > 0 ) {
93- crashk_res .start = crash_base ;
94- crashk_res .end = crash_base + crash_size - 1 ;
95- }
96-
97- if (crashk_res .end == crashk_res .start ) {
98- crashk_res .start = crashk_res .end = 0 ;
99- return ;
100- }
101-
102- /* We might have got these values via the command line or the
103- * device tree, either way sanitise them now. */
104-
105- crash_size = resource_size (& crashk_res );
84+ static unsigned long long __init get_crash_base (unsigned long long crash_base )
85+ {
10686
10787#ifndef CONFIG_NONSTATIC_KERNEL
108- if (crashk_res . start != KDUMP_KERNELBASE )
88+ if (crash_base != KDUMP_KERNELBASE )
10989 printk ("Crash kernel location must be 0x%x\n" ,
11090 KDUMP_KERNELBASE );
11191
112- crashk_res . start = KDUMP_KERNELBASE ;
92+ return KDUMP_KERNELBASE ;
11393#else
114- if (!crashk_res .start ) {
94+ unsigned long long crash_base_align ;
95+
96+ if (!crash_base ) {
11597#ifdef CONFIG_PPC64
11698 /*
11799 * On the LPAR platform place the crash kernel to mid of
@@ -123,53 +105,51 @@ void __init reserve_crashkernel(void)
123105 * kernel starts at 128MB offset on other platforms.
124106 */
125107 if (firmware_has_feature (FW_FEATURE_LPAR ))
126- crashk_res . start = min_t (u64 , ppc64_rma_size / 2 , SZ_512M );
108+ crash_base = min_t (u64 , ppc64_rma_size / 2 , SZ_512M );
127109 else
128- crashk_res . start = min_t (u64 , ppc64_rma_size / 2 , SZ_128M );
110+ crash_base = min_t (u64 , ppc64_rma_size / 2 , SZ_128M );
129111#else
130- crashk_res . start = KDUMP_KERNELBASE ;
112+ crash_base = KDUMP_KERNELBASE ;
131113#endif
132114 }
133115
134- crash_base = PAGE_ALIGN (crashk_res .start );
135- if (crash_base != crashk_res .start ) {
136- printk ("Crash kernel base must be aligned to 0x%lx\n" ,
137- PAGE_SIZE );
138- crashk_res .start = crash_base ;
139- }
116+ crash_base_align = PAGE_ALIGN (crash_base );
117+ if (crash_base != crash_base_align )
118+ pr_warn ("Crash kernel base must be aligned to 0x%lx\n" , PAGE_SIZE );
140119
120+ return crash_base_align ;
141121#endif
142- crash_size = PAGE_ALIGN (crash_size );
143- crashk_res .end = crashk_res .start + crash_size - 1 ;
122+ }
144123
145- /* The crash region must not overlap the current kernel */
146- if (overlaps_crashkernel (__pa (_stext ), _end - _stext )) {
147- printk (KERN_WARNING
148- "Crash kernel can not overlap current kernel\n" );
149- crashk_res .start = crashk_res .end = 0 ;
124+ void __init arch_reserve_crashkernel (void )
125+ {
126+ unsigned long long crash_size , crash_base , crash_end ;
127+ unsigned long long kernel_start , kernel_size ;
128+ unsigned long long total_mem_sz ;
129+ int ret ;
130+
131+ total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size ();
132+
133+ /* use common parsing */
134+ ret = parse_crashkernel (boot_command_line , total_mem_sz , & crash_size ,
135+ & crash_base , NULL , NULL );
136+
137+ if (ret )
150138 return ;
151- }
152139
153- /* Crash kernel trumps memory limit */
154- if (memory_limit && memory_limit <= crashk_res .end ) {
155- memory_limit = crashk_res .end + 1 ;
156- total_mem_sz = memory_limit ;
157- printk ("Adjusted memory limit for crashkernel, now 0x%llx\n" ,
158- memory_limit );
159- }
140+ crash_base = get_crash_base (crash_base );
141+ crash_end = crash_base + crash_size - 1 ;
160142
161- printk (KERN_INFO "Reserving %ldMB of memory at %ldMB "
162- "for crashkernel (System RAM: %ldMB)\n" ,
163- (unsigned long )(crash_size >> 20 ),
164- (unsigned long )(crashk_res .start >> 20 ),
165- (unsigned long )(total_mem_sz >> 20 ));
143+ kernel_start = __pa (_stext );
144+ kernel_size = _end - _stext ;
166145
167- if (!memblock_is_region_memory (crashk_res .start , crash_size ) ||
168- memblock_reserve (crashk_res .start , crash_size )) {
169- pr_err ("Failed to reserve memory for crashkernel!\n" );
170- crashk_res .start = crashk_res .end = 0 ;
146+ /* The crash region must not overlap the current kernel */
147+ if ((kernel_start + kernel_size > crash_base ) && (kernel_start <= crash_end )) {
148+ pr_warn ("Crash kernel can not overlap current kernel\n" );
171149 return ;
172150 }
151+
152+ reserve_crashkernel_generic (crash_size , crash_base , 0 , false);
173153}
174154
175155int __init overlaps_crashkernel (unsigned long start , unsigned long size )
0 commit comments