Skip to content

Commit fd8e141

Browse files
chenhuacaigregkh
authored andcommitted
LoongArch: Use correct API to map cmdline in relocate_kernel()
[ Upstream commit 0124fbb ] 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 <[email protected]> Reviewed-by: Jiaxun Yang <[email protected]> Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 938acd8 commit fd8e141

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

@@ -170,7 +171,7 @@ unsigned long __init relocate_kernel(void)
170171
unsigned long kernel_length;
171172
unsigned long random_offset = 0;
172173
void *location_new = _text; /* Default to original kernel start */
173-
char *cmdline = early_ioremap(fw_arg1, COMMAND_LINE_SIZE); /* Boot command line is passed in fw_arg1 */
174+
char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE); /* Boot command line is passed in fw_arg1 */
174175

175176
strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
176177

@@ -182,6 +183,7 @@ unsigned long __init relocate_kernel(void)
182183
random_offset = (unsigned long)location_new - (unsigned long)(_text);
183184
#endif
184185
reloc_offset = (unsigned long)_text - VMLINUX_LOAD_ADDRESS;
186+
early_memunmap(cmdline, COMMAND_LINE_SIZE);
185187

186188
if (random_offset) {
187189
kernel_length = (long)(_end) - (long)(_text);

0 commit comments

Comments
 (0)