mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jiaxun Yang" <jiaxun.yang@flygoat.com>
To: "Huacai Chen" <chenhuacai@loongson.cn>,
	"Huacai Chen" <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, "Xuefeng Li" <lixuefeng@loongson.cn>,
	"Guo Ren" <guoren@kernel.org>, "Xuerui Wang" <kernel@xen0n.name>,
	linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn
Subject: Re: [PATCH] LoongArch: Use correct API to map cmdline in relocate_kernel()
Date: Wed, 03 Jul 2024 13:07:20 +0800	[thread overview]
Message-ID: <a012763d-d1d4-4e70-b8fc-173b8a915af9@app.fastmail.com> (raw)
In-Reply-To: <20240702151415.1160566-1-chenhuacai@loongson.cn>



在2024年7月2日七月 下午11:14,Huacai Chen写道:
> fw_arg1 is in memory space rather than I/O space, so we should use
> early_memremap_ro() instead of early_ioremap() to map the cmdline.
> Moreover, we should unmap it after using.
>
> Suggested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

Thanks for correcting that.

> ---
>  arch/loongarch/kernel/relocate.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kernel/relocate.c b/arch/loongarch/kernel/relocate.c
> index 1acfa704c8d0..0eddd4a66b87 100644
> --- a/arch/loongarch/kernel/relocate.c
> +++ b/arch/loongarch/kernel/relocate.c
> @@ -13,6 +13,7 @@
>  #include <asm/bootinfo.h>
>  #include <asm/early_ioremap.h>
>  #include <asm/inst.h>
> +#include <asm/io.h>
>  #include <asm/sections.h>
>  #include <asm/setup.h>
> 
> @@ -170,7 +171,7 @@ unsigned long __init relocate_kernel(void)
>  	unsigned long kernel_length;
>  	unsigned long random_offset = 0;
>  	void *location_new = _text; /* Default to original kernel start */
> -	char *cmdline = early_ioremap(fw_arg1, COMMAND_LINE_SIZE); /* Boot 
> command line is passed in fw_arg1 */
> +	char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE); /* 
> Boot command line is passed in fw_arg1 */
> 
>  	strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
> 
> @@ -182,6 +183,7 @@ unsigned long __init relocate_kernel(void)
>  		random_offset = (unsigned long)location_new - (unsigned long)(_text);
>  #endif
>  	reloc_offset = (unsigned long)_text - VMLINUX_LOAD_ADDRESS;
> +	early_memunmap(cmdline, COMMAND_LINE_SIZE);
> 
>  	if (random_offset) {
>  		kernel_length = (long)(_end) - (long)(_text);
> -- 
> 2.43.0

-- 
- Jiaxun

      reply	other threads:[~2024-07-03  5:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02 15:14 Huacai Chen
2024-07-03  5:07 ` Jiaxun Yang [this message]

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=a012763d-d1d4-4e70-b8fc-173b8a915af9@app.fastmail.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=guoren@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=loongarch@lists.linux.dev \
    --cc=loongson-kernel@lists.loongnix.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

all inboxes | Powered by JetHome®