Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Pratyush Anand <panand@redhat.com>
Cc: kexec@lists.infradead.org, kexec@lists.fedoraproject.org
Subject: Re: [PATCH RFC 5/6] arm64: Add support for binary image
Date: Mon, 20 Apr 2015 15:24:02 +0800	[thread overview]
Message-ID: <20150420072402.GG15033@dhcp-16-116.nay.redhat.com> (raw)
In-Reply-To: <0a15f2079e6c378996dceda1d509df77d2f43899.1429201849.git.panand@redhat.com>

On 04/16/15 at 10:17pm, Pratyush Anand wrote:
> This patch adds support to use binary image ie arch/arm64/boot/Image.
> 
> Binary image does not have sufficient knowledge to extract page offset
> information, which is needed by kexec tool. Use a new command parameter
> --page-offset, so that user can provide page offset information for
> liner mapping.
> 
> Signed-off-by: Pratyush Anand <panand@redhat.com>
> ---

Seems there's a function get_kernel_page_offset used to get page_offset
automatically in arm. arm64 should have it either.


>  kexec/arch/arm64/crashdump-arm64.h      |  1 +
>  kexec/arch/arm64/include/arch/options.h | 10 ++++--
>  kexec/arch/arm64/kexec-arm64.c          |  3 ++
>  kexec/arch/arm64/kexec-arm64.h          |  2 ++
>  kexec/arch/arm64/kexec-image-arm64.c    | 54 ++++++++++++++++++++++++++++++---
>  5 files changed, 63 insertions(+), 7 deletions(-)
> 
> diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
> index d4fd3f2288c9..d53fa34de37a 100644
> --- a/kexec/arch/arm64/crashdump-arm64.h
> +++ b/kexec/arch/arm64/crashdump-arm64.h
> @@ -17,6 +17,7 @@
>  #define CRASH_MAX_MEMORY_RANGES	32
>  
>  extern struct memory_ranges usablemem_rgns;
> +extern struct memory_range crash_reserved_mem;
>  
>  int load_crashdump_segments(struct kexec_info *info, char **option);
>  void modify_ehdr_for_crashmem(struct mem_ehdr *ehdr);
> diff --git a/kexec/arch/arm64/include/arch/options.h b/kexec/arch/arm64/include/arch/options.h
> index afe3e9827ff3..af14102220ea 100644
> --- a/kexec/arch/arm64/include/arch/options.h
> +++ b/kexec/arch/arm64/include/arch/options.h
> @@ -5,9 +5,10 @@
>  #define OPT_DTB		((OPT_MAX)+1)
>  #define OPT_INITRD	((OPT_MAX)+2)
>  #define OPT_LITE	((OPT_MAX)+3)
> -#define OPT_PORT	((OPT_MAX)+4)
> -#define OPT_REUSE_CMDLINE	((OPT_MAX+5))
> -#define OPT_ARCH_MAX	((OPT_MAX)+6)
> +#define OPT_PAGE_OFFSET	((OPT_MAX)+4)
> +#define OPT_PORT	((OPT_MAX)+5)
> +#define OPT_REUSE_CMDLINE	((OPT_MAX+6))
> +#define OPT_ARCH_MAX	((OPT_MAX)+7)
>  
>  #define KEXEC_ARCH_OPTIONS \
>  	KEXEC_OPTIONS \
> @@ -16,6 +17,7 @@
>  	{ "dtb",          1, NULL, OPT_DTB }, \
>  	{ "initrd",       1, NULL, OPT_INITRD }, \
>  	{ "lite",         0, NULL, OPT_LITE }, \
> +	{ "page-offset",  1, NULL, OPT_PAGE_OFFSET }, \
>  	{ "port",         1, NULL, OPT_PORT }, \
>  	{ "ramdisk",      1, NULL, OPT_INITRD }, \
>  	{ "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE }, \
> @@ -30,6 +32,7 @@ static const char arm64_opts_usage[] __attribute__ ((unused)) =
>  "     --dtb=FILE            Use FILE as the device tree blob.\n"
>  "     --initrd=FILE         Use FILE as the kernel initial ramdisk.\n"
>  "     --lite                Fast reboot, no memory integrity checks.\n"
> +"     --page-offset         Kernel page-offset for binary image load.\n"
>  "     --port=ADDRESS        Purgatory output to port ADDRESS.\n"
>  "     --ramdisk=FILE        Use FILE as the kernel initial ramdisk.\n"
>  "     --reuse-cmdline       Use command line arg of primary kernel.\n";
> @@ -38,6 +41,7 @@ struct arm64_opts {
>  	const char *command_line;
>  	const char *dtb;
>  	const char *initrd;
> +	uint64_t page_offset;
>  	uint64_t port;
>  	int lite;
>  };
> diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
> index 34e4ebf1eb23..190037c75186 100644
> --- a/kexec/arch/arm64/kexec-arm64.c
> +++ b/kexec/arch/arm64/kexec-arm64.c
> @@ -99,6 +99,9 @@ int arch_process_options(int argc, char **argv)
>  		case OPT_PORT:
>  			arm64_opts.port = strtoull(optarg, NULL, 0);
>  			break;
> +		case OPT_PAGE_OFFSET:
> +			arm64_opts.page_offset = strtoull(optarg, NULL, 0);
> +			break;
>  		default:
>  			break; /* Ignore core and unknown options. */
>  		}
> diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h
> index 61e15032cbd6..7e4d0568bd01 100644
> --- a/kexec/arch/arm64/kexec-arm64.h
> +++ b/kexec/arch/arm64/kexec-arm64.h
> @@ -17,6 +17,8 @@
>  #define BOOT_BLOCK_LAST_COMP_VERSION 16
>  #define COMMAND_LINE_SIZE 512
>  
> +#define ARM64_DEFAULT_PAGE_OFFSET 0xfffffe0000000000
> +
>  int elf_arm64_probe(const char *kernel_buf, off_t kernel_size);
>  int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
>  	off_t kernel_size, struct kexec_info *info);
> diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c
> index b025dc6c0185..2ce68293a37b 100644
> --- a/kexec/arch/arm64/kexec-image-arm64.c
> +++ b/kexec/arch/arm64/kexec-image-arm64.c
> @@ -8,7 +8,9 @@
>  #include <errno.h>
>  #include <getopt.h>
>  #include <libfdt.h>
> +#include <stdlib.h>
>  
> +#include "crashdump-arm64.h"
>  #include "dt-ops.h"
>  #include "image-header.h"
>  #include "kexec-arm64.h"
> @@ -31,15 +33,59 @@ int image_arm64_probe(const char *kernel_buf, off_t kernel_size)
>  	dbgprintf("%s: PE format: %s\n", __func__,
>  		(arm64_header_check_pe_sig(h) ? "yes" : "no"));
>  
> -	fprintf(stderr, "kexec: arm64 binary Image files are currently NOT SUPPORTED.\n");
> -
> -	return -1;
> +	return 0;
>  }
>  
>  int image_arm64_load(int argc, char **argv, const char *kernel_buf,
>  	off_t kernel_size, struct kexec_info *info)
>  {
> -	return -ENOSYS;
> +	int result;
> +	uint64_t start;
> +	const struct arm64_image_header *h;
> +	char *header_option = NULL;
> +
> +	h = (const struct arm64_image_header *)(kernel_buf);
> +
> +	arm64_mem.text_offset = le64_to_cpu(h->text_offset);
> +	arm64_mem.image_size = le64_to_cpu(h->image_size);
> +
> +	if(!arm64_opts.page_offset)
> +		arm64_mem.page_offset = ARM64_DEFAULT_PAGE_OFFSET;
> +	else
> +		arm64_mem.page_offset = arm64_opts.page_offset;
> +
> +	if (info->kexec_flags & KEXEC_ON_CRASH) {
> +		result = load_crashdump_segments(info, &header_option);
> +
> +		if (result) {
> +			fprintf(stderr, "kexec: load crashdump segments failed.\n");
> +			return -1;
> +		}
> +		start = crash_reserved_mem.start;
> +	} else {
> +		result = parse_iomem_single("Kernel code\n", &start, NULL);
> +
> +		if (result) {
> +			fprintf(stderr, "kexec: Could not get kernel code address.\n");
> +			return -1;
> +		}
> +		start -= arm64_mem.text_offset;
> +	}
> +
> +	/* Add kernel */
> +	add_segment_phys_virt(info, kernel_buf, kernel_size,
> +			start + arm64_mem.text_offset,
> +			kernel_size, 0);
> +
> +	info->entry = (void *)start + arm64_mem.text_offset;
> +
> +	result = arm64_load_other_segments(info, (unsigned long)info->entry,
> +		header_option);
> +
> +	if (header_option)
> +		free(header_option);
> +
> +	return result;
>  }
>  
>  void image_arm64_usage(void)
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2015-04-20  7:24 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 16:47 [PATCH RFC 0/6] Various fixes for purgatory and ARM64 Pratyush Anand
2015-04-16 16:47 ` [PATCH RFC 1/6] purgatory: Fix memcmp for src address increment Pratyush Anand
2015-04-17 16:55   ` Geoff Levand
2015-04-20  0:25     ` Simon Horman
2015-04-22 11:19       ` Pratyush Anand
2015-04-23  2:23         ` Simon Horman
2015-04-16 16:47 ` [PATCH RFC 2/6] purgatory: No need to sha256 update if ptr->len is zero Pratyush Anand
2015-04-17 16:58   ` Geoff Levand
2015-04-17 23:26     ` Pratyush Anand
2015-04-20  3:01   ` Baoquan He
2015-04-20  3:18     ` Pratyush Anand
2015-04-16 16:47 ` [PATCH RFC 3/6] arm64: allocate memory for other segments after kernel Pratyush Anand
2015-04-17 16:59   ` Geoff Levand
2015-04-20  3:21   ` Baoquan He
2015-04-21  4:19     ` Pratyush Anand
2015-04-21 10:06       ` AKASHI Takahiro
2015-04-22  6:16         ` AKASHI Takahiro
2015-04-16 16:47 ` [PATCH RFC 4/6] arm64: support reuse-cmdline option Pratyush Anand
2015-04-17 17:02   ` Geoff Levand
2015-04-16 16:47 ` [PATCH RFC 5/6] arm64: Add support for binary image Pratyush Anand
2015-04-17 17:07   ` Geoff Levand
2015-04-17 18:00     ` Geoff Levand
2015-04-17 23:27       ` Pratyush Anand
2015-04-20  7:24   ` Baoquan He [this message]
2015-04-21  4:42     ` Pratyush Anand
2015-04-22  2:53       ` Baoquan He
2015-04-22 11:19         ` Pratyush Anand
2015-04-16 16:47 ` [PATCH RFC 6/6] arm64: wait for transmit completion before next character transmission Pratyush Anand
2015-04-17  5:36   ` Minfei Huang
2015-04-17  5:37     ` Pratyush Anand
2015-04-20  2:58       ` Baoquan He
2015-04-20  3:34         ` Pratyush Anand
2015-04-17 17:22   ` Geoff Levand
2015-04-17 23:31     ` Pratyush Anand
2015-04-16 23:54 ` [PATCH RFC 0/6] Various fixes for purgatory and ARM64 Simon Horman
2015-04-17  1:27 ` Dave Young
2015-04-17  2:48   ` Pratyush Anand
2015-04-17 17:27 ` Geoff Levand

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=20150420072402.GG15033@dhcp-16-116.nay.redhat.com \
    --to=bhe@redhat.com \
    --cc=kexec@lists.fedoraproject.org \
    --cc=kexec@lists.infradead.org \
    --cc=panand@redhat.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