Re: [PATCH v6 08/17] arm64: hibernate: add trans_pgd public functions
flat view
From: Pavel Tatashin <pasha.tatashin@soleen.com>
Date: 2019-10-14 15:34:24
Also in:
kexec, linux-mm, lkml
quoted
+ + memcpy(page, src_start, length); + __flush_icache_range((unsigned long)page, (unsigned long)page + length); + + trans_pgd = (void *)get_safe_page(GFP_ATOMIC); + if (!trans_pgd) + return -ENOMEM; + + rc = trans_pgd_map_page(trans_pgd, page, dst_addr, + PAGE_KERNEL_EXEC); + if (rc) + return rc; + /* * Load our new page tables. A strict BBM approach requires that we * ensure that TLBs are free of any entries that may overlap with the(I suspect you are going to to duplicate this in the kexec code. Kexec has the same pattern: instructions that have to be copied to do the relocation of the rest of memory)
Yes, the relocation function is also copied, but I do not see an easy way to unify this particular code with kexec. We can discuss in kexec part of this series what else can be unified with hibernate's code.
quoted
@@ -462,6 +476,24 @@ static int copy_page_tables(pgd_t *dst_pgdp, unsigned long start,quoted
+int trans_pgd_create_copy(pgd_t **dst_pgdp, unsigned long start, + unsigned long end) +{ + int rc; + pgd_t *trans_pgd = (pgd_t *)get_safe_page(GFP_ATOMIC); + + if (!trans_pgd) { + pr_err("Failed to allocate memory for temporary page tables.\n"); + return -ENOMEM; + } + + rc = copy_page_tables(trans_pgd, start, end); + if (!rc) + *dst_pgdp = trans_pgd;*dst_pgdp was already allocated in swsusp_arch_resume().
Good catch, I forgot to remove allocation from swsusp_arch_resume().
quoted
+ + return rc; +} + /* * Setup then Resume from the hibernate image using swsusp_arch_suspend_exit(). *@@ -488,7 +520,7 @@ int swsusp_arch_resume(void) pr_err("Failed to allocate memory for temporary page tables.\n"); return -ENOMEM; }If the allocation moves into 'trans_pgd_create_copy()', please move the code just above here (cut off by the diff) that allocates it in swsusp_arch_resume(). Its actually okay to leak memory like this, hibernate's allocator acts as a memory pool. It either gets freed if we fail to resume, or vanishes when the resumed kernel takes over.
I did.
Reviewed-by: James Morse <james.morse@arm.com>
Thank you, Pasha _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel