From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 2/2] xen/arm: support compressed kernels Date: Wed, 12 Aug 2015 17:35:42 +0100 Message-ID: <55CB75DE.1090102@citrix.com> References: <1439390875-21256-2-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1439390875-21256-2-git-send-email-stefano.stabellini@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini , xen-devel@lists.xensource.com Cc: julien.grall@citrix.com, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org On 12/08/15 15:47, Stefano Stabellini wrote: > Signed-off-by: Stefano Stabellini > CC: julien.grall@citrix.com > CC: ian.campbell@citrix.com > --- > xen/arch/arm/kernel.c | 36 ++++++++++++++++++++++++++++++++++++ > xen/common/Makefile | 2 +- > xen/include/asm-arm/byteorder.h | 2 ++ > 3 files changed, 39 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c > index f641b12..ca50cdd 100644 > --- a/xen/arch/arm/kernel.c > +++ b/xen/arch/arm/kernel.c > @@ -13,6 +13,8 @@ > #include > #include > #include > +#include > +#include > > #include "kernel.h" > > @@ -310,6 +312,38 @@ static int kernel_zimage64_probe(struct kernel_info *info, > > return 0; > } > + > +static int kernel_zimage64_compressed_probe(struct kernel_info *info, > + paddr_t addr, paddr_t size) > +{ > + char *output, *input; > + unsigned char magic[2]; > + int rc; > + unsigned kernel_order_in; > + unsigned kernel_order_out; > + paddr_t output_size; > + > + copy_from_paddr(magic, addr, sizeof(magic)); Need a size check before assuming sufficient length. (All of the arm probe functions suffer in a similar way.) > + > + if (!((magic[0] == 0x1f) && ((magic[1] == 0x8b) || (magic[1] == 0x9e)))) > + return -EINVAL; > + > + kernel_order_in = get_order_from_bytes(size); > + input = (char *)ioremap_cache(addr, size); > + > + output_size = output_length(input, size); > + kernel_order_out = get_order_from_bytes(output_size); > + output = (char *)alloc_xenheap_pages(kernel_order_out, 0); > + > + rc = decompress(input, size, output); > + clean_dcache_va_range(output, output_size); > + iounmap(input); > + > + if (rc != 0) Xen style. ~Andrew