linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
To: linux-arm-kernel@lists.infradead.org
Cc: f.fainelli@gmail.com, "Sverdlin,
	Alexander \(Nokia - DE/Ulm\)" <alexander.sverdlin@nokia.co>
Subject: [PATCH] arm: Support initrd with address in boot alias region
Date: Tue, 29 Sep 2020 09:54:38 +0200	[thread overview]
Message-ID: <c7063c79-0e34-f1be-35ec-56d1cf993a2f@nokia.com> (raw)

If bootloader passes address of initrd in boot alias region, initrd
will fail on memblock_is_region_memory as memblock with such address
doesn't exist.

Issue was observed with kexec which passed initrd address in boot alias
region, while bootloader will typically pass physical address. Commit
fe7db7570379 ("of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT")
uncovered problem by removing virt_to_phys on the initrd physical
address. __virt_to_phys on our platform coincidentally fixed address.

Fix by trying to correct address in case of invalid physical address.

Signed-off-by: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
---
 arch/arm/mm/init.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 000c1b48e973..6cbf64383cfc 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -164,6 +164,17 @@ static void __init arm_initrd_init(void)
 	if (!phys_initrd_size)
 		return;
 
+	/*
+	 * In case initrd is not valid physical address, try with boot
+	 * memory region alias as bootloader may have passed address
+	 * within.
+	 */
+	if (!pfn_valid(__phys_to_pfn(phys_initrd_start))) {
+		pr_info("initrd at invalid address, trying with boot alias\n");
+		if (arm_has_idmap_alias())
+			phys_initrd_start = idmap_to_phys(phys_initrd_start);
+	}
+
 	/*
 	 * Round the memory region to page boundaries as per free_initrd_mem()
 	 * This allows us to detect whether the pages overlapping the initrd
-- 
2.28.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2020-09-29  7:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29  7:54 Matija Glavinic Pecotic [this message]
2020-09-29 17:21 ` [PATCH] arm: Support initrd with address in boot alias region Florian Fainelli
2020-09-30 10:35   ` Russell King - ARM Linux admin
2020-09-30 11:07     ` Matija Glavinic Pecotic

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=c7063c79-0e34-f1be-35ec-56d1cf993a2f@nokia.com \
    --to=matija.glavinic-pecotic.ext@nokia.com \
    --cc=alexander.sverdlin@nokia.co \
    --cc=f.fainelli@gmail.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).