lkml.org 
[lkml]   [2019]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 08/17] arm64: hibernate: add trans_pgd public functions
> > +
> > + 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.

>
> > @@ -462,6 +476,24 @@ static int copy_page_tables(pgd_t *dst_pgdp, unsigned long start,
>
> > +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().


> > +
> > + 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

\
 
 \ /
  Last update: 2019-10-14 17:35    [W:0.065 / U:0.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site