Skip to content

Commit 0124fbb

Browse files
committed
LoongArch: Use correct API to map cmdline in relocate_kernel()
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> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 67e6b11 commit 0124fbb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/loongarch/kernel/relocate.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/bootinfo.h>
1414
#include <asm/early_ioremap.h>
1515
#include <asm/inst.h>
16+
#include <asm/io.h>
1617
#include <asm/sections.h>
1718
#include <asm/setup.h>
1819

@@ -196,7 +197,7 @@ unsigned long __init relocate_kernel(void)
196197
unsigned long kernel_length;
197198
unsigned long random_offset = 0;
198199
void *location_new = _text; /* Default to original kernel start */
199-
char *cmdline = early_ioremap(fw_arg1, COMMAND_LINE_SIZE); /* Boot command line is passed in fw_arg1 */
200+
char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE); /* Boot command line is passed in fw_arg1 */
200201

201202
strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
202203

@@ -208,6 +209,7 @@ unsigned long __init relocate_kernel(void)
208209
random_offset = (unsigned long)location_new - (unsigned long)(_text);
209210
#endif
210211
reloc_offset = (unsigned long)_text - VMLINUX_LOAD_ADDRESS;
212+
early_memunmap(cmdline, COMMAND_LINE_SIZE);
211213

212214
if (random_offset) {
213215
kernel_length = (long)(_end) - (long)(_text);

0 commit comments

Comments
 (0)