1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/types.h>
3 #include <linux/init.h>
4 #include <linux/libfdt.h>
5 #include <linux/string.h>
6 #include <asm/pgtable.h>
11 static char early_cmdline
[COMMAND_LINE_SIZE
];
13 static char *get_early_cmdline(uintptr_t dtb_pa
)
15 const char *fdt_cmdline
= NULL
;
16 unsigned int fdt_cmdline_size
= 0;
19 if (!IS_ENABLED(CONFIG_CMDLINE_FORCE
)) {
20 chosen_node
= fdt_path_offset((void *)dtb_pa
, "/chosen");
21 if (chosen_node
>= 0) {
22 fdt_cmdline
= fdt_getprop((void *)dtb_pa
, chosen_node
,
25 fdt_cmdline_size
= strlen(fdt_cmdline
);
26 strscpy(early_cmdline
, fdt_cmdline
,
32 if (IS_ENABLED(CONFIG_CMDLINE_EXTEND
) ||
33 IS_ENABLED(CONFIG_CMDLINE_FORCE
) ||
34 fdt_cmdline_size
== 0 /* CONFIG_CMDLINE_FALLBACK */) {
35 strlcat(early_cmdline
, CONFIG_CMDLINE
, COMMAND_LINE_SIZE
);
41 static u64
match_noXlvl(char *cmdline
)
43 if (strstr(cmdline
, "no4lvl"))
45 else if (strstr(cmdline
, "no5lvl"))
51 u64
set_satp_mode_from_cmdline(uintptr_t dtb_pa
)
53 char *cmdline
= get_early_cmdline(dtb_pa
);
55 return match_noXlvl(cmdline
);
58 static bool match_nokaslr(char *cmdline
)
60 return strstr(cmdline
, "nokaslr");
63 bool set_nokaslr_from_cmdline(uintptr_t dtb_pa
)
65 char *cmdline
= get_early_cmdline(dtb_pa
);
67 return match_nokaslr(cmdline
);