~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/riscv/kernel/pi/cmdline_early.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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>
  8 
  9 static char early_cmdline[COMMAND_LINE_SIZE];
 10 
 11 /*
 12  * Declare the functions that are exported (but prefixed) here so that LLVM
 13  * does not complain it lacks the 'static' keyword (which, if added, makes
 14  * LLVM complain because the function is actually unused in this file).
 15  */
 16 u64 set_satp_mode_from_cmdline(uintptr_t dtb_pa);
 17 bool set_nokaslr_from_cmdline(uintptr_t dtb_pa);
 18 
 19 static char *get_early_cmdline(uintptr_t dtb_pa)
 20 {
 21         const char *fdt_cmdline = NULL;
 22         unsigned int fdt_cmdline_size = 0;
 23         int chosen_node;
 24 
 25         if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
 26                 chosen_node = fdt_path_offset((void *)dtb_pa, "/chosen");
 27                 if (chosen_node >= 0) {
 28                         fdt_cmdline = fdt_getprop((void *)dtb_pa, chosen_node,
 29                                                   "bootargs", NULL);
 30                         if (fdt_cmdline) {
 31                                 fdt_cmdline_size = strlen(fdt_cmdline);
 32                                 strscpy(early_cmdline, fdt_cmdline,
 33                                         COMMAND_LINE_SIZE);
 34                         }
 35                 }
 36         }
 37 
 38         if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
 39             IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
 40             fdt_cmdline_size == 0 /* CONFIG_CMDLINE_FALLBACK */) {
 41                 strlcat(early_cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 42         }
 43 
 44         return early_cmdline;
 45 }
 46 
 47 static u64 match_noXlvl(char *cmdline)
 48 {
 49         if (strstr(cmdline, "no4lvl"))
 50                 return SATP_MODE_48;
 51         else if (strstr(cmdline, "no5lvl"))
 52                 return SATP_MODE_57;
 53 
 54         return 0;
 55 }
 56 
 57 u64 set_satp_mode_from_cmdline(uintptr_t dtb_pa)
 58 {
 59         char *cmdline = get_early_cmdline(dtb_pa);
 60 
 61         return match_noXlvl(cmdline);
 62 }
 63 
 64 static bool match_nokaslr(char *cmdline)
 65 {
 66         return strstr(cmdline, "nokaslr");
 67 }
 68 
 69 bool set_nokaslr_from_cmdline(uintptr_t dtb_pa)
 70 {
 71         char *cmdline = get_early_cmdline(dtb_pa);
 72 
 73         return match_nokaslr(cmdline);
 74 }
 75 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php