diff options
author | Andi Kleen <ak@suse.de> | 2006-03-25 10:29:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-25 12:10:53 -0500 |
commit | 681558fdb5848f0a6dc248108f0f7323f7380857 (patch) | |
tree | 275df1a007f74837c6d23b5c5987b85804ab22f3 | |
parent | 86ebcea899ff01274c1e8e15bf1d1f1cf5fac471 (diff) |
[PATCH] x86_64: Check that early arguments are words on their own
We've always had the problem that arguments only did a prefix match,
which resulted e.g. in noapic and noapictimer getting confused.
Fix the early argument parsing code to always check that arguments are
whole words (except for those that take additional arguments of course)
I factored out the checking code for that while also makes the code
easier to maintain.
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/x86_64/kernel/setup.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c index 6ca07eaa26db..01e2de4d2540 100644 --- a/arch/x86_64/kernel/setup.c +++ b/arch/x86_64/kernel/setup.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/cpufreq.h> | 46 | #include <linux/cpufreq.h> |
47 | #include <linux/dmi.h> | 47 | #include <linux/dmi.h> |
48 | #include <linux/dma-mapping.h> | 48 | #include <linux/dma-mapping.h> |
49 | #include <linux/ctype.h> | ||
49 | 50 | ||
50 | #include <asm/mtrr.h> | 51 | #include <asm/mtrr.h> |
51 | #include <asm/uaccess.h> | 52 | #include <asm/uaccess.h> |
@@ -270,6 +271,13 @@ static void __init probe_roms(void) | |||
270 | } | 271 | } |
271 | } | 272 | } |
272 | 273 | ||
274 | /* Check for full argument with no trailing characters */ | ||
275 | static int fullarg(char *p, char *arg) | ||
276 | { | ||
277 | int l = strlen(arg); | ||
278 | return !memcmp(p, arg, l) && (p[l] == 0 || isspace(p[l])); | ||
279 | } | ||
280 | |||
273 | static __init void parse_cmdline_early (char ** cmdline_p) | 281 | static __init void parse_cmdline_early (char ** cmdline_p) |
274 | { | 282 | { |
275 | char c = ' ', *to = command_line, *from = COMMAND_LINE; | 283 | char c = ' ', *to = command_line, *from = COMMAND_LINE; |
@@ -293,10 +301,10 @@ static __init void parse_cmdline_early (char ** cmdline_p) | |||
293 | #endif | 301 | #endif |
294 | #ifdef CONFIG_ACPI | 302 | #ifdef CONFIG_ACPI |
295 | /* "acpi=off" disables both ACPI table parsing and interpreter init */ | 303 | /* "acpi=off" disables both ACPI table parsing and interpreter init */ |
296 | if (!memcmp(from, "acpi=off", 8)) | 304 | if (fullarg(from,"acpi=off")) |
297 | disable_acpi(); | 305 | disable_acpi(); |
298 | 306 | ||
299 | if (!memcmp(from, "acpi=force", 10)) { | 307 | if (fullarg(from, "acpi=force")) { |
300 | /* add later when we do DMI horrors: */ | 308 | /* add later when we do DMI horrors: */ |
301 | acpi_force = 1; | 309 | acpi_force = 1; |
302 | acpi_disabled = 0; | 310 | acpi_disabled = 0; |
@@ -304,52 +312,47 @@ static __init void parse_cmdline_early (char ** cmdline_p) | |||
304 | 312 | ||
305 | /* acpi=ht just means: do ACPI MADT parsing | 313 | /* acpi=ht just means: do ACPI MADT parsing |
306 | at bootup, but don't enable the full ACPI interpreter */ | 314 | at bootup, but don't enable the full ACPI interpreter */ |
307 | if (!memcmp(from, "acpi=ht", 7)) { | 315 | if (fullarg(from, "acpi=ht")) { |
308 | if (!acpi_force) | 316 | if (!acpi_force) |
309 | disable_acpi(); | 317 | disable_acpi(); |
310 | acpi_ht = 1; | 318 | acpi_ht = 1; |
311 | } | 319 | } |
312 | else if (!memcmp(from, "pci=noacpi", 10)) | 320 | else if (fullarg(from, "pci=noacpi")) |
313 | acpi_disable_pci(); | 321 | acpi_disable_pci(); |
314 | else if (!memcmp(from, "acpi=noirq", 10)) | 322 | else if (fullarg(from, "acpi=noirq")) |
315 | acpi_noirq_set(); | 323 | acpi_noirq_set(); |
316 | 324 | ||
317 | else if (!memcmp(from, "acpi_sci=edge", 13)) | 325 | else if (fullarg(from, "acpi_sci=edge")) |
318 | acpi_sci_flags.trigger = 1; | 326 | acpi_sci_flags.trigger = 1; |
319 | else if (!memcmp(from, "acpi_sci=level", 14)) | 327 | else if (fullarg(from, "acpi_sci=level")) |
320 | acpi_sci_flags.trigger = 3; | 328 | acpi_sci_flags.trigger = 3; |
321 | else if (!memcmp(from, "acpi_sci=high", 13)) | 329 | else if (fullarg(from, "acpi_sci=high")) |
322 | acpi_sci_flags.polarity = 1; | 330 | acpi_sci_flags.polarity = 1; |
323 | else if (!memcmp(from, "acpi_sci=low", 12)) | 331 | else if (fullarg(from, "acpi_sci=low")) |
324 | acpi_sci_flags.polarity = 3; | 332 | acpi_sci_flags.polarity = 3; |
325 | 333 | ||
326 | /* acpi=strict disables out-of-spec workarounds */ | 334 | /* acpi=strict disables out-of-spec workarounds */ |
327 | else if (!memcmp(from, "acpi=strict", 11)) { | 335 | else if (fullarg(from, "acpi=strict")) { |
328 | acpi_strict = 1; | 336 | acpi_strict = 1; |
329 | } | 337 | } |
330 | #ifdef CONFIG_X86_IO_APIC | 338 | #ifdef CONFIG_X86_IO_APIC |
331 | else if (!memcmp(from, "acpi_skip_timer_override", 24)) | 339 | else if (fullarg(from, "acpi_skip_timer_override")) |
332 | acpi_skip_timer_override = 1; | 340 | acpi_skip_timer_override = 1; |
333 | #endif | 341 | #endif |
334 | #endif | 342 | #endif |
335 | 343 | ||
336 | if (!memcmp(from, "disable_timer_pin_1", 19)) | 344 | if (fullarg(from, "disable_timer_pin_1")) |
337 | disable_timer_pin_1 = 1; | 345 | disable_timer_pin_1 = 1; |
338 | if (!memcmp(from, "enable_timer_pin_1", 18)) | 346 | if (fullarg(from, "enable_timer_pin_1")) |
339 | disable_timer_pin_1 = -1; | 347 | disable_timer_pin_1 = -1; |
340 | 348 | ||
341 | if (!memcmp(from, "nolapic", 7) || | 349 | if (fullarg(from, "nolapic") || fullarg(from, "disableapic")) |
342 | !memcmp(from, "disableapic", 11)) | ||
343 | disable_apic = 1; | 350 | disable_apic = 1; |
344 | 351 | ||
345 | /* Don't confuse with noapictimer */ | 352 | if (fullarg(from, "noapic")) |
346 | if (!memcmp(from, "noapic", 6) && | ||
347 | (from[6] == ' ' || from[6] == 0)) | ||
348 | skip_ioapic_setup = 1; | 353 | skip_ioapic_setup = 1; |
349 | 354 | ||
350 | /* Make sure to not confuse with apic= */ | 355 | if (fullarg(from,"apic")) { |
351 | if (!memcmp(from, "apic", 4) && | ||
352 | (from[4] == ' ' || from[4] == 0)) { | ||
353 | skip_ioapic_setup = 0; | 356 | skip_ioapic_setup = 0; |
354 | ioapic_force = 1; | 357 | ioapic_force = 1; |
355 | } | 358 | } |
@@ -388,7 +391,7 @@ static __init void parse_cmdline_early (char ** cmdline_p) | |||
388 | iommu_setup(from+6); | 391 | iommu_setup(from+6); |
389 | } | 392 | } |
390 | 393 | ||
391 | if (!memcmp(from,"oops=panic", 10)) | 394 | if (fullarg(from,"oops=panic")) |
392 | panic_on_oops = 1; | 395 | panic_on_oops = 1; |
393 | 396 | ||
394 | if (!memcmp(from, "noexec=", 7)) | 397 | if (!memcmp(from, "noexec=", 7)) |