* [PATCH] bring initial context to a known state
@ 2007-10-07 15:42 Robert Millan
2007-10-10 15:01 ` Marcin Kurek
0 siblings, 1 reply; 3+ messages in thread
From: Robert Millan @ 2007-10-07 15:42 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 332 bytes --]
When GRUB starts initial_context is in an unknown state. This can lead to
GRUB detecting bogus variables from it. Attached patch zeroes that struct
during initialisation to avoid that.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
[-- Attachment #2: env_init.diff --]
[-- Type: text/x-diff, Size: 1191 bytes --]
2007-10-07 Robert Millan <rmh@aybabtu.com>
* kern/env.c (grub_env_init): New function. Set initial_context
struct to zero.
* kern/main.c (grub_main): Call grub_env_init() after
grub_machine_init().
diff -ur grub2/kern/env.c grub2.env_init/kern/env.c
--- grub2/kern/env.c 2007-07-22 01:32:26.000000000 +0200
+++ grub2.env_init/kern/env.c 2007-10-07 17:36:44.000000000 +0200
@@ -47,6 +47,13 @@
/* The current context. */
static struct grub_env_context *current_context = &initial_context;
+/* Bring initial context to a known state. */
+void
+grub_env_init ()
+{
+ grub_memset (&initial_context, 0, sizeof(initial_context));
+}
+
/* Return the hash representation of the string S. */
static unsigned int
grub_env_hashval (const char *s)
diff -ur grub2/kern/main.c grub2.env_init/kern/main.c
--- grub2/kern/main.c 2007-07-22 01:32:26.000000000 +0200
+++ grub2.env_init/kern/main.c 2007-10-07 17:36:44.000000000 +0200
@@ -112,6 +112,9 @@
/* First of all, initialize the machine. */
grub_machine_init ();
+ /* Initialize context. */
+ grub_env_init ();
+
/* Hello. */
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
grub_printf ("Welcome to GRUB!\n\n");
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bring initial context to a known state
2007-10-07 15:42 [PATCH] bring initial context to a known state Robert Millan
@ 2007-10-10 15:01 ` Marcin Kurek
2007-10-15 14:03 ` Robert Millan
0 siblings, 1 reply; 3+ messages in thread
From: Marcin Kurek @ 2007-10-10 15:01 UTC (permalink / raw)
To: The development of GRUB 2
Hell[o]
> When GRUB starts initial_context is in an unknown state. This can lead to
> GRUB detecting bogus variables from it. Attached patch zeroes that struct
> during initialisation to avoid that.
This change broken command line argument handling for ieee1275.
Arguments are read by grub_machine_init() in this case and zeroing is
done just after that.
I guess it should be placed before grub_machine_init() to avoid this problem.
--
--- Marcin 'Morgoth' Kurek ---
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bring initial context to a known state
2007-10-10 15:01 ` Marcin Kurek
@ 2007-10-15 14:03 ` Robert Millan
0 siblings, 0 replies; 3+ messages in thread
From: Robert Millan @ 2007-10-15 14:03 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Oct 10, 2007 at 05:01:44PM +0200, Marcin Kurek wrote:
> Hell[o]
>
> > When GRUB starts initial_context is in an unknown state. This can lead to
> > GRUB detecting bogus variables from it. Attached patch zeroes that struct
> > during initialisation to avoid that.
>
> This change broken command line argument handling for ieee1275.
> Arguments are read by grub_machine_init() in this case and zeroing is
> done just after that.
>
> I guess it should be placed before grub_machine_init() to avoid this problem.
Uhm.. Marco pointed out that it's in the ELF standard that memory is zeroed
before load. So there isn't really a problem, and my issue was just found in
an inconsistent situation when playing with LB self-boot.
Let's kill this thread.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-15 14:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-07 15:42 [PATCH] bring initial context to a known state Robert Millan
2007-10-10 15:01 ` Marcin Kurek
2007-10-15 14:03 ` Robert Millan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.