public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor.
@ 2008-05-23 21:59 Kristian Høgsberg
  2008-05-23 21:59 ` [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed Kristian Høgsberg
  2008-05-24  1:07 ` [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor Rik van Riel
  0 siblings, 2 replies; 10+ messages in thread
From: Kristian Høgsberg @ 2008-05-23 21:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kristian Høgsberg

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
---
 arch/x86/boot/compressed/misc.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 90456ce..0d03579 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -30,6 +30,7 @@
 #include <asm/io.h>
 #include <asm/page.h>
 #include <asm/boot.h>
+#include <asm/bootparam.h>
 
 /* WARNING!!
  * This code is compiled with -fPIC and it is relocated dynamically
@@ -187,13 +188,8 @@ static void gzip_release(void **);
 /*
  * This is set up by the setup-routine at boot-time
  */
-static unsigned char *real_mode; /* Pointer to real-mode data */
-
-#define RM_EXT_MEM_K   (*(unsigned short *)(real_mode + 0x2))
-#ifndef STANDARD_MEMORY_BIOS_CALL
-#define RM_ALT_MEM_K   (*(unsigned long *)(real_mode + 0x1e0))
-#endif
-#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))
+static struct boot_params *real_mode;		/* Pointer to real-mode data */
+static struct screen_info *rm_screen_info;	/* Pointer to real-mode data */
 
 extern unsigned char input_data[];
 extern int input_len;
@@ -276,12 +272,12 @@ static void putstr(const char *s)
 	char c;
 
 #ifdef CONFIG_X86_32
-	if (RM_SCREEN_INFO.orig_video_mode == 0 && lines == 0 && cols == 0)
+	if (rm_screen_info->orig_video_mode == 0 && lines == 0 && cols == 0)
 		return;
 #endif
 
-	x = RM_SCREEN_INFO.orig_x;
-	y = RM_SCREEN_INFO.orig_y;
+	x = rm_screen_info->orig_x;
+	y = rm_screen_info->orig_y;
 
 	while ((c = *s++) != '\0') {
 		if (c == '\n') {
@@ -302,8 +298,8 @@ static void putstr(const char *s)
 		}
 	}
 
-	RM_SCREEN_INFO.orig_x = x;
-	RM_SCREEN_INFO.orig_y = y;
+	rm_screen_info->orig_x = x;
+	rm_screen_info->orig_y = y;
 
 	pos = (x + cols * y) * 2;	/* Update cursor position */
 	outb(14, vidport);
@@ -430,7 +426,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 {
 	real_mode = rmode;
 
-	if (RM_SCREEN_INFO.orig_video_mode == 7) {
+	if (rm_screen_info->orig_video_mode == 7) {
 		vidmem = (char *) 0xb0000;
 		vidport = 0x3b4;
 	} else {
@@ -438,8 +434,8 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 		vidport = 0x3d4;
 	}
 
-	lines = RM_SCREEN_INFO.orig_video_lines;
-	cols = RM_SCREEN_INFO.orig_video_cols;
+	lines = rm_screen_info->orig_video_lines;
+	cols = rm_screen_info->orig_video_cols;
 
 	window = output;		/* Output buffer (Normally at 1M) */
 	free_mem_ptr     = heap;	/* Heap */
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed.
  2008-05-23 21:59 [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor Kristian Høgsberg
@ 2008-05-23 21:59 ` Kristian Høgsberg
  2008-05-23 22:42   ` Johannes Weiner
  2008-05-24  9:25   ` Mikael Pettersson
  2008-05-24  1:07 ` [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor Rik van Riel
  1 sibling, 2 replies; 10+ messages in thread
From: Kristian Høgsberg @ 2008-05-23 21:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kristian Høgsberg

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
---
 arch/x86/boot/compressed/misc.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 0d03579..b7b5c1f 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -190,6 +190,7 @@ static void gzip_release(void **);
  */
 static struct boot_params *real_mode;		/* Pointer to real-mode data */
 static struct screen_info *rm_screen_info;	/* Pointer to real-mode data */
+static int noisy;
 
 extern unsigned char input_data[];
 extern int input_len;
@@ -391,7 +392,8 @@ static void parse_elf(void *output)
 		return;
 	}
 
-	putstr("Parsing ELF... ");
+	if (noisy)
+		putstr("Parsing ELF... ");
 
 	phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
 	if (!phdrs)
@@ -419,11 +421,27 @@ static void parse_elf(void *output)
 	}
 }
 
+static const char *strnstr(const char *string, int len, const char *s)
+{
+	int i, j;
+
+	for (i = 0; i < len; i++) {
+		for (j = 0; i + j < len && s[j]; j++)
+			if (string[i + j] != s[j])
+				break;
+		if (s[j] == '\0')
+			return string + i;
+	}
+
+	return NULL;
+}
 asmlinkage void decompress_kernel(void *rmode, memptr heap,
 				  unsigned char *input_data,
 				  unsigned long input_len,
 				  unsigned char *output)
 {
+	char *cmdline;
+
 	real_mode = rmode;
 
 	if (rm_screen_info->orig_video_mode == 7) {
@@ -437,6 +455,10 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 	lines = rm_screen_info->orig_video_lines;
 	cols = rm_screen_info->orig_video_cols;
 
+	cmdline = (char *) real_mode->hdr.cmd_line_ptr;
+	if (strnstr(cmdline, real_mode->hdr.cmdline_size, "noisy"))
+		noisy = 1;
+
 	window = output;		/* Output buffer (Normally at 1M) */
 	free_mem_ptr     = heap;	/* Heap */
 	free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
@@ -461,9 +483,11 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 #endif
 
 	makecrc();
-	putstr("\nDecompressing Linux... ");
+	if (noisy)
+		putstr("\nDecompressing Linux... ");
 	gunzip();
 	parse_elf(output);
-	putstr("done.\nBooting the kernel.\n");
+	if (noisy)
+		putstr("done.\nBooting the kernel.\n");
 	return;
 }
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed.
  2008-05-23 21:59 ` [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed Kristian Høgsberg
@ 2008-05-23 22:42   ` Johannes Weiner
  2008-05-24  9:25   ` Mikael Pettersson
  1 sibling, 0 replies; 10+ messages in thread
From: Johannes Weiner @ 2008-05-23 22:42 UTC (permalink / raw)
  To: Kristian Høgsberg; +Cc: linux-kernel

Hi,

Kristian Høgsberg <krh@redhat.com> writes:

> Signed-off-by: Kristian Høgsberg <krh@redhat.com>
> ---
>  arch/x86/boot/compressed/misc.c |   30 +++++++++++++++++++++++++++---
>  1 files changed, 27 insertions(+), 3 deletions(-)

Isn't that a bit much code to potentially suppress three lines of
output?

	Hannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor.
  2008-05-23 21:59 [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor Kristian Høgsberg
  2008-05-23 21:59 ` [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed Kristian Høgsberg
@ 2008-05-24  1:07 ` Rik van Riel
  2008-05-24  6:17   ` H. Peter Anvin
  1 sibling, 1 reply; 10+ messages in thread
From: Rik van Riel @ 2008-05-24  1:07 UTC (permalink / raw)
  To: Kristian Høgsberg; +Cc: linux-kernel, Kristian Høgsberg

On Fri, 23 May 2008 17:59:27 -0400
Kristian Høgsberg <krh@redhat.com> wrote:

> Signed-off-by: Kristian Høgsberg <krh@redhat.com>

Acked-by: Rik van Riel <riel@redhat.com>


> +static struct boot_params *real_mode;		/* Pointer to real-mode data */
> +static struct screen_info *rm_screen_info;	/* Pointer to real-mode data */

People who wonder why these pointers never get initialized: they
point to the zeropage, which of course lives at address zero.

/* The so-called "zeropage" */
struct boot_params {
	struct screen_info screen_info;                 /* 0x000 */
        struct apm_bios_info apm_bios_info;             /* 0x040 */
        __u8  _pad2[12];                                /* 0x054 */
        struct ist_info ist_info;                       /* 0x060 */
	...

-- 
All rights reversed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor.
  2008-05-24  1:07 ` [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor Rik van Riel
@ 2008-05-24  6:17   ` H. Peter Anvin
  2008-05-25  4:03     ` Rik van Riel
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2008-05-24  6:17 UTC (permalink / raw)
  To: Rik van Riel; +Cc: Kristian Høgsberg, linux-kernel

Rik van Riel wrote:
> 
> People who wonder why these pointers never get initialized: they
> point to the zeropage, which of course lives at address zero.
> 
> /* The so-called "zeropage" */
> struct boot_params {
> 	struct screen_info screen_info;                 /* 0x000 */
>         struct apm_bios_info apm_bios_info;             /* 0x040 */
>         __u8  _pad2[12];                                /* 0x054 */
>         struct ist_info ist_info;                       /* 0x060 */
> 	...
> 

Uhm... except it doesn't live at address zero, at all.

It's called "zeropage" because we used to recycle it into 
empty_zero_page, a long long time ago.

The bootparms structure is pointed to by %esi being passed from the 
setup code to the decompressor to the kernel.

	-hpa

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed.
  2008-05-23 21:59 ` [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed Kristian Høgsberg
  2008-05-23 22:42   ` Johannes Weiner
@ 2008-05-24  9:25   ` Mikael Pettersson
  2008-05-24 18:07     ` Diego Calleja
  1 sibling, 1 reply; 10+ messages in thread
From: Mikael Pettersson @ 2008-05-24  9:25 UTC (permalink / raw)
  To: Kristian Høgsberg; +Cc: linux-kernel

=?utf-8?q?Kristian=20H=C3=B8gsberg?= writes:
 > Signed-off-by: Kristian Høgsberg <krh@redhat.com>
 > ---
 >  arch/x86/boot/compressed/misc.c |   30 +++++++++++++++++++++++++++---
 >  1 files changed, 27 insertions(+), 3 deletions(-)

How is this an improvement? What bug does it fix?
Is there any evidence that these messages are harmful
for end-users?

All this accomplishes is to make early boot failures harder
to debug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed.
  2008-05-24  9:25   ` Mikael Pettersson
@ 2008-05-24 18:07     ` Diego Calleja
  0 siblings, 0 replies; 10+ messages in thread
From: Diego Calleja @ 2008-05-24 18:07 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: Kristian Høgsberg, linux-kernel

El Sat, 24 May 2008 11:25:38 +0200, Mikael Pettersson <mikpe@it.uu.se> escribió:

> All this accomplishes is to make early boot failures harder
> to debug.

And there's already a parameter to switch the verbosity of printk - 'quiet'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor.
  2008-05-24  6:17   ` H. Peter Anvin
@ 2008-05-25  4:03     ` Rik van Riel
  2008-05-25  4:06       ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Rik van Riel @ 2008-05-25  4:03 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Kristian Høgsberg, linux-kernel

On Fri, 23 May 2008 23:17:01 -0700
"H. Peter Anvin" <hpa@zytor.com> wrote:

> Uhm... except it doesn't live at address zero, at all.
> 
> It's called "zeropage" because we used to recycle it into 
> empty_zero_page, a long long time ago.
> 
> The bootparms structure is pointed to by %esi being passed from the 
> setup code to the decompressor to the kernel.

Then why does dereferencing the uninitialized
pointer work, both in the code before and after
the patch?

What am I misssing?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor.
  2008-05-25  4:03     ` Rik van Riel
@ 2008-05-25  4:06       ` H. Peter Anvin
  2008-05-25  4:25         ` Kristian Høgsberg
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2008-05-25  4:06 UTC (permalink / raw)
  To: Rik van Riel; +Cc: Kristian Høgsberg, linux-kernel

Rik van Riel wrote:
> On Fri, 23 May 2008 23:17:01 -0700
> "H. Peter Anvin" <hpa@zytor.com> wrote:
> 
>> Uhm... except it doesn't live at address zero, at all.
>>
>> It's called "zeropage" because we used to recycle it into 
>> empty_zero_page, a long long time ago.
>>
>> The bootparms structure is pointed to by %esi being passed from the 
>> setup code to the decompressor to the kernel.
> 
> Then why does dereferencing the uninitialized
> pointer work, both in the code before and after
> the patch?
> 
> What am I misssing?

Heck if I know.  It definitely *shouldn't* work...

	-hpa

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor.
  2008-05-25  4:06       ` H. Peter Anvin
@ 2008-05-25  4:25         ` Kristian Høgsberg
  0 siblings, 0 replies; 10+ messages in thread
From: Kristian Høgsberg @ 2008-05-25  4:25 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Rik van Riel, Kristian Høgsberg, linux-kernel

On Sat, May 24, 2008 at 09:06:44PM -0700, H. Peter Anvin wrote:
> Rik van Riel wrote:
>> On Fri, 23 May 2008 23:17:01 -0700
>> "H. Peter Anvin" <hpa@zytor.com> wrote:
>>
>>> Uhm... except it doesn't live at address zero, at all.
>>>
>>> It's called "zeropage" because we used to recycle it into 
>>> empty_zero_page, a long long time ago.
>>>
>>> The bootparms structure is pointed to by %esi being passed from the setup 
>>> code to the decompressor to the kernel.
>>
>> Then why does dereferencing the uninitialized
>> pointer work, both in the code before and after
>> the patch?
>>
>> What am I misssing?
>
> Heck if I know.  It definitely *shouldn't* work...

Damn, I lost a chunk of the patch.  There's supposed to be a

        rm_screen_info = &real_mode->screen_info;

after the real_mode = rmode assignment.  In the code before,
RM_SCREEN_INFO was a macro that just referenced the real_mode pointer:

	#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))

Thanks, wil resend.
Kristian



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-05-25  4:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-23 21:59 [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor Kristian Høgsberg
2008-05-23 21:59 ` [PATCH 2/2] Only print "Decompressing Linux" etc when 'noisy' is passed Kristian Høgsberg
2008-05-23 22:42   ` Johannes Weiner
2008-05-24  9:25   ` Mikael Pettersson
2008-05-24 18:07     ` Diego Calleja
2008-05-24  1:07 ` [PATCH 1/2] Use structs instead of hardcoded offsets in x86 boot decompressor Rik van Riel
2008-05-24  6:17   ` H. Peter Anvin
2008-05-25  4:03     ` Rik van Riel
2008-05-25  4:06       ` H. Peter Anvin
2008-05-25  4:25         ` Kristian Høgsberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox