Skip to content

Commit 0db6896

Browse files
maheshsalmpe
authored andcommitted
powerpc/fadump: Do not allow hot-remove memory from fadump reserved area.
For fadump to work successfully there should not be any holes in reserved memory ranges where kernel has asked firmware to move the content of old kernel memory in event of crash. Now that fadump uses CMA for reserved area, this memory area is now not protected from hot-remove operations unless it is cma allocated. Hence, fadump service can fail to re-register after the hot-remove operation, if hot-removed memory belongs to fadump reserved region. To avoid this make sure that memory from fadump reserved area is not hot-removable if fadump is registered. However, if user still wants to remove that memory, he can do so by manually stopping fadump service before hot-remove operation. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent f86593b commit 0db6896

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

arch/powerpc/include/asm/fadump.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ struct fad_crash_memory_ranges {
205205
unsigned long long size;
206206
};
207207

208-
extern int is_fadump_boot_memory_area(u64 addr, ulong size);
208+
extern int is_fadump_memory_area(u64 addr, ulong size);
209209
extern int early_init_dt_scan_fw_dump(unsigned long node,
210210
const char *uname, int depth, void *data);
211211
extern int fadump_reserve_mem(void);

arch/powerpc/kernel/fadump.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,19 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,
183183

184184
/*
185185
* If fadump is registered, check if the memory provided
186-
* falls within boot memory area.
186+
* falls within boot memory area and reserved memory area.
187187
*/
188-
int is_fadump_boot_memory_area(u64 addr, ulong size)
188+
int is_fadump_memory_area(u64 addr, ulong size)
189189
{
190+
u64 d_start = fw_dump.reserve_dump_area_start;
191+
u64 d_end = d_start + fw_dump.reserve_dump_area_size;
192+
190193
if (!fw_dump.dump_registered)
191194
return 0;
192195

196+
if (((addr + size) > d_start) && (addr <= d_end))
197+
return 1;
198+
193199
return (addr + size) > RMA_START && addr <= fw_dump.boot_memory_size;
194200
}
195201

arch/powerpc/platforms/pseries/hotplug-memory.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb)
353353
phys_addr = lmb->base_addr;
354354

355355
#ifdef CONFIG_FA_DUMP
356-
/* Don't hot-remove memory that falls in fadump boot memory area */
357-
if (is_fadump_boot_memory_area(phys_addr, block_sz))
356+
/*
357+
* Don't hot-remove memory that falls in fadump boot memory area
358+
* and memory that is reserved for capturing old kernel memory.
359+
*/
360+
if (is_fadump_memory_area(phys_addr, block_sz))
358361
return false;
359362
#endif
360363

0 commit comments

Comments
 (0)