diff options
author | Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | 2008-10-27 10:25:49 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-10-27 12:18:31 -0400 |
commit | 97b0511ce125b0cb95d73b198c1bdbb3cebc4de2 (patch) | |
tree | 0caed72319b7e270b26d82c4a61ae26628b33254 /arch/mips/txx9 | |
parent | d1a8e2a6da5bea09452495748891a4ea9e42035e (diff) |
MIPS: TXx9: Make firmware parameter passing more robust
When booting Linux on a txx9 board with VxWorks boot loader, it crashes in
prom_getenv(), as VxWorks doesn't pass firmware parameters in a0-a3 (in my
case, the actual leftover values in these registers were 0x80002000,
0x80001fe0, 0x2000, and 0x20).
Make the parsing of argc, argv, and envp a bit more robust by checking if
argc is a number below CKSEG0, and argv/envp point to CKSEG0.
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/txx9')
-rw-r--r-- | arch/mips/txx9/generic/setup.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c index 18086c549573..a13a08b8c9ec 100644 --- a/arch/mips/txx9/generic/setup.c +++ b/arch/mips/txx9/generic/setup.c | |||
@@ -156,11 +156,23 @@ static struct txx9_board_vec *__init find_board_byname(const char *name) | |||
156 | 156 | ||
157 | static void __init prom_init_cmdline(void) | 157 | static void __init prom_init_cmdline(void) |
158 | { | 158 | { |
159 | int argc = (int)fw_arg0; | 159 | int argc; |
160 | int *argv32 = (int *)fw_arg1; | 160 | int *argv32; |
161 | int i; /* Always ignore the "-c" at argv[0] */ | 161 | int i; /* Always ignore the "-c" at argv[0] */ |
162 | char builtin[CL_SIZE]; | 162 | char builtin[CL_SIZE]; |
163 | 163 | ||
164 | if (fw_arg0 >= CKSEG0 || fw_arg1 < CKSEG0) { | ||
165 | /* | ||
166 | * argc is not a valid number, or argv32 is not a valid | ||
167 | * pointer | ||
168 | */ | ||
169 | argc = 0; | ||
170 | argv32 = NULL; | ||
171 | } else { | ||
172 | argc = (int)fw_arg0; | ||
173 | argv32 = (int *)fw_arg1; | ||
174 | } | ||
175 | |||
164 | /* ignore all built-in args if any f/w args given */ | 176 | /* ignore all built-in args if any f/w args given */ |
165 | /* | 177 | /* |
166 | * But if built-in strings was started with '+', append them | 178 | * But if built-in strings was started with '+', append them |
@@ -414,10 +426,12 @@ char * __init prom_getcmdline(void) | |||
414 | 426 | ||
415 | const char *__init prom_getenv(const char *name) | 427 | const char *__init prom_getenv(const char *name) |
416 | { | 428 | { |
417 | const s32 *str = (const s32 *)fw_arg2; | 429 | const s32 *str; |
418 | 430 | ||
419 | if (!str) | 431 | if (fw_arg2 < CKSEG0) |
420 | return NULL; | 432 | return NULL; |
433 | |||
434 | str = (const s32 *)fw_arg2; | ||
421 | /* YAMON style ("name", "value" pairs) */ | 435 | /* YAMON style ("name", "value" pairs) */ |
422 | while (str[0] && str[1]) { | 436 | while (str[0] && str[1]) { |
423 | if (!strcmp((const char *)(unsigned long)str[0], name)) | 437 | if (!strcmp((const char *)(unsigned long)str[0], name)) |