From: Sameer Goel <sgoel@codeaurora.org>
To: geoff@infradead.org
Cc: panand@redhat.com, timur@codeaurora.org,
kexec@lists.infradead.org, rruigrok@codeaurora.org,
takahiro.akashi@linaro.org, Sameer Goel <sgoel@codeaurora.org>
Subject: [PATCH V2] arm64:kexec: Memstart should not be before the kernel start address
Date: Thu, 11 Aug 2016 19:24:29 -0600 [thread overview]
Message-ID: <1470965069-20121-1-git-send-email-sgoel@codeaurora.org> (raw)
Starting 4.6 the kernel memblock start is rounded down to a desirable
alignment. So, the kernel can see reserved meory regions before the kernel
start address in the iomem query.
Need to make sure that the right kernel start address is picked from the iomem
query.
Signed-off-by: Sameer Goel <sgoel@codeaurora.org>
---
This change should be applied on top of geoff kexec-tools v3 branch from
arm64[1] + bugfix[2]
[1] http://lists.infradead.org/pipermail/kexec/2016-August/016768.html
[2] http://lists.infradead.org/pipermail/kexec/2016-July/016664.html
kexec/arch/arm64/kexec-arm64.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 940cddb..7a1d4fc 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -25,6 +25,11 @@
/* Global varables the core kexec routines expect. */
+#define SZ_2M 0x200000
+#define __round_mask(x, y) ((__typeof__(x))((y)-1))
+#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
+#define round_down(x, y) ((x) & ~__round_mask(x, y))
+
unsigned char reuse_initrd;
off_t initrd_base;
@@ -448,6 +453,27 @@ void add_segment(struct kexec_info *info, const void *buf, size_t bufsz,
add_segment_phys_virt(info, buf, bufsz, base, memsz, 1);
}
+static int get_memory_ranges_iomem_kc_cb(void *data, int nr, char *str,
+ unsigned long long base, unsigned long long length)
+{
+ struct memory_range *r;
+
+ if (nr >= KEXEC_SEGMENT_MAX)
+ return -1;
+
+ r = (struct memory_range *)data + nr;
+ r->type = RANGE_RAM;
+ r->start = base;
+ r->end = base + length - 1;
+
+ set_phys_offset(round_down(r->start, SZ_2M));
+
+ dbgprintf("%s: %016llx - %016llx : %s", __func__, r->start,
+ r->end, str);
+
+ return 0;
+}
+
/**
* get_memory_ranges_iomem_cb - Helper for get_memory_ranges_iomem.
*/
@@ -465,7 +491,6 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
r->start = base;
r->end = base + length - 1;
- set_phys_offset(r->start);
dbgprintf("%s: %016llx - %016llx : %s", __func__, r->start,
r->end, str);
@@ -480,6 +505,14 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
static int get_memory_ranges_iomem(struct memory_range *array,
unsigned int *count)
{
+ *count = kexec_iomem_for_each_line("Kernel code\n",
+ get_memory_ranges_iomem_kc_cb, array);
+
+ if (!*count) {
+ dbgprintf("%s: failed: No code segment found.\n", __func__);
+ return -EFAILED;
+ }
+
*count = kexec_iomem_for_each_line("System RAM\n",
get_memory_ranges_iomem_cb, array);
--
Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2016-08-12 1:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-12 1:24 Sameer Goel [this message]
2016-08-12 5:28 ` [PATCH V2] arm64:kexec: Memstart should not be before the kernel start address Pratyush Anand
2016-08-18 17:45 ` 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=1470965069-20121-1-git-send-email-sgoel@codeaurora.org \
--to=sgoel@codeaurora.org \
--cc=geoff@infradead.org \
--cc=kexec@lists.infradead.org \
--cc=panand@redhat.com \
--cc=rruigrok@codeaurora.org \
--cc=takahiro.akashi@linaro.org \
--cc=timur@codeaurora.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