From: "Thomas Weißschuh" <thomas@t-8ch.de>
To: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Huacai Chen <chenhuacai@kernel.org>,
Binbin Zhou <zhoubinbin@loongson.cn>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/4] LoongArch: Fix built-in DTB detection
Date: Thu, 30 May 2024 12:06:01 +0200 [thread overview]
Message-ID: <e1321725-ee7e-4716-ad45-634803fca5ff@t-8ch.de> (raw)
In-Reply-To: <20240522-loongarch-booting-fixes-v3-1-25e77a8fc86e@flygoat.com>
On 2024-05-22 23:02:17+0000, Jiaxun Yang wrote:
> fdt_check_header(__dtb_start) will always success because kernel
> provided a dummy dtb, and by coincidence __dtb_start clashed with
> entry of this dummy dtb. The consequence is fdt passed from
> firmware will never be taken.
>
> Fix by trying to utilise __dtb_start only when CONFIG_BUILTIN_DTB
> is enabled.
>
> Cc: stable@vger.kernel.org
> Fixes: 7b937cc243e5 ("of: Create of_root if no dtb provided by firmware")
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> v3: Better reasoning in commit message, thanks Binbin and Huacai!
> ---
> arch/loongarch/kernel/setup.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
> index 60e0fe97f61a..ea6d5db6c878 100644
> --- a/arch/loongarch/kernel/setup.c
> +++ b/arch/loongarch/kernel/setup.c
> @@ -275,16 +275,18 @@ static void __init arch_reserve_crashkernel(void)
> static void __init fdt_setup(void)
> {
> #ifdef CONFIG_OF_EARLY_FLATTREE
> - void *fdt_pointer;
> + void *fdt_pointer = NULL;
>
> /* ACPI-based systems do not require parsing fdt */
> if (acpi_os_get_root_pointer())
> return;
>
> +#ifdef CONFIG_BUILTIN_DTB
> /* Prefer to use built-in dtb, checking its legality first. */
> if (!fdt_check_header(__dtb_start))
> fdt_pointer = __dtb_start;
> - else
> +#endif
> + if (!fdt_pointer)
> fdt_pointer = efi_fdt_pointer(); /* Fallback to firmware dtb */
Prefer to use non-ifdef logic:
if (IS_ENABLED(CONFIG_BUILTIN_DTB) && !fdt_check_header(__dtb_start))
fdt_pointer = __dtb_start;
This is shorter, easier to read and will prevent bitrot.
The code will be typechecked but then optimized away, so no
runtime overhead exists.
>
> if (!fdt_pointer || fdt_check_header(fdt_pointer))
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-05-30 10:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 22:02 [PATCH v3 0/4] LoongArch: Bootloader interface fixes Jiaxun Yang
2024-05-22 22:02 ` [PATCH v3 1/4] LoongArch: Fix built-in DTB detection Jiaxun Yang
2024-05-30 10:06 ` Thomas Weißschuh [this message]
2024-05-30 14:49 ` Huacai Chen
2024-05-22 22:02 ` [PATCH v3 2/4] LoongArch: smp: Add all CPUs enabled by fdt to NUMA node 0 Jiaxun Yang
2024-05-22 22:02 ` [PATCH v3 3/4] LoongArch: Fix entry point in image header Jiaxun Yang
2024-05-29 18:28 ` Nathan Chancellor
2024-05-30 5:01 ` WANG Rui
2024-05-30 9:50 ` Jiaxun Yang
2024-05-30 10:41 ` Huacai Chen
2024-05-22 22:02 ` [PATCH v3 4/4] LoongArch: Override higher address bits in JUMP_VIRT_ADDR Jiaxun Yang
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=e1321725-ee7e-4716-ad45-634803fca5ff@t-8ch.de \
--to=thomas@t-8ch.de \
--cc=chenhuacai@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=zhoubinbin@loongson.cn \
/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