Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1719706
| From | AKASHI Takahiro <takahiro.akashi@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 10/14] arm64: kexec_file: load initrd, device-tree and purgatory segments |
| Date | 2017-08-25 03:40 +0200 |
| Message-ID | <uibLk-5Xx-9@gated-at.bofh.it> (permalink) |
| References | <uhVwR-3Wx-1@gated-at.bofh.it> <uhVGy-405-21@gated-at.bofh.it> <ui3Xr-Z6-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Aug 24, 2017 at 06:11:31PM +0100, Mark Rutland wrote:
> On Thu, Aug 24, 2017 at 05:18:07PM +0900, AKASHI Takahiro wrote:
> > load_other_segments() sets up and adds all the memory segments necessary
> > other than kernel, including initrd, device-tree blob and purgatory.
> > Most of the code was borrowed from kexec-tools' counterpart.
> >
> > In addition, arch_kexec_image_probe(), arch_kexec_image_load() and
> > arch_kexec_kernel_verify_sig() are stubs for supporting multiple types
> > of kernel image formats.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> > ---
> > arch/arm64/include/asm/kexec.h | 18 +++
> > arch/arm64/kernel/machine_kexec_file.c | 255 +++++++++++++++++++++++++++++++++
> > 2 files changed, 273 insertions(+)
>
> > +int load_other_segments(struct kimage *image, unsigned long kernel_load_addr,
> > + char *initrd, unsigned long initrd_len,
> > + char *cmdline, unsigned long cmdline_len)
> > +{
> > + struct kexec_buf kbuf;
> > + unsigned long initrd_load_addr = 0;
> > + unsigned long purgatory_load_addr, dtb_load_addr;
> > + char *dtb = NULL;
> > + unsigned long dtb_len;
> > + int ret = 0;
> > +
> > + kbuf.image = image;
> > +
> > + /* Load initrd */
> > + if (initrd) {
> > + kbuf.buffer = initrd;
> > + kbuf.bufsz = initrd_len;
> > + kbuf.memsz = initrd_len;
> > + kbuf.buf_align = PAGE_SIZE;
> > + /* within 1GB-aligned window of up to 32GB in size */
> > + kbuf.buf_min = kernel_load_addr;
> > + kbuf.buf_max = round_down(kernel_load_addr, SZ_1G)
> > + + (unsigned long)SZ_1G * 31;
> > + kbuf.top_down = 0;
> > +
> > + ret = kexec_add_buffer(&kbuf);
> > + if (ret)
> > + goto out_err;
> > + initrd_load_addr = kbuf.mem;
> > +
> > + pr_debug("Loaded initrd at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
> > + initrd_load_addr, initrd_len, initrd_len);
> > + }
> > +
> > + /* Load dtb blob */
> > + ret = setup_dtb(image, initrd_load_addr, initrd_len,
> > + cmdline, cmdline_len, &dtb, &dtb_len);
> > + if (ret) {
> > + pr_err("Preparing for new dtb failed\n");
> > + goto out_err;
> > + }
> > +
> > + kbuf.buffer = dtb;
> > + kbuf.bufsz = dtb_len;
> > + kbuf.memsz = dtb_len;
> > + /* not across 2MB boundary */
> > + kbuf.buf_align = SZ_2M;
> > + /*
> > + * Note for backporting:
> > + * On kernel prior to v4.2, fdt must reside within 512MB block
> > + * where the kernel also resides. So
> > + * kbuf.buf_min = round_down(kernel_load_addr, SZ_512M);
> > + * kbuf.buf_max = round_up(kernel_load_addr, SZ_512M);
> > + * would be required.
> > + */
> > + kbuf.buf_min = kernel_load_addr;
> > + kbuf.buf_max = ULONG_MAX;
> > + kbuf.top_down = 1;
>
> IIUC, this is trying to load the DTB above the kernel. Is that correct?
Yes.
> Assuming so, shouldn't that kernel_load_addr be kernel_load_addr +
> image_size from the kernel header?
Okey, it would be much safer.
> Otherwise, if the kernel is loaded close to the end of memory, the DTB
> could overlap.
Right, but we allocate the kernel from "bottom up"(top_down=0)
and such a corruption is very unlikely. If it happens, it means
that system memory is just too small.
Thanks,
-Takahiro AKASHI
> Thanks,
> Mark.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/14] arm64: kexec: add kexec_file_load support AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:20 +0200
[PATCH 14/14] arm64: kexec_file: add vmlinux format support AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:20 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support Mark Rutland <mark.rutland@arm.com> - 2017-08-24 19:40 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 04:10 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support Dave Young <dyoung@redhat.com> - 2017-08-25 08:20 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-09-08 05:00 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support Mark Rutland <mark.rutland@arm.com> - 2017-08-29 12:10 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> - 2017-08-29 18:20 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support Michael Ellerman <mpe@ellerman.id.au> - 2017-08-30 10:50 +0200
Re: [PATCH 14/14] arm64: kexec_file: add vmlinux format support AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-09-08 05:10 +0200
[PATCH 08/14] arm64: kexec_file: create purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:20 +0200
Re: [PATCH 08/14] arm64: kexec_file: create purgatory Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-08-24 11:20 +0200
Re: [PATCH 08/14] arm64: kexec_file: create purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 03:20 +0200
Re: [PATCH 08/14] arm64: kexec_file: create purgatory Mark Rutland <mark.rutland@arm.com> - 2017-08-24 19:00 +0200
Re: [PATCH 08/14] arm64: kexec_file: create purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 03:10 +0200
Re: [PATCH 08/14] arm64: kexec_file: create purgatory Mark Rutland <mark.rutland@arm.com> - 2017-08-25 12:30 +0200
Re: [PATCH 08/14] arm64: kexec_file: create purgatory Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> - 2017-08-25 18:20 +0200
Re: [PATCH 08/14] arm64: kexec_file: create purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-09-08 04:50 +0200
[PATCH 02/14] include: pe.h: remove message[] from mz header definition AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:20 +0200
Re: [PATCH 02/14] include: pe.h: remove message[] from mz header definition Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-08-24 11:10 +0200
[PATCH 01/14] MODSIGN: Export module signature definitions AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:20 +0200
[PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
Re: [PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-08-24 11:20 +0200
Re: [PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 03:30 +0200
Re: [PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory Mark Rutland <mark.rutland@arm.com> - 2017-08-24 19:10 +0200
Re: [PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 03:30 +0200
Re: [PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory Mark Rutland <mark.rutland@arm.com> - 2017-08-25 12:50 +0200
Re: [PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-09-08 04:50 +0200
Re: [PATCH 09/14] arm64: kexec_file: add sha256 digest check in purgatory Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> - 2017-09-08 18:00 +0200
[PATCH 07/14] asm-generic: add kexec_file_load system call to unistd.h AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
Re: [PATCH 07/14] asm-generic: add kexec_file_load system call to unistd.h Arnd Bergmann <arnd@arndb.de> - 2017-08-24 13:00 +0200
[PATCH 13/14] arm64: kexec_file: add Image format support AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
Re: [PATCH 13/14] arm64: kexec_file: add Image format support Mark Rutland <mark.rutland@arm.com> - 2017-08-24 19:30 +0200
Re: [PATCH 13/14] arm64: kexec_file: add Image format support AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 04:00 +0200
[PATCH 03/14] resource: add walk_system_ram_res_rev() AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
Re: [PATCH 03/14] resource: add walk_system_ram_res_rev() Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-08-24 11:10 +0200
Re: [PATCH 03/14] resource: add walk_system_ram_res_rev() AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 03:00 +0200
Re: [PATCH 03/14] resource: add walk_system_ram_res_rev() Pratyush Anand <panand@redhat.com> - 2017-08-31 04:40 +0200
Re: [PATCH 03/14] resource: add walk_system_ram_res_rev() AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-09-08 04:40 +0200
[PATCH 10/14] arm64: kexec_file: load initrd, device-tree and purgatory segments AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
Re: [PATCH 10/14] arm64: kexec_file: load initrd, device-tree and purgatory segments Mark Rutland <mark.rutland@arm.com> - 2017-08-24 19:20 +0200
Re: [PATCH 10/14] arm64: kexec_file: load initrd, device-tree and purgatory segments AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-25 03:40 +0200
[PATCH 04/14] kexec_file: factor out vmlinux (elf) parser from powerpc AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
[PATCH 05/14] kexec_file: factor out crashdump elf header function from x86 AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
Re: [PATCH 05/14] kexec_file: factor out crashdump elf header function from x86 Dave Young <dyoung@redhat.com> - 2017-08-25 07:50 +0200
Re: [PATCH 05/14] kexec_file: factor out crashdump elf header function from x86 AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-09-08 04:30 +0200
[PATCH 06/14] kexec_file: add kexec_add_segment() AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
[PATCH 12/14] arm64: enable KEXEC_FILE config AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
[PATCH 11/14] arm64: kexec_file: set up for crash dump adding elf core header AKASHI Takahiro <takahiro.akashi@linaro.org> - 2017-08-24 10:30 +0200
csiph-web