kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Baoquan He <bhe@redhat.com>
Cc: mjg59@srcf.ucam.org, greg@kroah.com, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org, ebiederm@xmission.com,
	hpa@zytor.com
Subject: Re: [PATCH 5/6] kexec-bzImage: Support for loading bzImage using 64bit entry
Date: Mon, 2 Dec 2013 10:36:47 -0500	[thread overview]
Message-ID: <20131202153647.GE18642@redhat.com> (raw)
In-Reply-To: <20131128113514.GD4318@dhcp-16-252.nay.redhat.com>

On Thu, Nov 28, 2013 at 07:35:14PM +0800, Baoquan He wrote:

[..]
> > +void *bzImage64_load(struct kimage *image, char *kernel,
> > +		unsigned long kernel_len,
> > +		char *initrd, unsigned long initrd_len,
> > +		char *cmdline, unsigned long cmdline_len)
> > +{
> > +
> > +	struct setup_header *header;
> > +	int setup_sects, kern16_size_needed, kern16_size, ret = 0;
> > +	unsigned long setup_size, setup_header_size;
> > +	struct boot_params *params;
> > +	unsigned long bootparam_load_addr, kernel_load_addr, initrd_load_addr;
> > +	unsigned long kernel_bufsz, kernel_memsz, kernel_align;
> > +	char *kernel_buf;
> > +	struct bzimage64_data *ldata;
> > +
> > +	header = (struct setup_header *)(kernel + 0x1F1);
> > +	setup_sects = header->setup_sects;
> > +	if (setup_sects == 0)
> > +		setup_sects = 4;
> > +
> > +	kern16_size = (setup_sects + 1) * 512;
> > +	if (kernel_len < kern16_size) {
> > +		pr_debug("bzImage truncated\n");
> > +		return ERR_PTR(-ENOEXEC);
> > +	}
> > +
> > +	if (cmdline_len > header->cmdline_size) {
> > +		pr_debug("Kernel command line too long\n");
> > +		return ERR_PTR(-EINVAL);
> > +	}
> > +
> > +	/* Allocate loader specific data */
> > +	ldata = kzalloc(sizeof(struct bzimage64_data), GFP_KERNEL);
> > +	if (!ldata)
> > +		return ERR_PTR(-ENOMEM);
> > +
> > +	/* Argument/parameter segment */
> > +	kern16_size_needed = kern16_size;
> > +	if (kern16_size_needed < 4096)
> > +		kern16_size_needed = 4096;
> > +
> > +	setup_size = kern16_size_needed + cmdline_len;
> > +	params = kzalloc(setup_size, GFP_KERNEL);
> > +	if (!params) {
> > +		ret = -ENOMEM;
> > +		goto out_free_loader_data;
> > +	}
> > +
> > +	/* Copy setup header onto bootparams. */
> > +	setup_header_size = 0x0202 + kernel[0x0201] - 0x1F1;
> > +
> > +	/* Is there a limit on setup header size? */
> > +	memcpy(&params->hdr, (kernel + 0x1F1), setup_header_size);
> > +	ret = kexec_add_buffer(image, (char *)params, setup_size,
> > +			setup_size, 16, 0x3000, -1, 1, &bootparam_load_addr);
> > +	if (ret)
> > +		goto out_free_params;
> > +	pr_debug("Loaded boot_param and command line at 0x%lx\n",
> > +			bootparam_load_addr);
> > +
> > +	/* Load kernel */
> > +	kernel_buf = kernel + kern16_size;
> > +	kernel_bufsz =  kernel_len - kern16_size;
> > +	kernel_memsz = ALIGN(header->init_size, 4096);
> > +	kernel_align = header->kernel_alignment;
> > +
> > +	ret = kexec_add_buffer(image, kernel_buf,
> > +			kernel_bufsz, kernel_memsz, kernel_align, 0x100000,
> > +			-1, 1, &kernel_load_addr);
> > +	if (ret)
> > +		goto out_free_params;
> > +
> > +	pr_debug("Loaded 64bit kernel at 0x%lx sz = 0x%lx\n", kernel_load_addr,
> > +				kernel_memsz);
> > +
> > +	/* Load initrd high */
> > +	if (initrd) {
> > +		ret = kexec_add_buffer(image, initrd, initrd_len, initrd_len,
> > +			4096, 0x10000000, ULONG_MAX, 1, &initrd_load_addr);
> 
> Here the minimal starting addr to locate initrd is 256M, though it's
> allocated from top to down, I am still wondering why.

Hi Bao,

Good catch. It is vestige of some hard coding I had done initially to
test my patches. Forgot to remove the hardcoding here. Will fix it in
next version.

Thanks
Vivek

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

  reply	other threads:[~2013-12-02 15:37 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-20 17:50 [PATCH 0/6] kexec: A new system call to allow in kernel loading Vivek Goyal
2013-11-20 17:50 ` [PATCH 1/6] kexec: Export vmcoreinfo note size properly Vivek Goyal
2013-11-21 18:59   ` Greg KH
2013-11-21 19:08     ` Vivek Goyal
2013-11-20 17:50 ` [PATCH 2/6] kexec: Move segment verification code in a separate function Vivek Goyal
2013-11-20 17:50 ` [PATCH 3/6] resource: Provide new functions to walk through resources Vivek Goyal
2013-11-20 17:50 ` [PATCH 4/6] kexec: A new system call, kexec_file_load, for in kernel kexec Vivek Goyal
2013-11-21 19:03   ` Greg KH
2013-11-21 19:06     ` Matthew Garrett
2013-11-21 19:13       ` Vivek Goyal
2013-11-21 19:19         ` Matthew Garrett
2013-11-21 19:24           ` Vivek Goyal
2013-11-22 18:57           ` Vivek Goyal
2013-11-23  3:39             ` Eric W. Biederman
2013-11-25 16:39               ` Vivek Goyal
2013-11-26 12:23                 ` Eric W. Biederman
2013-11-26 14:27                   ` Vivek Goyal
2013-12-19 12:54                     ` Torsten Duwe
2013-12-20 14:19                       ` Vivek Goyal
2013-12-20 23:11                         ` Eric W. Biederman
2013-12-20 23:20                           ` Kees Cook
2013-12-21 11:38                             ` Torsten Duwe
2014-01-02 20:39                             ` Vivek Goyal
2014-01-02 20:56                               ` H. Peter Anvin
2014-01-06 21:33                                 ` Josh Boyer
2014-01-07  4:22                                   ` H. Peter Anvin
2013-12-20 23:20                           ` H. Peter Anvin
2013-12-21  1:32                             ` Eric W. Biederman
2013-12-21  3:32                               ` H. Peter Anvin
2013-12-21 12:15                                 ` Torsten Duwe
2013-11-21 19:16     ` Vivek Goyal
2013-11-22  1:03     ` Kees Cook
2013-11-22  2:13       ` Vivek Goyal
2013-11-22 20:42   ` Jiri Kosina
2014-01-17 19:17     ` Vivek Goyal
2013-11-29  3:10   ` Baoquan He
2013-12-02 15:27     ` WANG Chao
2013-12-02 15:44     ` Vivek Goyal
2013-12-04  1:35       ` Baoquan He
2013-12-04 17:19         ` Vivek Goyal
2013-12-04  1:56   ` Baoquan He
2013-12-04  8:19     ` Baoquan He
2013-12-04 17:32     ` Vivek Goyal
2013-11-20 17:50 ` [PATCH 5/6] kexec-bzImage: Support for loading bzImage using 64bit entry Vivek Goyal
2013-11-21 19:07   ` Greg KH
2013-11-21 19:21     ` Vivek Goyal
2013-11-22 15:24       ` H. Peter Anvin
2013-11-28 11:35   ` Baoquan He
2013-12-02 15:36     ` Vivek Goyal [this message]
2013-11-20 17:50 ` [PATCH 6/6] kexec: Support for Kexec on panic using new system call Vivek Goyal
2013-11-28 11:28   ` Baoquan He
2013-12-02 15:30     ` Vivek Goyal
2013-12-04  1:51       ` Baoquan He
2013-12-04 17:20         ` Vivek Goyal
2013-12-04  1:41   ` Baoquan He
2013-12-04 17:19     ` Vivek Goyal
2013-11-21 18:58 ` [PATCH 0/6] kexec: A new system call to allow in kernel loading Greg KH
2013-11-21 19:07   ` Vivek Goyal
2013-11-21 19:46     ` Vivek Goyal
2013-11-21 19:06 ` Geert Uytterhoeven
2013-11-21 19:14   ` Vivek Goyal
2013-11-21 23:07 ` Eric W. Biederman
2013-11-22  1:28   ` H. Peter Anvin
2013-11-22  2:35     ` Vivek Goyal
2013-11-22  2:40       ` H. Peter Anvin
2013-11-22  1:55   ` Vivek Goyal
2013-11-22  9:09     ` Geert Uytterhoeven
2013-11-22 13:30       ` Jiri Kosina
2013-11-22 13:46         ` Vivek Goyal
2013-11-22 13:50           ` Jiri Kosina
2013-11-22 15:33             ` Vivek Goyal
2013-11-22 17:45               ` Kees Cook
2013-11-22 13:43       ` Vivek Goyal
2013-11-22 15:25         ` Geert Uytterhoeven
2013-11-22 15:33           ` Jiri Kosina
2013-11-22 15:57             ` Eric Paris
2013-11-22 16:04               ` Jiri Kosina
2013-11-22 16:08                 ` Vivek Goyal
2013-11-22 13:34     ` Eric W. Biederman
2013-11-22 14:19       ` Vivek Goyal
2013-11-22 19:48         ` Greg KH
2013-11-23  3:23         ` Eric W. Biederman
2013-12-04 19:34           ` Vivek Goyal
2013-12-05  4:10             ` Eric W. Biederman
2013-11-25 10:04       ` Michael Holzheu
2013-11-25 15:36         ` Vivek Goyal
2013-11-25 16:15           ` Michael Holzheu
2013-11-22  0:55 ` HATAYAMA Daisuke
2013-11-22  2:03   ` Vivek Goyal
2013-12-03 13:23 ` Baoquan He

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=20131202153647.GE18642@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=bhe@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=greg@kroah.com \
    --cc=hpa@zytor.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.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).