unify kernel command line handling
We now use MIPS_CMDLINE_DTB_EXTEND for all boot varieties (tftpboot, flash boot, kexec) with the addition of MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE - local patch - so that the bootloader args are ignored unless they contain the string "liminix"
This commit is contained in:
parent
1c36f1b373
commit
a5cfa37ed3
6 changed files with 74 additions and 10 deletions
|
@ -79,6 +79,10 @@ in {
|
||||||
MODULE_SIG = "y";
|
MODULE_SIG = "y";
|
||||||
DEBUG_FS = "y";
|
DEBUG_FS = "y";
|
||||||
|
|
||||||
|
MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE = "y";
|
||||||
|
MIPS_BOOTLOADER_CMDLINE_COOKIE = "\"liminix\"";
|
||||||
|
MIPS_CMDLINE_DTB_EXTEND = "y";
|
||||||
|
|
||||||
# basic networking protocols
|
# basic networking protocols
|
||||||
NET = "y";
|
NET = "y";
|
||||||
UNIX = "y";
|
UNIX = "y";
|
||||||
|
|
|
@ -14,10 +14,6 @@ in {
|
||||||
kernel = {
|
kernel = {
|
||||||
config = {
|
config = {
|
||||||
MTD_SPLIT_UIMAGE_FW = "y";
|
MTD_SPLIT_UIMAGE_FW = "y";
|
||||||
# ignore the commandline provided by U-Boot because it's most
|
|
||||||
# likely wrong
|
|
||||||
MIPS_CMDLINE_FROM_BOOTLOADER = lib.mkForce "n";
|
|
||||||
MIPS_CMDLINE_FROM_DTB = "y";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,6 @@ in {
|
||||||
config = {
|
config = {
|
||||||
boot.ramdisk.enable = true;
|
boot.ramdisk.enable = true;
|
||||||
|
|
||||||
kernel.config.MIPS_CMDLINE_FROM_DTB = "y";
|
|
||||||
kernel.config.MIPS_CMDLINE_FROM_BOOTLOADER = mkForce "n";
|
|
||||||
|
|
||||||
outputs.kexecboot =
|
outputs.kexecboot =
|
||||||
let o = config.outputs; in
|
let o = config.outputs; in
|
||||||
pkgs.runCommand "kexecboot" {} ''
|
pkgs.runCommand "kexecboot" {} ''
|
||||||
|
|
|
@ -11,7 +11,6 @@ in {
|
||||||
imports = [ ./ramdisk.nix ];
|
imports = [ ./ramdisk.nix ];
|
||||||
config = {
|
config = {
|
||||||
boot.ramdisk.enable = true;
|
boot.ramdisk.enable = true;
|
||||||
kernel.config.MIPS_CMDLINE_FROM_BOOTLOADER = "y";
|
|
||||||
|
|
||||||
outputs.tftpboot =
|
outputs.tftpboot =
|
||||||
let o = config.outputs; in
|
let o = config.outputs; in
|
||||||
|
@ -35,12 +34,12 @@ in {
|
||||||
squashfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize)))
|
squashfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize)))
|
||||||
squashfsBytes=$(($(stat -L -c %s ${config.outputs.squashfs}) + 0x100000 &(~0xfffff)))
|
squashfsBytes=$(($(stat -L -c %s ${config.outputs.squashfs}) + 0x100000 &(~0xfffff)))
|
||||||
squashfsMb=$(($squashfsBytes >> 20))
|
squashfsMb=$(($squashfsBytes >> 20))
|
||||||
cmd="mtdparts=phram0:''${squashfsMb}M(nix) phram.phram=phram0,''${squashfsStart},''${squashfsMb}Mi memmap=''${squashfsMb}M\$''${squashfsStart} root=1f00";
|
cmd="mtdparts=phram0:''${squashfsMb}M(rootfs) phram.phram=phram0,''${squashfsStart},''${squashfsMb}Mi memmap=''${squashfsMb}M\$''${squashfsStart} root=1f00";
|
||||||
|
|
||||||
cat > $out << EOF
|
cat > $out << EOF
|
||||||
setenv serverip ${cfg.serverip}
|
setenv serverip ${cfg.serverip}
|
||||||
setenv ipaddr ${cfg.ipaddr}
|
setenv ipaddr ${cfg.ipaddr}
|
||||||
setenv bootargs '${concatStringsSep " " config.boot.commandLine} $cmd'
|
setenv bootargs 'liminix $cmd'
|
||||||
tftp 0x$(printf %x ${cfg.loadAddress}) result/uimage ; tftp 0x$(printf %x $squashfsStart) result/squashfs
|
tftp 0x$(printf %x ${cfg.loadAddress}) result/uimage ; tftp 0x$(printf %x $squashfsStart) result/squashfs
|
||||||
bootm 0x$(printf %x ${cfg.loadAddress})
|
bootm 0x$(printf %x ${cfg.loadAddress})
|
||||||
EOF
|
EOF
|
||||||
|
|
63
pkgs/kernel/cmdline-cookie.patch
Normal file
63
pkgs/kernel/cmdline-cookie.patch
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
|
||||||
|
index 393eb2133243..f61bfbaa4001 100644
|
||||||
|
--- a/arch/mips/Kconfig
|
||||||
|
+++ b/arch/mips/Kconfig
|
||||||
|
@@ -3157,6 +3157,24 @@ choice
|
||||||
|
if you don't intend to always append a DTB.
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
+config MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE
|
||||||
|
+ bool "Ignore bootloader command-line unless cookie present"
|
||||||
|
+ default n
|
||||||
|
+
|
||||||
|
+config MIPS_BOOTLOADER_CMDLINE_COOKIE
|
||||||
|
+ string "Bootloader kernel argument cookie string"
|
||||||
|
+ depends on MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE
|
||||||
|
+ help
|
||||||
|
+ Use bootloader command line if and only if it contains
|
||||||
|
+ this string. Some bootloaders allow setting the command line
|
||||||
|
+ for interactive boots but provide an incorrect (and
|
||||||
|
+ unchangeable) default when booting unattended.
|
||||||
|
+
|
||||||
|
+ This option can be combined with e.g. MIPS_CMDLINE_DTB_EXTEND
|
||||||
|
+ or MIPS_CMDLINE_BUILTIN_EXTEND: it doesn't affect
|
||||||
|
+ where else your command line comes from, just whether
|
||||||
|
+ the bootloader-provided command line is used as part of it.
|
||||||
|
+
|
||||||
|
choice
|
||||||
|
prompt "Kernel command line type" if !CMDLINE_OVERRIDE
|
||||||
|
default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \
|
||||||
|
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
|
||||||
|
index ef73ba1e0ec1..52a836c43630 100644
|
||||||
|
--- a/arch/mips/kernel/setup.c
|
||||||
|
+++ b/arch/mips/kernel/setup.c
|
||||||
|
@@ -72,6 +72,12 @@ static const char builtin_cmdline[] __initconst = CONFIG_CMDLINE;
|
||||||
|
static const char builtin_cmdline[] __initconst = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#ifdef CONFIG_MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE
|
||||||
|
+static const char cmdline_cookie[] __initconst = CONFIG_MIPS_BOOTLOADER_CMDLINE_COOKIE;
|
||||||
|
+#else
|
||||||
|
+static const char cmdline_cookie[] __initconst = NULL;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* mips_io_port_base is the begin of the address space to which x86 style
|
||||||
|
* I/O ports are mapped.
|
||||||
|
@@ -558,6 +564,16 @@ static void __init bootcmdline_init(void)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* If CMDLINE_REQUIRE_COOKIE is set to a string, we require that
|
||||||
|
+ * string to be present in the bootloader command line, otherwise
|
||||||
|
+ * we ignore it. This is to accommodate bootloaders that allow
|
||||||
|
+ * the command line to be specified for interactive boots but
|
||||||
|
+ * hardcode an incorrect command line for unattended boots */
|
||||||
|
+#ifdef CONFIG_MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE
|
||||||
|
+ if(strstr(arcs_cmdline, cmdline_cookie) == NULL) {
|
||||||
|
+ arcs_cmdline[0] = '\0';
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
/*
|
||||||
|
* If the user specified a built-in command line &
|
||||||
|
* MIPS_CMDLINE_BUILTIN_EXTEND, then the built-in command line is
|
|
@ -41,6 +41,7 @@ stdenv.mkDerivation rec {
|
||||||
"unpackPhase"
|
"unpackPhase"
|
||||||
"butcherPkgconfig"
|
"butcherPkgconfig"
|
||||||
"extraPatchPhase"
|
"extraPatchPhase"
|
||||||
|
"patchPhase"
|
||||||
"patchScripts"
|
"patchScripts"
|
||||||
"configurePhase"
|
"configurePhase"
|
||||||
"checkConfigurationPhase"
|
"checkConfigurationPhase"
|
||||||
|
@ -48,6 +49,10 @@ stdenv.mkDerivation rec {
|
||||||
"installPhase"
|
"installPhase"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./cmdline-cookie.patch
|
||||||
|
];
|
||||||
|
|
||||||
# this is here to work around what I think is a bug in nixpkgs
|
# this is here to work around what I think is a bug in nixpkgs
|
||||||
# packaging of ncurses: it installs pkg-config data files which
|
# packaging of ncurses: it installs pkg-config data files which
|
||||||
# don't produce any -L options when queried with "pkg-config --lib
|
# don't produce any -L options when queried with "pkg-config --lib
|
||||||
|
|
Loading…
Reference in a new issue