From: Julien Grall <julien.grall@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
xen-devel@lists.xensource.com
Cc: Ian.Campbell@citrix.com
Subject: Re: [PATCH v2 2/2] xen/arm: support gzip compressed kernels
Date: Thu, 13 Aug 2015 12:35:18 +0100 [thread overview]
Message-ID: <55CC80F6.3030307@citrix.com> (raw)
In-Reply-To: <1439464897-32609-2-git-send-email-stefano.stabellini@eu.citrix.com>
Hi Stefano,
On 13/08/15 12:21, Stefano Stabellini wrote:
> +static int kernel_decompress(struct kernel_info *info,
> + paddr_t *addr, paddr_t *size)
> +{
> + char *output, *input;
> + char magic[2];
> + int rc;
> + unsigned kernel_order_in;
> + unsigned kernel_order_out;
> + paddr_t output_size;
> +
Please check that the binary is not too small before reading the magic.
> + copy_from_paddr(magic, *addr, sizeof(magic));
> +
> + /* only gzip is supported */
> + if (!gzip_check(magic, *size))
> + return 0;
> +
> + kernel_order_in = get_order_from_bytes(*size);
> + input = ioremap_cache(*addr, *size);
The return of ioremap_cache should be check.
> +
> + output_size = output_length(input, *size);
> + kernel_order_out = get_order_from_bytes(output_size);
> + output = alloc_xenheap_pages(kernel_order_out, 0);
Ditto.
> +
> + rc = perform_gunzip(output, input, *size);
> + clean_dcache_va_range(output, output_size);
> + iounmap(input);
> +
> + *addr = virt_to_maddr(output);
> + *size = output_size;
> + return 1;
> +}
> +
> #ifdef CONFIG_ARM_64
> /*
> * Check if the image is a 64-bit Image.
> @@ -463,6 +502,15 @@ int kernel_probe(struct kernel_info *info)
> printk("Loading ramdisk from boot module @ %"PRIpaddr"\n",
> info->initrd_bootmodule->start);
>
> + if (kernel_decompress(info, &start, &size) > 0)
> + {
> + /* Free the original kernel, update the pointers to the
> + * decompressed kernel */
> + dt_unreserved_regions(mod->start, mod->start + mod->size,
> + init_domheap_pages, 0);
> + mod->start = start;
> + mod->size = size;
I'm not sure to see how this would work. Any call to alloc_xenheap_pages
should be follow by a called to free_xenheap_pages.
But when freeing the modules, we are using init_heap_pages.
I don't think they are similar.
Furthermore, you may allocate more memory than necessary because you are
using an order but you never update the size. So we would have memory
loose forever.
Regards,
--
Julien Grall
next prev parent reply other threads:[~2015-08-13 11:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 11:19 [PATCH v2 0/2] support gzipped kernels on arm Stefano Stabellini
2015-08-13 11:21 ` [PATCH v2 1/2] xen: move perform_gunzip to common Stefano Stabellini
2015-08-13 12:21 ` Jan Beulich
2015-09-01 13:56 ` Stefano Stabellini
2015-09-01 14:10 ` Jan Beulich
2015-08-13 11:21 ` [PATCH v2 2/2] xen/arm: support gzip compressed kernels Stefano Stabellini
2015-08-13 11:35 ` Julien Grall [this message]
2015-09-01 14:57 ` Stefano Stabellini
2015-09-01 15:07 ` Ian Campbell
2015-09-02 11:26 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55CC80F6.3030307@citrix.com \
--to=julien.grall@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).