Skip to contentSkip to conversation

x86_64 built-in command line

PATCH In review Matt Mackall 6 participants 18 messages Jul 31, 2006 – Aug 1, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86_64 built-in command line

Allow setting a command line at build time on x86_64. Compiled but not tested.

arch/x86_64/Kconfig +14 -0
Index: linux/arch/x86_64/Kconfig
===================================================================
@@ -558,6 +558,20 @@ config K8_NB
 	def_bool y
 	depends on AGP_AMD64 || IOMMU || (PCI && NUMA)
 
+config CMDLINE_BOOL
+	bool "Default bootloader kernel arguments" if EMBEDDED
+
+config CMDLINE
+	string "Initial kernel command string" if EMBEDDED
+	depends on CMDLINE_BOOL
+	default "root=/dev/hda1 ro"
+	help
+	  On some systems, there is no way for the boot loader to pass
+	  arguments to the kernel. For these platforms, you can supply
+	  some command-line options at build time by entering them
+	  here. In most cases you will need to specify the root device
+	  here.
+
 endmenu
 
 #
arch/x86_64/kernel/setup.c +4 -0
Index: linux/arch/x86_64/kernel/setup.c
===================================================================
@@ -289,6 +289,10 @@ static __init void parse_cmdline_early (
 	int len = 0;
 	int userdef = 0;
 
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif
+
 	for (;;) {
 		if (c != ' ') 
 			goto next_char; 
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#1 lore raw
Quoted 47 lines · Matt Mackall

Allow setting a command line at build time on x86_64. Compiled but not tested.

Index: linux/arch/x86_64/Kconfig
===================================================================

arch/x86_64/Kconfig +14 -0
@@ -558,6 +558,20 @@ config K8_NB
 	def_bool y
 	depends on AGP_AMD64 || IOMMU || (PCI && NUMA)
 
+config CMDLINE_BOOL
+	bool "Default bootloader kernel arguments" if EMBEDDED
+
+config CMDLINE
+	string "Initial kernel command string" if EMBEDDED
+	depends on CMDLINE_BOOL
+	default "root=/dev/hda1 ro"
+	help
+	  On some systems, there is no way for the boot loader to pass
+	  arguments to the kernel. For these platforms, you can supply
+	  some command-line options at build time by entering them
+	  here. In most cases you will need to specify the root device
+	  here.
+

endmenu

#
Index: linux/arch/x86_64/kernel/setup.c
===================================================================

arch/x86_64/kernel/setup.c +4 -1
@@ -289,6 +289,10 @@ static __init void parse_cmdline_early (
 	int len = 0;
 	int userdef = 0;
 
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif
+
 	for (;;) {
 		if (c != ' ')
 			goto next_char;
 
--
Quoted 2 lines

Mathematics is the supreme nostalgia of our time.
-

But this just makes it nice for __your__ embedded system. I suggest you use:

arch/x86_64/kernel/setup.c

Quoted 1 line
arch/x86_64/kernel/setup.c +1 -0
+	default "root=/dev/root ro"

The boot setup code makes a symlink to whatever your specific setup requires.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.24 on an i686 machine (5592.62 BogoMips). New book: http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#2 lore raw
In reply to Matt Mackall

arch/x86_64/kernel/setup.c static __init void parse_cmdline_early ( · line 294

Quoted 4 lines
arch/x86_64/kernel/setup.c +3 -0
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif

I think I would prefer a strcat.

Also you should describe the exact behaviour (override/append) in Kconfig help.

-Andi

#3 lore raw
Quoted 9 lines · Andi Kleen

arch/x86_64/kernel/setup.c static __init void parse_cmdline_early ( · line 294

Quoted 4 lines
arch/x86_64/kernel/setup.c +3 -0
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif

I think I would prefer a strcat.

Also you should describe the exact behaviour (override/append) in Kconfig help.

In the i386 thread, Matt described having a firmware bootloader which passes bogus parameters. For that case, it would make sense to have a non-default CONFIG option to have override rather than conjoined (and I maintain that the built-in command line should be prepended.)

-hpa

#4 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Andi Kleen

arch/x86_64/kernel/setup.c static __init void parse_cmdline_early ( · line 294

Quoted 4 lines
arch/x86_64/kernel/setup.c +3 -0
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif

I think I would prefer a strcat.

Quoted 7 lines
Quoted 2 lines

Also you should describe the exact behaviour (override/append) in Kconfig help.

In the i386 thread, Matt described having a firmware bootloader which passes bogus parameters. For that case, it would make sense to have a non-default CONFIG option to have override rather than conjoined (and I maintain that the built-in command line should be prepended.)

Is that boot loader common? What's its name?
If not I would prefer that he keeps the one liner patch to deal with that private.

For generic semantics strcat (or possible prepend) is probably better.

-Andi

#5 lore raw
Quoted 17 lines · Andi Kleen
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Andi Kleen

arch/x86_64/kernel/setup.c static __init void parse_cmdline_early ( · line 294

Quoted 4 lines
arch/x86_64/kernel/setup.c +3 -0
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif

I think I would prefer a strcat.

Quoted 7 lines
Quoted 2 lines

Also you should describe the exact behaviour (override/append) in Kconfig help.

In the i386 thread, Matt described having a firmware bootloader which passes bogus parameters. For that case, it would make sense to have a non-default CONFIG option to have override rather than conjoined (and I maintain that the built-in command line should be prepended.)

Quoted 5 lines

Is that boot loader common? What's its name?
If not I would prefer that he keeps the one liner patch to deal with that private.

For generic semantics strcat (or possible prepend) is probably better.

No, it doesn't work for numerous kernel options that can't be negated.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#6 lore raw
Quoted 11 lines · Matt Mackall
Quoted 10 lines · Andi Kleen
Quoted 9 lines · H. Peter Anvin
Quoted 8 lines · Andi Kleen

arch/x86_64/kernel/setup.c static __init void parse_cmdline_early ( · line 294

Quoted 4 lines
arch/x86_64/kernel/setup.c +3 -0
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif

I think I would prefer a strcat.

Also you should describe the exact behaviour (override/append) in Kconfig help.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

In the i386 thread, Matt described having a firmware bootloader which passes bogus parameters. For that case, it would make sense to have a non-default CONFIG option to have override rather than conjoined (and I maintain that the built-in command line should be prepended.)

Is that boot loader common? What's its name? If not I would prefer that he keeps the one liner patch to deal with that private.

For generic semantics strcat (or possible prepend) is probably better.

No, it doesn't work for numerous kernel options that can't be negated.

How about we fix the real problem, then?

-hpa

#7 lore raw
In reply to Matt Mackall
Quoted 5 lines · Matt Mackall
Quoted 2 lines

For generic semantics strcat (or possible prepend) is probably better.

No, it doesn't work for numerous kernel options that can't be negated.

Anyway, there are four possible behaviours: builtin only, bootloader only, buildin+bootloader, and bootloader+builtin. I believe the last is the most appropriate default, but there really is no reason why this can't be a four-way configuration option.

-hpa

#8 lore raw
In reply to Matt Mackall

Actually, the best thing to do might be to designate a symbol (say &, like in automount) as "insert the boot loader command line here."

That way you can specify things in the builtin command line that are both prepended and appended to the boot loader command, and if you wish, you can emit it completely.

The default would be just "&".

-hpa

#9 lore raw
Quoted 8 lines · H. Peter Anvin

Actually, the best thing to do might be to designate a symbol (say &, like in automount) as "insert the boot loader command line here."

That way you can specify things in the builtin command line that are both prepended and appended to the boot loader command, and if you wish, you can emit it completely.

The default would be just "&".

That idea doesn't suck. I'll take a look at it.

We still have a problem with overriding things like console=tty, for which there's no obvious fix that doesn't break the world.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#10 lore raw
Quoted 11 lines · Matt Mackall
Quoted 8 lines · H. Peter Anvin

Actually, the best thing to do might be to designate a symbol (say &, like in automount) as "insert the boot loader command line here."

That way you can specify things in the builtin command line that are both prepended and appended to the boot loader command, and if you wish, you can emit it completely.

The default would be just "&".

That idea doesn't suck. I'll take a look at it.

With %s it would be much less code to write.

-Andi

#11 lore raw
Quoted 11 lines · Andi Kleen
Quoted 7 lines · Matt Mackall
Quoted 5 lines · H. Peter Anvin

Actually, the best thing to do might be to designate a symbol (say &, like in automount) as "insert the boot loader command line here."

That way you can specify things in the builtin command line that are both prepended and appended to the boot loader command, and if you wish, you can emit it completely.

The default would be just "&".

That idea doesn't suck. I'll take a look at it.

With %s it would be much less code to write.

True; it would just mean that the buildin command line would have to double %'s, but that's not really a problem.

On the other hand, a single-character substitution loop is hardly complex.

-hpa

#12 lore raw
Quoted 3 lines

True; it would just mean that the buildin command line would have to double %'s, but that's not really a problem.

Similar for &s

-Andi

#13 lore raw
In reply to Matt Mackall
Quoted 6 lines · Matt Mackall

That idea doesn't suck. I'll take a look at it.

We still have a problem with overriding things like console=tty, for which there's no obvious fix that doesn't break the world.

One could define "console=" (empty argument) as a command to reset the list. It probably would be useful.

-hpa

#14 lore raw
In reply to Matt Mackall
Quoted 18 lines · On Mon, 31 Jul 2006 20:43:19 -0500 Matt Mackall <[email protected]> wrote:
Quoted 17 lines · Andi Kleen
Quoted 15 lines · H. Peter Anvin
Quoted 9 lines · Andi Kleen

arch/x86_64/kernel/setup.c static __init void parse_cmdline_early ( · line 294

Quoted 4 lines
arch/x86_64/kernel/setup.c +3 -0
+#ifdef CONFIG_CMDLINE_BOOL
+	strlcpy(saved_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+#endif

I think I would prefer a strcat.

Also you should describe the exact behaviour (override/append) in Kconfig help.

In the i386 thread, Matt described having a firmware bootloader which passes bogus parameters. For that case, it would make sense to have a non-default CONFIG option to have override rather than conjoined (and I maintain that the built-in command line should be prepended.)

Quoted 7 lines
Quoted 5 lines

Is that boot loader common? What's its name?
If not I would prefer that he keeps the one liner patch to deal with that private.

For generic semantics strcat (or possible prepend) is probably better.

No, it doesn't work for numerous kernel options that can't be negated.

I think what I'm hearing is that we need three options: append, prepend or replace.

#15 lore raw
In reply to Matt Mackall

On Jul 31 2006, at 12:14, Matt Mackall was caught saying:

Quoted 2 lines

Allow setting a command line at build time on x86_64. Compiled but not tested.

Can we just make this into a generic option and put the relevant strcpy (strcat) in init/main.c. We've supported a default in-kernel command line on ARM for sometime now and I think it would be best to just have a single implementation.

~Deepak

Signature · 3 lines
Deepak Saxena - [email protected] - http://www.plexity.net

"An open heart has no possessions, only experiences" - Matt Bibbeau
#16 lore raw
Quoted 8 lines · Deepak Saxena

On Jul 31 2006, at 12:14, Matt Mackall was caught saying:

Quoted 2 lines

Allow setting a command line at build time on x86_64. Compiled but not tested.

Can we just make this into a generic option and put the relevant strcpy (strcat) in init/main.c. We've supported a default in-kernel command line on ARM for sometime now and I think it would be best to just have a single implementation.

One problem is that some architectures (like i386/x86-64) have early boot arguments that are processed before init/main

-Andi

#17 lore raw
In reply to Deepak Saxena
Quoted 9 lines · Deepak Saxena

On Jul 31 2006, at 12:14, Matt Mackall was caught saying:

Quoted 2 lines

Allow setting a command line at build time on x86_64. Compiled but not tested.

Can we just make this into a generic option and put the relevant strcpy (strcat) in init/main.c. We've supported a default in-kernel command line on ARM for sometime now and I think it would be best to just have a single implementation.

Yes on the generic option, no on putting it in init/main.c... on a lot of architectures, some parsing of the command line happens *very* early, sometimes even before the C code is invoked.

-hpa