* Re: [ECOS] Redboots CRC checking
2004-05-27 13:22 Winkler Andreas
@ 2004-05-27 14:40 ` Gary Thomas
0 siblings, 0 replies; 7+ messages in thread
From: Gary Thomas @ 2004-05-27 14:40 UTC (permalink / raw)
To: Winkler Andreas; +Cc: eCos Discussion, eCos patches
[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]
On Thu, 2004-05-27 at 06:54, Winkler Andreas wrote:
> Hi,
>
> after some troubles i got the CRC checking to work. But it doesn't work as i
> expected.
> I need the CRC checking to prevent Redboot from executing a corrupted
> kernel.
> But Redboot only prints a message while loading.
> The execute command tries to start the kernel, and look what happens:
>
> RedBoot> fi loa kernel
> ** Warning - checksum failure. stored: 0x7ca3fe54, computed: 0xdde742c4
> RedBoot> e
> Using base address 0x01008000 and length 0x000ba7c8
> Uncompressing Linux...........
>
> invalid compressed format (err=1)
>
> -- System halted
>
> This system is defect for the use of a customer.
> I expected Redboot to not start the kernel with the checksum error.
> This would enable the start of a backup kernel in a startup script.
> Is there an existing solution for my request or must i implement it by
> myself?
I can see that the "Linux exec" code doesn't respect this failure,
sorry.
The problem is that the "Linux exec" function is [necessarily]
implemented by each architecture. Each of these need to be changed to
be sensitive to whether or not the load succeeds.
I've applied the attached patch, so this should now work as expected.
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
[-- Attachment #2: diffs --]
[-- Type: text/x-patch, Size: 14724 bytes --]
Index: hal/arm/arch/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/arm/arch/current/ChangeLog,v
retrieving revision 1.97
diff -u -5 -p -r1.97 ChangeLog
--- hal/arm/arch/current/ChangeLog 24 May 2004 12:32:09 -0000 1.97
+++ hal/arm/arch/current/ChangeLog 27 May 2004 13:21:18 -0000
@@ -1,5 +1,11 @@
+2004-05-27 Gary Thomas <gary@mlbassoc.com>
+
+ * src/redboot_linux_exec.c (do_exec): Be sensitive to value in
+ "entry_address" as this can indicate if the image to be executed
+ is valid (the "load" functions set it to "NO_MEMORY" when invalid)
+
2004-05-24 Ian Campbell <icampbell@arcom.com>
* src/hal_misc.c: __mem_fault_handler: Only do this if we have
CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS. This allows the HAL to be
compiled without stubs.
Index: hal/arm/arch/current/src/redboot_linux_exec.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/arm/arch/current/src/redboot_linux_exec.c,v
retrieving revision 1.10
diff -u -5 -p -r1.10 redboot_linux_exec.c
--- hal/arm/arch/current/src/redboot_linux_exec.c 11 Mar 2003 15:41:11 -0000 1.10
+++ hal/arm/arch/current/src/redboot_linux_exec.c 27 May 2004 13:15:12 -0000
@@ -7,11 +7,11 @@
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
-// Copyright (C) 2003 Gary Thomas
+// Copyright (C) 2003, 2004 Gary Thomas
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -312,10 +312,14 @@ do_exec(int argc, char *argv[])
(void **)&ramdisk_addr, (bool *)&ramdisk_addr_set, "ramdisk_addr");
init_opts(&opts[5], 's', true, OPTION_ARG_TYPE_NUM,
(void **)&ramdisk_size, (bool *)&ramdisk_size_set, "ramdisk_size");
if (!scan_opts(argc, argv, 1, opts, 6, (void *)&entry, OPTION_ARG_TYPE_NUM, "[physical] starting address"))
{
+ return;
+ }
+ if (entry == (unsigned long)NO_MEMORY) {
+ diag_printf("Can't execute Linux - invalid entry address\n");
return;
}
// Set up parameters to pass to kernel
Index: hal/h8300/arch/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/h8300/arch/current/ChangeLog,v
retrieving revision 1.6
diff -u -5 -p -r1.6 ChangeLog
--- hal/h8300/arch/current/ChangeLog 22 Apr 2004 15:26:34 -0000 1.6
+++ hal/h8300/arch/current/ChangeLog 27 May 2004 13:17:58 -0000
@@ -1,5 +1,11 @@
+2004-05-27 Gary Thomas <gary@mlbassoc.com>
+
+ * src/redboot_linux_exec.c (do_exec): Be sensitive to value in
+ "entry_address" as this can indicate if the image to be executed
+ is valid (the "load" functions set it to "NO_MEMORY" when invalid)
+
2004-04-22 Jani Monoses <jani@iv.ro>
* cdl/hal_h8300.cdl :
Invoke tail with stricter syntax that works in latest coreutils.
Index: hal/h8300/arch/current/src/redboot_linux_exec.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/h8300/arch/current/src/redboot_linux_exec.c,v
retrieving revision 1.2
diff -u -5 -p -r1.2 redboot_linux_exec.c
--- hal/h8300/arch/current/src/redboot_linux_exec.c 6 Apr 2004 20:33:07 -0000 1.2
+++ hal/h8300/arch/current/src/redboot_linux_exec.c 27 May 2004 13:15:34 -0000
@@ -7,10 +7,11 @@
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2004 Gary Thomas
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -78,10 +79,14 @@ do_exec(int argc, char *argv[])
&cmd_line, &command_line_set, "kernel command line");
if (!scan_opts(argc, argv, 1, opts, 2, (void *)&entry,
OPTION_ARG_TYPE_NUM, "entry address"))
return ;
+ if (entry == (unsigned long)NO_MEMORY) {
+ diag_printf("Can't execute Linux - invalid entry address\n");
+ return;
+ }
diag_printf("Now booting linux kernel:\n");
diag_printf(" Entry Address 0x%08x\n", entry);
diag_printf(" Cmdline : %s\n", cmd_line);
Index: hal/mips/arch/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/mips/arch/current/ChangeLog,v
retrieving revision 1.73
diff -u -5 -p -r1.73 ChangeLog
--- hal/mips/arch/current/ChangeLog 27 May 2004 06:26:53 -0000 1.73
+++ hal/mips/arch/current/ChangeLog 27 May 2004 13:21:09 -0000
@@ -1,5 +1,11 @@
+2004-05-27 Gary Thomas <gary@mlbassoc.com>
+
+ * src/redboot_linux_exec.c (do_exec): Be sensitive to value in
+ "entry_address" as this can indicate if the image to be executed
+ is valid (the "load" functions set it to "NO_MEMORY" when invalid)
+
2004-05-16 Andrew Dyer <adyer@righthandtech.com>
* include/hal_cache.h: Changed the calculation of _IWAY and _DWAY
for the case where HAL_MIPS_CACHE_INSN_USES_LSB is set to only
affect the LSBs in the CACHE instruction offset field. #define
Index: hal/mips/arch/current/src/redboot_linux_exec.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/mips/arch/current/src/redboot_linux_exec.c,v
retrieving revision 1.7
diff -u -5 -p -r1.7 redboot_linux_exec.c
--- hal/mips/arch/current/src/redboot_linux_exec.c 11 Mar 2003 17:14:13 -0000 1.7
+++ hal/mips/arch/current/src/redboot_linux_exec.c 27 May 2004 13:15:49 -0000
@@ -7,10 +7,11 @@
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+// Copyright (C) 2004 Gary Thomas
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -112,10 +113,14 @@ do_exec(int argc, char *argv[])
(void **)&cmd_line, &cmd_line_set, "kernel command line");
if (!scan_opts(argc, argv, 1, opts, 3, (void *)&entry,
OPTION_ARG_TYPE_NUM, "entry address"))
return;
+ if (entry == (unsigned long)NO_MEMORY) {
+ diag_printf("Can't execute Linux - invalid entry address\n");
+ return;
+ }
linux = (void *)entry;
__chan = CYGACC_CALL_IF_CONSOLE_PROCS();
baud = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
Index: hal/mn10300/am33/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/mn10300/am33/current/ChangeLog,v
retrieving revision 1.16
diff -u -5 -p -r1.16 ChangeLog
--- hal/mn10300/am33/current/ChangeLog 22 Apr 2004 15:26:47 -0000 1.16
+++ hal/mn10300/am33/current/ChangeLog 27 May 2004 13:17:52 -0000
@@ -1,5 +1,11 @@
+2004-05-27 Gary Thomas <gary@mlbassoc.com>
+
+ * src/redboot_linux_exec.c (do_exec): Be sensitive to value in
+ "entry_address" as this can indicate if the image to be executed
+ is valid (the "load" functions set it to "NO_MEMORY" when invalid)
+
2004-04-22 Jani Monoses <jani@iv.ro>
* cdl/hal_mn10300_am33.cdl :
Invoke tail with stricter syntax that works in latest coreutils.
Index: hal/mn10300/am33/current/src/redboot_linux_exec.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/mn10300/am33/current/src/redboot_linux_exec.c,v
retrieving revision 1.2
diff -u -5 -p -r1.2 redboot_linux_exec.c
--- hal/mn10300/am33/current/src/redboot_linux_exec.c 11 Mar 2003 17:14:14 -0000 1.2
+++ hal/mn10300/am33/current/src/redboot_linux_exec.c 27 May 2004 13:16:12 -0000
@@ -7,10 +7,11 @@
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+// Copyright (C) 2004 Gary Thomas
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -101,10 +102,14 @@ do_exec(int argc, char *argv[])
num_options = 2;
if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry,
OPTION_ARG_TYPE_NUM, "starting address"))
{
+ return;
+ }
+ if (entry == (unsigned long)NO_MEMORY) {
+ diag_printf("Can't execute Linux - invalid entry address\n");
return;
}
if (cmd_line_set) {
memcpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS,"cmdline:",8);
strncpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+8,cmd_line,256);
Index: hal/powerpc/arch/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/arch/current/ChangeLog,v
retrieving revision 1.64
diff -u -5 -p -r1.64 ChangeLog
--- hal/powerpc/arch/current/ChangeLog 29 Apr 2004 03:39:58 -0000 1.64
+++ hal/powerpc/arch/current/ChangeLog 27 May 2004 13:20:58 -0000
@@ -1,5 +1,11 @@
+2004-05-27 Gary Thomas <gary@mlbassoc.com>
+
+ * src/redboot_linux_exec.c (do_exec): Be sensitive to value in
+ "entry_address" as this can indicate if the image to be executed
+ is valid (the "load" functions set it to "NO_MEMORY" when invalid)
+
2004-04-29 Jonathan Larmour <jifl@eCosCentric.com>
* include/hal_arch.h (HAL_SET_GDB_FLOATING_POINT_REGISTERS): Make
absolutely safe with respect to strict-aliasing.
(HAL_SET_GDB_FLOATING_POINT_REGISTERS): Ditto.
Index: hal/powerpc/arch/current/src/redboot_linux_exec.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/arch/current/src/redboot_linux_exec.c,v
retrieving revision 1.3
diff -u -5 -p -r1.3 redboot_linux_exec.c
--- hal/powerpc/arch/current/src/redboot_linux_exec.c 29 Apr 2004 03:22:17 -0000 1.3
+++ hal/powerpc/arch/current/src/redboot_linux_exec.c 27 May 2004 13:20:27 -0000
@@ -7,11 +7,11 @@
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
-// Copyright (C) 2002, 2003 Gary Thomas
+// Copyright (C) 2002, 2003, 2004 Gary Thomas
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -116,10 +116,14 @@ do_exec(int argc, char *argv[])
init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR,
(void *)&cmd_line, (bool *)&cmd_line_set, "kernel command line");
entry = entry_address; // Default from last 'load' operation
if (!scan_opts(argc, argv, 1, opts, 2, (void *)&entry, OPTION_ARG_TYPE_NUM,
"[physical] starting address")) {
+ return;
+ }
+ if (entry == (unsigned long)NO_MEMORY) {
+ diag_printf("Can't execute Linux - invalid entry address\n");
return;
}
// Determine baud rate on current console
__chan = CYGACC_CALL_IF_CONSOLE_PROCS();
Index: hal/sh/arch/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/sh/arch/current/ChangeLog,v
retrieving revision 1.51
diff -u -5 -p -r1.51 ChangeLog
--- hal/sh/arch/current/ChangeLog 14 May 2004 12:01:56 -0000 1.51
+++ hal/sh/arch/current/ChangeLog 27 May 2004 13:20:53 -0000
@@ -1,5 +1,11 @@
+2004-05-27 Gary Thomas <gary@mlbassoc.com>
+
+ * src/redboot_linux_exec.c (do_exec): Be sensitive to value in
+ "entry_address" as this can indicate if the image to be executed
+ is valid (the "load" functions set it to "NO_MEMORY" when invalid)
+
2004-04-30 Yoshinori Sato <ysato@users.sourceforge.jp>
* src/sh.ld: Add entry section for targets, like Dreamcast, that
need special entry code.
Index: hal/sh/arch/current/src/redboot_linux_exec.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/sh/arch/current/src/redboot_linux_exec.c,v
retrieving revision 1.3
diff -u -5 -p -r1.3 redboot_linux_exec.c
--- hal/sh/arch/current/src/redboot_linux_exec.c 11 Mar 2003 17:14:15 -0000 1.3
+++ hal/sh/arch/current/src/redboot_linux_exec.c 27 May 2004 13:16:56 -0000
@@ -7,10 +7,11 @@
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+// Copyright (C) 2004 Gary Thomas
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
@@ -121,10 +122,14 @@ do_exec(int argc, char *argv[])
(void **)&cmd_line, &cmd_line_set, "kernel command line");
if (!scan_opts(argc, argv, 1, opts, 8, (void *)&entry,
OPTION_ARG_TYPE_NUM, "entry address"))
return;
+ if (entry == (unsigned long)NO_MEMORY) {
+ diag_printf("Can't execute Linux - invalid entry address\n");
+ return;
+ }
diag_printf("Now booting linux kernel:\n");
diag_printf(" Base address 0x%08x Entry 0x%08x\n", base_addr, entry);
diag_printf(" Cmdline : %s\n", cmd_line);
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 7+ messages in thread