drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / riscv / kernel / pi / cmdline_early.c
blobfbcdc9e4e14322af0cedd31343aeb9403ba2dd14
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>
7 #include <asm/setup.h>
9 #include "pi.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;
17 int chosen_node;
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,
23 "bootargs", NULL);
24 if (fdt_cmdline) {
25 fdt_cmdline_size = strlen(fdt_cmdline);
26 strscpy(early_cmdline, fdt_cmdline,
27 COMMAND_LINE_SIZE);
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);
38 return early_cmdline;
41 static u64 match_noXlvl(char *cmdline)
43 if (strstr(cmdline, "no4lvl"))
44 return SATP_MODE_48;
45 else if (strstr(cmdline, "no5lvl"))
46 return SATP_MODE_57;
48 return 0;
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);