From: achandran@mvista.com (Arun Chandran)
To: linux-arm-kernel@lists.infradead.org
Subject: Kexec on arm64
Date: Wed, 30 Jul 2014 11:16:39 +0530 [thread overview]
Message-ID: <CAFdej02R=3bq9n0ic5AZHwRjGT21fZ7S2ouuXZNevjdRsxmUNA@mail.gmail.com> (raw)
In-Reply-To: <20140729133557.GQ2576@leverpostej>
On Tue, Jul 29, 2014 at 7:05 PM, Mark Rutland <mark.rutland@arm.com> wrote:
> [...]
>
>> The default code did not work.
>>
>> It is working with the change below
>>
>> ###############
>> diff --git a/arch/arm64/kernel/machine_kexec.c
>> b/arch/arm64/kernel/machine_kexec.c
>> index 5632473..7c5f859 100644
>> --- a/arch/arm64/kernel/machine_kexec.c
>> +++ b/arch/arm64/kernel/machine_kexec.c
>> @@ -147,12 +147,17 @@ static bool kexec_is_dtb_user(const dtb_t *dtb)
>> /**
>> * kexec_list_walk - Helper to walk the kimage page list.
>> */
>> -
>> +static int kexec_kernel_size;
>> +#define IMG_SIZE_NONE 0
>> +#define KERN_SIZE_FLAG 1
>> +#define DTB_SIZE_FLAG 2
>> static void kexec_list_walk(void *ctx, unsigned long kimage_head,
>> void (*cb)(void *ctx, unsigned int flag, void *addr, void *dest))
>> {
>> void *dest;
>> unsigned long *entry;
>> + int imgsize_flag = IMG_SIZE_NONE;
>> +
>>
>> for (entry = &kimage_head, dest = NULL; ; entry++) {
>> unsigned int flag = *entry & IND_FLAGS;
>> @@ -164,10 +169,18 @@ static void kexec_list_walk(void *ctx, unsigned
>> long kimage_head,
>> cb(ctx, flag, addr, NULL);
>> break;
>> case IND_DESTINATION:
>> + if (imgsize_flag == IMG_SIZE_NONE) {
>> + kexec_kernel_size = 0;
>> + imgsize_flag = KERN_SIZE_FLAG;
>> + } else if (imgsize_flag == KERN_SIZE_FLAG) {
>> + imgsize_flag = DTB_SIZE_FLAG;
>> + }
>> dest = addr;
>> cb(ctx, flag, addr, NULL);
>> break;
>> case IND_SOURCE:
>> + if (imgsize_flag == KERN_SIZE_FLAG)
>> + kexec_kernel_size++;
>> cb(ctx, flag, addr, dest);
>> dest += PAGE_SIZE;
>> break;
>> @@ -693,5 +706,20 @@ void machine_kexec(struct kimage *image)
>>
>> kexec_list_walk(NULL, image->head, kexec_list_flush_cb);
>>
>> + /*
>> + * Make sure virtual addresses of new kernel are flushed
>> + * SZ_512K = TEXT_OFFSET
>
> TEXT_OFFSET is not guaranteed to be 512K. The TEXT_OFFSET area also
> shouldn't need to be flushed.
>
> Since c218bca74eea (arm64: Relax the kernel cache requirements for
> boot), the kernel will flush the cache for anything outside of the Image
> that it writes to before enabling the MMU and caches (e.g. the idmap and
> swapper page tables). Once caches are up we shouldn't care.
>
Ok. TEXT_OFFSET macro is not exported, that's why I used SZ_512K.
Any particular reason for not exporting it?
> Assuming that the existing kernel code is correct, the only region we
> should need to flush out to the PoC is the region from _text to _edata
> (i.e. just the contents of the Image).
>
>> + * kexec_kernel = kexec_kernel_size * PAGE_SIZE
>> + * Don't know = (SZ_4M + SZ_1M)
>> + * SZ_4M = not working
>> + * SZ_6M = working
>> + * SZ_8M = working
>> + *
>> + * so chose SZ_4M + SZ_1M; Don't know why this is required
>> + * BSS, stack ??
>> + *
>> + */
>> + __flush_dcache_area((void *)PAGE_OFFSET, SZ_512K +
>> (kexec_kernel_size * PAGE_SIZE) + SZ_4M + SZ_1M);
>> +
>> soft_restart(reboot_code_buffer_phys);
>> }
>
> How big exactly is the kernel Image you're trying to kexec?
For the 1st and second stage I use the same kernel as they
are combined with intramfs final image size varies.
1st stage
-------------
$ls -l arch/arm64/boot/uImage
-rw-rw-r-- 1 arun arun 12895544 Jul 30 10:57 arch/arm64/boot/uImage
It will boot to intramfs
$ls /
bin dtb.dtb home lib linuxrc mnt proc run share tmp var
dev etc init lib64 media opt root sbin sys usr vmlinux.strip
kexec will boot vmlinux.strip
$ls -l vmlinux.strip
-rwxrwxr-x 1 arun arun 8194760 Jul 30 10:55 vmlinux.strip
2nd stage
--------------
$ls -l arch/arm64/boot/uImage
-rw-rw-r-- 1 arun arun 8127800 Jul 30 10:54 arch/arm64/boot/uImage
The corresponding vmlinux is converted to vmlinux.strip
$aarch64-linux-gnu-strip vmlinux -o vmlinux.strip
$cp vmlinux.strip /ramfs/aarch64_le_rootfs/
--Arun
next prev parent reply other threads:[~2014-07-30 5:46 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAFdej006OSyhgDcJ2iZdbjt+PtysN=i_+9Dr4GTmr=+t5yg4Kw@mail.gmail.com>
2014-07-15 17:04 ` Kexec on arm64 Geoff Levand
2014-07-16 17:57 ` Feng Kan
2014-07-16 23:04 ` Geoff Levand
2014-07-22 9:44 ` Arun Chandran
2014-07-22 13:25 ` Arun Chandran
2014-07-24 0:38 ` Geoff Levand
2014-07-24 9:36 ` Mark Rutland
2014-07-24 12:49 ` Arun Chandran
2014-07-25 0:17 ` Geoff Levand
2014-07-25 10:31 ` Arun Chandran
2014-07-25 10:36 ` Mark Rutland
2014-07-25 11:48 ` Arun Chandran
2014-07-25 12:14 ` Mark Rutland
2014-07-25 15:29 ` Arun Chandran
2014-07-26 0:18 ` Geoff Levand
2014-07-28 15:00 ` Arun Chandran
2014-07-28 15:38 ` Mark Rutland
2014-07-29 0:09 ` Geoff Levand
2014-07-29 9:10 ` Mark Rutland
2014-07-29 12:32 ` Arun Chandran
2014-07-29 13:35 ` Mark Rutland
2014-07-29 21:19 ` Geoff Levand
2014-07-30 7:22 ` Arun Chandran
2014-08-01 11:13 ` Arun Chandran
2014-08-03 14:47 ` Mark Rutland
2014-08-04 10:16 ` Arun Chandran
2014-08-04 11:35 ` Mark Rutland
2014-08-07 0:40 ` Geoff Levand
2014-08-07 9:59 ` Mark Rutland
2014-08-07 17:09 ` Geoff Levand
2014-08-04 17:21 ` Geoff Levand
2014-08-06 13:54 ` Arun Chandran
2014-08-06 15:51 ` Arun Chandran
2014-08-07 20:07 ` Geoff Levand
2014-08-08 5:46 ` Arun Chandran
2014-08-08 10:03 ` Arun Chandran
2014-08-12 5:42 ` Arun Chandran
2014-08-13 11:09 ` Arun Chandran
2014-08-26 22:32 ` Geoff Levand
2014-08-27 4:56 ` Arun Chandran
2014-07-30 5:46 ` Arun Chandran [this message]
2014-07-30 9:16 ` Mark Rutland
2014-07-30 7:01 ` Arun Chandran
2014-07-25 10:26 ` Arun Chandran
2014-07-25 11:29 ` Mark Rutland
2014-07-24 11:50 ` Arun Chandran
2014-07-30 3:26 ` Feng Kan
2014-07-24 0:10 ` Geoff Levand
2014-07-24 9:13 ` Mark Rutland
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='CAFdej02R=3bq9n0ic5AZHwRjGT21fZ7S2ouuXZNevjdRsxmUNA@mail.gmail.com' \
--to=achandran@mvista.com \
--cc=linux-arm-kernel@lists.infradead.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).