xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, xen-devel@lists.xen.org
Subject: Re: [PATCH v3 03/15] xen: arm: support for loading 64-bit zImage dom0
Date: Fri, 19 Jul 2013 14:30:24 +0100	[thread overview]
Message-ID: <51E93F70.9020905@linaro.org> (raw)
In-Reply-To: <1374234284-6304-3-git-send-email-ian.campbell@citrix.com>

On 07/19/2013 12:44 PM, Ian Campbell wrote:
> This is defined in linux/Documentation/arm64/booting.txt.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>  xen/arch/arm/kernel.c |   80 +++++++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 75 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
> index 641b1f0..f6ff294 100644
> --- a/xen/arch/arm/kernel.c
> +++ b/xen/arch/arm/kernel.c
> @@ -27,6 +27,8 @@
>  
>  #define ZIMAGE32_MAGIC 0x016f2818
>  
> +#define ZIMAGE64_MAGIC 0x14000008
> +
>  struct minimal_dtb_header {
>      uint32_t magic;
>      uint32_t total_size;
> @@ -115,6 +117,57 @@ static void kernel_zimage_load(struct kernel_info *info)
>      }
>  }
>  
> +#ifdef CONFIG_ARM_64
> +/*
> + * Check if the image is a 64-bit zImage and setup kernel_info
> + */
> +static int kernel_try_zimage64_prepare(struct kernel_info *info,
> +                                     paddr_t addr, paddr_t size)
> +{
> +    /* linux/Documentation/arm64/booting.txt */
> +    struct {
> +        uint32_t magic;
> +        uint32_t res0;
> +        uint64_t text_offset;  /* Image load offset */
> +        uint64_t res1;
> +        uint64_t res2;
> +    } zimage;
> +    uint64_t start, end;
> +
> +    if ( size < sizeof(zimage) )
> +        return -EINVAL;
> +
> +    copy_from_paddr(&zimage, addr, sizeof(zimage), DEV_SHARED);
> +
> +    if (zimage.magic != ZIMAGE64_MAGIC)
> +        return -EINVAL;
> +
> +    /* Currently there is no length in the header, so just use the size */
> +    start = 0;
> +    end = size;
> +
> +    /*
> +     * Given the above this check is a bit pointless, but leave it
> +     * here in case someone adds a length field in the future.
> +     */
> +    if ( (end - start) > size )
> +        return -EINVAL;
> +
> +    info->zimage.kernel_addr = addr;
> +
> +    info->zimage.load_addr = info->mem.bank[0].start
> +        + zimage.text_offset;
> +    info->zimage.len = end - start;
> +
> +    info->entry = info->zimage.load_addr;
> +    info->load = kernel_zimage_load;

Could you fill check_overlap callback? For this purpose, you can reuse
kernel_zimage_check_overlap.

> +    info->type = DOMAIN_PV64;
> +
> +    return 0;
> +}
> +#endif
> +
>  /*
>   * Check if the image is a 32-bit zImage and setup kernel_info
>   */
> @@ -170,6 +223,10 @@ static int kernel_try_zimage32_prepare(struct kernel_info *info,
>      info->load = kernel_zimage_load;
>      info->check_overlap = kernel_zimage_check_overlap;
>  
> +#ifdef CONFIG_ARM_64
> +    info->type = DOMAIN_PV32;
> +#endif
> +
>      return 0;
>  }
>  
> @@ -208,6 +265,19 @@ static int kernel_try_elf_prepare(struct kernel_info *info,
>      if ( (rc = elf_xen_parse(&info->elf.elf, &info->elf.parms)) != 0 )
>          goto err;
>  
> +#ifdef CONFIG_ARM_64
> +    if ( elf_32bit(&info->elf.elf) )
> +        info->type = DOMAIN_PV32;
> +    else if ( elf_64bit(&info->elf.elf) )
> +        info->type = DOMAIN_PV64;
> +    else
> +    {
> +        printk("Unknown ELF class\n");
> +        rc = -EINVAL;
> +        goto err;
> +    }
> +#endif
> +
>      /*
>       * TODO: can the ELF header be used to find the physical address
>       * to load the image to?  Instead of assuming virt == phys.
> @@ -254,13 +324,13 @@ int kernel_prepare(struct kernel_info *info)
>          info->load_attr = BUFFERABLE;
>      }
>  
> -    rc = kernel_try_zimage32_prepare(info, start, size);
> -    if (rc < 0)
> -        rc = kernel_try_elf_prepare(info, start, size);
> -
>  #ifdef CONFIG_ARM_64
> -    info->type = DOMAIN_PV32; /* No 64-bit guest support yet */
> +    rc = kernel_try_zimage64_prepare(info, start, size);
> +    if (rc < 0)
>  #endif
> +        rc = kernel_try_zimage32_prepare(info, start, size);
> +    if (rc < 0)
> +        rc = kernel_try_elf_prepare(info, start, size);
>  
>      return rc;
>  }
> 

  reply	other threads:[~2013-07-19 13:30 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 11:44 [PATCH v3 00/15] xen: arm: 64-bit dom0 kernel support Ian Campbell
2013-07-19 11:44 ` [PATCH v3 01/15] xen: arm: tweak arm64 stack frame layout Ian Campbell
2013-07-19 11:44 ` [PATCH v3 02/15] xen: arm: rename 32-bit specific zImage field offset constants Ian Campbell
2013-07-19 11:44 ` [PATCH v3 03/15] xen: arm: support for loading 64-bit zImage dom0 Ian Campbell
2013-07-19 13:30   ` Julien Grall [this message]
2013-07-19 13:39     ` Ian Campbell
2013-07-19 11:44 ` [PATCH v3 04/15] xen: arm: support building a 64-bit dom0 domain Ian Campbell
2013-07-19 12:59   ` Konrad Rzeszutek Wilk
2013-07-19 13:42     ` Ian Campbell
2013-07-19 11:44 ` [PATCH v3 05/15] xen: arm: precalculate VTTBR_EL2 for a domain when setting up its p2m Ian Campbell
2013-07-19 11:44 ` [PATCH v3 06/15] xen: arm: improve register dump output for 64-bit guest (and more generally too) Ian Campbell
2013-07-19 11:44 ` [PATCH v3 07/15] xen: arm: support dumping 64-bit guest stack Ian Campbell
2013-07-19 11:44 ` [PATCH v3 08/15] xen: arm: show less words in a line of a stack trace in 64-bit builds Ian Campbell
2013-07-19 11:44 ` [PATCH v3 09/15] xen: arm: Set EL1 register width in HCR_EL2 during context switch Ian Campbell
2013-07-22 10:44   ` Stefano Stabellini
2013-07-19 11:44 ` [PATCH v3 10/15] xen: arm: handle traps from 64-bit guests Ian Campbell
2013-07-24 11:30   ` Stefano Stabellini
2013-07-24 17:50     ` Ian Campbell
2013-07-19 11:44 ` [PATCH v3 11/15] xen: arm: handle hypercalls " Ian Campbell
2013-07-19 11:44 ` [PATCH v3 12/15] xen: arm: handle 64-bit system register access traps Ian Campbell
2013-07-19 11:44 ` [PATCH v3 13/15] xen: arm: align some comments Ian Campbell
2013-07-19 11:44 ` [PATCH v3 14/15] xen: arm: document HCR bits Ian Campbell
2013-07-19 13:35   ` Julien Grall
2013-07-19 11:44 ` [PATCH v3 15/15] xen: arm: Handle SMC from 64-bit guests Ian Campbell
2013-07-22 21:33 ` [PATCH v3 00/15] xen: arm: 64-bit dom0 kernel support Ian Campbell

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=51E93F70.9020905@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /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).