Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-09 Thread yhlu

On 5/9/07, Gerd Hoffmann <[EMAIL PROTECTED]> wrote:

Refine SCREEN_INFO sanity check for vgacon initialization.

Checking video mode field only to see whenever SCREEN_INFO is
initialized is not enougth, in some cases it is zero although
a vga card is present.  Lets additionally check cols and lines.

Signed-off-by: Gerd Hoffmann <[EMAIL PROTECTED]>
Cc: Rusty Russell <[EMAIL PROTECTED]>
Cc: Andi Kleen <[EMAIL PROTECTED]>
Cc: Alan <[EMAIL PROTECTED]>
Cc: Ingo Molnar <[EMAIL PROTECTED]>
Cc: Eric W. Biederman <[EMAIL PROTECTED]>
---
 drivers/video/console/vgacon.c |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: vanilla-2.6.21-git11/drivers/video/console/vgacon.c
===
--- vanilla-2.6.21-git11.orig/drivers/video/console/vgacon.c
+++ vanilla-2.6.21-git11/drivers/video/console/vgacon.c
@@ -368,9 +368,14 @@ static const char *vgacon_startup(void)
 #endif
}

+   /* SCREEN_INFO initialized? */
+   if ((ORIG_VIDEO_MODE  == 0) &&
+   (ORIG_VIDEO_LINES == 0) &&
+   (ORIG_VIDEO_COLS  == 0))
+   goto no_vga;
+
/* VGA16 modes are not handled by VGACON */
-   if ((ORIG_VIDEO_MODE == 0x00) ||/* SCREEN_INFO not initialized 
*/
-   (ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
+   if ((ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
(ORIG_VIDEO_MODE == 0x0E) ||/* 640x200/4 */
(ORIG_VIDEO_MODE == 0x10) ||/* 640x350/4 */
(ORIG_VIDEO_MODE == 0x12) ||/* 640x480/4 */


it works.

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-09 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Obviously not, but it was more of a comment on the apparent assumption
> that doing so would be simple.

Reasonable comment then.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-09 Thread H. Peter Anvin
[EMAIL PROTECTED] wrote:
> 
> Well in this case things are so very much better then attempting to
> us setup.S it isn't a real option.
> 

Obviously not, but it was more of a comment on the apparent assumption
that doing so would be simple.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-09 Thread yhlu

On 5/9/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:

"H. Peter Anvin" <[EMAIL PROTECTED]> writes:
We can look in /proc/ioports and see what has reserved
the video resources.  That should give us a reasonable
estimate of the video adapter.  We can do an ioctl to
the console and see how many lines and columns we have.

Reusing boot_params could be nice but if we have the information
available in other ways digging it out that way is quite possibly
better.


Another path:
LiuxBIOS+elfboot+payload, and payload is compressed elf
(vmlinux+initrd) via lzma.
and use kexec to boot final production kernel.
We don't need to use boot_params from the first tiny kernel.

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-09 Thread Eric W. Biederman
Gerd Hoffmann <[EMAIL PROTECTED]> writes:

>   Hi,
>
>> Since the whole point is to detect the case where we don't have
>> a screen at all it makes sense to check several additional variables
>> and make certain that they are all 0.  Agreed?
>
> Like in the attached patch?

Looks good to me.

> cheers,
>   Gerd
> Refine SCREEN_INFO sanity check for vgacon initialization.
>
> Checking video mode field only to see whenever SCREEN_INFO is
> initialized is not enougth, in some cases it is zero although
> a vga card is present.  Lets additionally check cols and lines.
>
> Signed-off-by: Gerd Hoffmann <[EMAIL PROTECTED]>
> Cc: Rusty Russell <[EMAIL PROTECTED]>
> Cc: Andi Kleen <[EMAIL PROTECTED]>
> Cc: Alan <[EMAIL PROTECTED]>
> Cc: Ingo Molnar <[EMAIL PROTECTED]>
> Cc: Eric W. Biederman <[EMAIL PROTECTED]>
> ---
>  drivers/video/console/vgacon.c |9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> Index: vanilla-2.6.21-git11/drivers/video/console/vgacon.c
> ===
> --- vanilla-2.6.21-git11.orig/drivers/video/console/vgacon.c
> +++ vanilla-2.6.21-git11/drivers/video/console/vgacon.c
> @@ -368,9 +368,14 @@ static const char *vgacon_startup(void)
>  #endif
>   }
>  
> + /* SCREEN_INFO initialized? */
> + if ((ORIG_VIDEO_MODE  == 0) &&
> + (ORIG_VIDEO_LINES == 0) &&
> + (ORIG_VIDEO_COLS  == 0))
> + goto no_vga;
> +
>   /* VGA16 modes are not handled by VGACON */
> - if ((ORIG_VIDEO_MODE == 0x00) || /* SCREEN_INFO not initialized */
> - (ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
> + if ((ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
>   (ORIG_VIDEO_MODE == 0x0E) ||/* 640x200/4 */
>   (ORIG_VIDEO_MODE == 0x10) ||/* 640x350/4 */
>   (ORIG_VIDEO_MODE == 0x12) ||/* 640x480/4 */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-09 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> yhlu wrote:
>> so the kexec tools need to scan the pci devices list, and find out how
>> to set real_mode.isVGA and orig_video_mode, also need to parse the
>> comand line about vga console.
>
> BTW, welcome to the hell of bypassing setup.

Well in this case things are so very much better then attempting to
us setup.S it isn't a real option.

In general BIOS calls just don't work reliably after linux has
been running for a while.

As for YH's point it does look like there are a few ways
to poke the linux kernel to see what is happening.

We can look in /proc/ioports and see what has reserved
the video resources.  That should give us a reasonable
estimate of the video adapter.  We can do an ioctl to
the console and see how many lines and columns we have.

Reusing boot_params could be nice but if we have the information
available in other ways digging it out that way is quite possibly
better.


Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-09 Thread Gerd Hoffmann

  Hi,


Since the whole point is to detect the case where we don't have
a screen at all it makes sense to check several additional variables
and make certain that they are all 0.  Agreed?


Like in the attached patch?

cheers,
  Gerd
Refine SCREEN_INFO sanity check for vgacon initialization.

Checking video mode field only to see whenever SCREEN_INFO is
initialized is not enougth, in some cases it is zero although
a vga card is present.  Lets additionally check cols and lines.

Signed-off-by: Gerd Hoffmann <[EMAIL PROTECTED]>
Cc: Rusty Russell <[EMAIL PROTECTED]>
Cc: Andi Kleen <[EMAIL PROTECTED]>
Cc: Alan <[EMAIL PROTECTED]>
Cc: Ingo Molnar <[EMAIL PROTECTED]>
Cc: Eric W. Biederman <[EMAIL PROTECTED]>
---
 drivers/video/console/vgacon.c |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: vanilla-2.6.21-git11/drivers/video/console/vgacon.c
===
--- vanilla-2.6.21-git11.orig/drivers/video/console/vgacon.c
+++ vanilla-2.6.21-git11/drivers/video/console/vgacon.c
@@ -368,9 +368,14 @@ static const char *vgacon_startup(void)
 #endif
}
 
+   /* SCREEN_INFO initialized? */
+   if ((ORIG_VIDEO_MODE  == 0) &&
+   (ORIG_VIDEO_LINES == 0) &&
+   (ORIG_VIDEO_COLS  == 0))
+   goto no_vga;
+
/* VGA16 modes are not handled by VGACON */
-   if ((ORIG_VIDEO_MODE == 0x00) ||/* SCREEN_INFO not initialized 
*/
-   (ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
+   if ((ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
(ORIG_VIDEO_MODE == 0x0E) ||/* 640x200/4 */
(ORIG_VIDEO_MODE == 0x10) ||/* 640x350/4 */
(ORIG_VIDEO_MODE == 0x12) ||/* 640x480/4 */


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread H. Peter Anvin
yhlu wrote:
> so the kexec tools need to scan the pci devices list, and find out how
> to set real_mode.isVGA and orig_video_mode, also need to parse the
> comand line about vga console.

BTW, welcome to the hell of bypassing setup.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread H. Peter Anvin
yhlu wrote:
> On 5/8/07, H. Peter Anvin <[EMAIL PROTECTED]> wrote:
>> H. Peter Anvin wrote:
>> Of course, one could argue that since all of those were obsolete by the
>> time Linux was first created, that it probably doesn't matter and that
>> isVGA == 0 pretty much means the more obvious thing.
>>
>> MDA/HGC stuck around for quite a while for debugging, since it was
>> non-conflicting with VGA, but even if it is, the reason people put it in
>> their system is to have something that the OS doesn't readily see.
>>
> so the kexec tools need to scan the pci devices list, and find out how
> to set real_mode.isVGA and orig_video_mode, also need to parse the
> comand line about vga console.

A better way, probably, would be for the kernel to export the
boot_params structure so kexec can reuse it.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, H. Peter Anvin <[EMAIL PROTECTED]> wrote:

H. Peter Anvin wrote:
Of course, one could argue that since all of those were obsolete by the
time Linux was first created, that it probably doesn't matter and that
isVGA == 0 pretty much means the more obvious thing.

MDA/HGC stuck around for quite a while for debugging, since it was
non-conflicting with VGA, but even if it is, the reason people put it in
their system is to have something that the OS doesn't readily see.


so the kexec tools need to scan the pci devices list, and find out how
to set real_mode.isVGA and orig_video_mode, also need to parse the
comand line about vga console.

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread H. Peter Anvin
H. Peter Anvin wrote:
> yhlu wrote:
>> On 5/8/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:
>>> Since the whole point is to detect the case where we don't have
>>> a screen at all it makes sense to check several additional variables
>>> and make certain that they are all 0.  Agreed?
>> need one good way to find if there is support vga console.
> 
> There really isn't one, at least not given the current data structure;
> the data structure has an "isVGA" flag, but if that is 0 it's supposed
> to mean CGA/MDA/HGC/EGA, as opposed to VGA...

Of course, one could argue that since all of those were obsolete by the
time Linux was first created, that it probably doesn't matter and that
isVGA == 0 pretty much means the more obvious thing.

MDA/HGC stuck around for quite a while for debugging, since it was
non-conflicting with VGA, but even if it is, the reason people put it in
their system is to have something that the OS doesn't readily see.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread H. Peter Anvin
yhlu wrote:
> On 5/8/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:
>> Since the whole point is to detect the case where we don't have
>> a screen at all it makes sense to check several additional variables
>> and make certain that they are all 0.  Agreed?
> 
> need one good way to find if there is support vga console.

There really isn't one, at least not given the current data structure;
the data structure has an "isVGA" flag, but if that is 0 it's supposed
to mean CGA/MDA/HGC/EGA, as opposed to VGA...

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Eric W. Biederman
yhlu <[EMAIL PROTECTED]> writes:

> On 5/8/07, Vivek Goyal <[EMAIL PROTECTED]> wrote:
>> On Tue, May 08, 2007 at 11:51:35AM -0700, yhlu wrote:
>> This message generally appears if you did not specify --args-linux
>> on kexec command line while loading vmlinux.
>>
> besides elf-x86_64, still need --args-linux to pass sth? but how to
> let it load ramdisk?

Same arguments just use --args-linux.

Basically the calling convention needs to be specified because
there isn't a universal one, and /sbin/kexec can't yet detect
vmlinux is linux.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:

Since the whole point is to detect the case where we don't have
a screen at all it makes sense to check several additional variables
and make certain that they are all 0.  Agreed?


need one good way to find if there is support vga console.

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, Vivek Goyal <[EMAIL PROTECTED]> wrote:

On Tue, May 08, 2007 at 11:51:35AM -0700, yhlu wrote:
This message generally appears if you did not specify --args-linux
on kexec command line while loading vmlinux.


besides elf-x86_64, still need --args-linux to pass sth? but how to
let it load ramdisk?

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Vivek Goyal
On Tue, May 08, 2007 at 11:51:35AM -0700, yhlu wrote:
> Eric,
> 
> i tried to load vmlinux with kexec and got
> Ramdisks not supported with generic elf arguments
> 

This message generally appears if you did not specify --args-linux
on kexec command line while loading vmlinux.

Thanks
Vivek
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> 
>> I expect I can find a few more examples where we specify
>> video_cols and video_lines but we use video_mode == 0.
>> 
>> Going farther mode 0x00 is a BIOS 40x25 mode.  So the patch below is
>> not always safe even if we boot the bzImage.  It is just highly
>> unlikely anyone would start the kernel in 40x25 text mode. 
>> 
>
> Mode 0x00 is, at least theoretically, BIOS 40x25 *grayscale*; this mode
> (and mode 0x02 which is the same thing in 80x25) were as far as I know
> only ever used with composite monitors off CGA cards, i.e. functionally
> never.  Actual monochrome monitors used mode 0x07.

I agree.  We are not at all likely to see it in practice.  Even
if my memory is correct and vga cards and non-monochrome cga
cards supported that mode.

That doesn't mean checking for 0x00 is sufficient to detect
an initialized struct screen_info, or a lack of a video screen.

We have in kernel historical precedent for using 0x00 as just meaning
a text mode.  I'm fairly certain that I looked I more closely I could
find this convention of using 0x00 to mean a text mode on ia64, mips,
and ppc, in addition to the instances I found on alpha, arm,

Since the whole point is to detect the case where we don't have
a screen at all it makes sense to check several additional variables
and make certain that they are all 0.  Agreed?

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:

"H. Peter Anvin" <[EMAIL PROTECTED]> writes:
I believe YH is asking how we setup real_mode_data in /sbin/kexec.


pxelinux:

SCREEN_INFO.orig_video_mode =  3
SCREEN_INFO.orig_x =  0
SCREEN_INFO.orig_y =  24
x86_boot_params[] :
: 00 18 ff ff 08 00 03 50 8c c8 03 00 8e c0 19 01
0010: 10 00 7c fb fc be 31 00 ac 20 c0 74 09 b4 0e bb
0020: 07 00 cd 10 eb f2 31 c0 cd 16 cd 19 ea f0 ff 00
0030: f0 44 69 72 65 63 74 20 62 6f 6f 74 15 00 10 00

current kexec:
SCREEN_INFO.orig_video_mode =  0
SCREEN_INFO.orig_x =  0
SCREEN_INFO.orig_y =  3
x86_boot_params[] :
: 00 03 00 fc 00 00 00 50 8c c8 00 00 8e c0 19 01
0010: 10 00 7c fb fc be 31 00 ac 20 c0 74 09 b4 0e bb
0020: 3f a3 00 16 eb f2 31 c0 cd 16 cd 19 ea f0 ff 00
0030: f0 44 69 72 65 63 74 20 62 6f 6f 74 15 00 20 00

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread H. Peter Anvin
Eric W. Biederman wrote:
> 
> I expect I can find a few more examples where we specify
> video_cols and video_lines but we use video_mode == 0.
> 
> Going farther mode 0x00 is a BIOS 40x25 mode.  So the patch below is
> not always safe even if we boot the bzImage.  It is just highly
> unlikely anyone would start the kernel in 40x25 text mode. 
> 

Mode 0x00 is, at least theoretically, BIOS 40x25 *grayscale*; this mode
(and mode 0x02 which is the same thing in 80x25) were as far as I know
only ever used with composite monitors off CGA cards, i.e. functionally
never.  Actual monochrome monitors used mode 0x07.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> yhlu wrote:
>> On 5/8/07, H. Peter Anvin <[EMAIL PROTECTED]> wrote:
>>> Jeremy Fitzhardinge wrote:
>>> Specifically boot_params.screen_info isn't being properly set up by the
>>> caller.
>> 
>> will setup real_mode_data in kexec path?
>
> -ENOPARSE

I believe YH is asking how we setup real_mode_data in /sbin/kexec.
The setup is:
> real_mode->orig_x = 0;
> real_mode->orig_y = 0;
> real_mode->orig_video_page = 0;
> real_mode->orig_video_mode = 0;
> real_mode->orig_video_cols = 80;
> real_mode->orig_video_lines = 25;
> real_mode->orig_video_ega_bx = 0;
> real_mode->orig_video_isVGA = 1;
> real_mode->orig_video_points = 16;

Silly but generally safe.

More relevant because the code is in kernel we have:

arch/arm/kernel/setup.c:
> struct screen_info screen_info = {
>  .orig_video_lines= 30,
>  .orig_video_cols = 80,
>  .orig_video_mode = 0,
>  .orig_video_ega_bx   = 0,
>  .orig_video_isVGA= 1,
>  .orig_video_points   = 8
> };


arch/alpha/kernel/sys_sio.c:
>   /* The AlphaBook1 has LCD video fixed at 800x600,
>  37 rows and 100 cols. */
>   screen_info.orig_y = 37;
>   screen_info.orig_video_cols = 100;
>   screen_info.orig_video_lines = 37;


I expect I can find a few more examples where we specify
video_cols and video_lines but we use video_mode == 0.

Going farther mode 0x00 is a BIOS 40x25 mode.  So the patch below is
not always safe even if we boot the bzImage.  It is just highly
unlikely anyone would start the kernel in 40x25 text mode. 

Therefore I expect the test should test several additional
fields, in particular video lines and columns before we
decide that we have an uninitialized screen_info and give up.


> commit f82af20e1a028e16b9bb11da081fa1148d40fa6a
> Author: Gerd Hoffmann <[EMAIL PROTECTED]>
> Date:   Wed May 2 19:27:19 2007 +0200
> 
> [PATCH] x86-64: ignore vgacon if hardware not present
> 
> Avoid trying to set up vgacon if there's no vga hardware present.
> 
> Signed-off-by: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
> Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
> Signed-off-by: Andi Kleen <[EMAIL PROTECTED]>
> Cc: Alan <[EMAIL PROTECTED]>
> Acked-by: Ingo Molnar <[EMAIL PROTECTED]>
> 
> diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
> index 91a2078..3e67c34 100644
> --- a/drivers/video/console/vgacon.c
> +++ b/drivers/video/console/vgacon.c
> @@ -371,7 +371,8 @@ static const char *vgacon_startup(void)
> }
>  
> /* VGA16 modes are not handled by VGACON */
> -   if ((ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
> +   if ((ORIG_VIDEO_MODE == 0x00) ||/* SCREEN_INFO not 
> initialized */
> +   (ORIG_VIDEO_MODE == 0x0D) ||/* 320x200/4 */
> (ORIG_VIDEO_MODE == 0x0E) ||/* 640x200/4 */
> (ORIG_VIDEO_MODE == 0x10) ||/* 640x350/4 */
> (ORIG_VIDEO_MODE == 0x12) ||/* 640x480/4 */

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread H. Peter Anvin
yhlu wrote:
> On 5/8/07, H. Peter Anvin <[EMAIL PROTECTED]> wrote:
>> Jeremy Fitzhardinge wrote:
>> Specifically boot_params.screen_info isn't being properly set up by the
>> caller.
> 
> will setup real_mode_data in kexec path?

-ENOPARSE

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, H. Peter Anvin <[EMAIL PROTECTED]> wrote:

Jeremy Fitzhardinge wrote:
Specifically boot_params.screen_info isn't being properly set up by the
caller.


will setup real_mode_data in kexec path?

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote:
> 
> Interesting.  I haven't really been following this thread, but doesn't
> it mean something isn't being initialized properly if this patch makes a
> difference?
> 

Specifically boot_params.screen_info isn't being properly set up by the
caller.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Jeremy Fitzhardinge
yhlu wrote:
> On 5/8/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:
>> You might try a git-bisect, or if it is just these patches
>> walking through them one-by-one.
>
> f82af20e1a028e16b9bb11da081fa1148d40fa6a is first bad commit
> commit f82af20e1a028e16b9bb11da081fa1148d40fa6a
> Author: Gerd Hoffmann <[EMAIL PROTECTED]>
> Date:   Wed May 2 19:27:19 2007 +0200
>
>[PATCH] x86-64: ignore vgacon if hardware not present
>
>Avoid trying to set up vgacon if there's no vga hardware present.
>
>Signed-off-by: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
>Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
>Signed-off-by: Andi Kleen <[EMAIL PROTECTED]>
>Cc: Alan <[EMAIL PROTECTED]>
>Acked-by: Ingo Molnar <[EMAIL PROTECTED]>

Interesting.  I haven't really been following this thread, but doesn't
it mean something isn't being initialized properly if this patch makes a
difference?

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:

You might try a git-bisect, or if it is just these patches
walking through them one-by-one.


f82af20e1a028e16b9bb11da081fa1148d40fa6a is first bad commit
commit f82af20e1a028e16b9bb11da081fa1148d40fa6a
Author: Gerd Hoffmann <[EMAIL PROTECTED]>
Date:   Wed May 2 19:27:19 2007 +0200

   [PATCH] x86-64: ignore vgacon if hardware not present

   Avoid trying to set up vgacon if there's no vga hardware present.

   Signed-off-by: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
   Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
   Signed-off-by: Andi Kleen <[EMAIL PROTECTED]>
   Cc: Alan <[EMAIL PROTECTED]>
   Acked-by: Ingo Molnar <[EMAIL PROTECTED]>

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Eric W. Biederman
yhlu <[EMAIL PROTECTED]> writes:

> Eric,
>
> i tried to load vmlinux with kexec and got
> Ramdisks not supported with generic elf arguments
>
> So i use mkelfImage with my patch ( convert elf64 to elf32) to make
> another elf32. and loaded with kexec and can not get vga console too.
> ---serial console works well.
>
> the mkelfImage 2.7 patch is at
> http://72.14.253.104/search?q=cache:fuxOvFw3ZIIJ:lists.osdl.org/pipermail/fastboot/attachments/20061108/009064a6/attachment.obj+mkelfImage+2.7+patch&hl=en&ct=clnk&cd=4&gl=us
>
> So the problem is not bzImage related, but in somewhere in vmlinux.

Odd.   Is it specifically these patches?
Or is it just the recent kernel from Linus?

You might try a git-bisect, or if it is just these patches
walking through them one-by-one.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

the mkelfImage 2.7 patch is at


https://lists.linux-foundation.org/pipermail/fastboot/attachments/20061108/009064a6/mkelfImage_2.7_amd64_1108-0001.obj

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

Eric,

i tried to load vmlinux with kexec and got
Ramdisks not supported with generic elf arguments

So i use mkelfImage with my patch ( convert elf64 to elf32) to make
another elf32. and loaded with kexec and can not get vga console too.
---serial console works well.

the mkelfImage 2.7 patch is at
http://72.14.253.104/search?q=cache:fuxOvFw3ZIIJ:lists.osdl.org/pipermail/fastboot/attachments/20061108/009064a6/attachment.obj+mkelfImage+2.7+patch&hl=en&ct=clnk&cd=4&gl=us

So the problem is not bzImage related, but in somewhere in vmlinux.

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, Vivek Goyal <[EMAIL PROTECTED]> wrote:

setup.S is never executed while doing kexec (unless somebody chooses to
do a real mode entry) and these patches don't change this beahviour.

Tomorrow I will test VGA behaviour on my machine. Are you using some
special frame buffer mode etc?



I disabled the FB in the kernel.

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/8/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:

Yes.  setup.S has always been skipped by bzImage via the kexec path
unless you explicitly tell /sbin/kexec to use the 16bit entry point.

Is not having a VGA console a new thing, or it something you just noticed?

Eric



before the changes, it works well.

with --real-mode, it will reset the machine.
with --reset-vga, i will get

Kernel alive
kernel direct mapping tables up to 1 @ 8000-d000

on VGA monitor.

YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Vivek Goyal
On Tue, May 08, 2007 at 09:41:09AM -0700, yhlu wrote:
> On 5/2/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:
> >Vivek Goyal <[EMAIL PROTECTED]> writes:
> >
> >> On Wed, May 02, 2007 at 02:59:11PM -0700, H. Peter Anvin wrote:
> >>> Jeremy Fitzhardinge wrote:
> >>> >
> >>> > So the bzImage structure is currently:
> >>> >
> >>> >1. old-style boot sector
> >>> >2. old-style boot info, followed by 0xaa55 at the end of the sector
> >>> >3. the HdrS boot param block
> >>> >4. setup.S boot code
> >>> >5. the self-decompressing kernel
> >>> >
> 
> Eric,
> 
> With the latest change that make vmlinux to be elf64 and make bzImage
> do switch to 64bit long mode, the kernel started via kexec can not get
> VGA console. but the serial console works well. I wonder if the
> setup.S is skipped in bzImage via kexec path.
> 
> or i missed sth?
> 

Hi,

setup.S is never executed while doing kexec (unless somebody chooses to
do a real mode entry) and these patches don't change this beahviour.

Tomorrow I will test VGA behaviour on my machine. Are you using some
special frame buffer mode etc?

Thanks
Vivek
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread Eric W. Biederman
yhlu <[EMAIL PROTECTED]> writes:

> Eric,
>
> With the latest change that make vmlinux to be elf64 and make bzImage
> do switch to 64bit long mode, the kernel started via kexec can not get
> VGA console. but the serial console works well. I wonder if the
> setup.S is skipped in bzImage via kexec path.

Yes.  setup.S has always been skipped by bzImage via the kexec path
unless you explicitly tell /sbin/kexec to use the 16bit entry point.

Is not having a VGA console a new thing, or it something you just noticed?

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-08 Thread yhlu

On 5/2/07, Eric W. Biederman <[EMAIL PROTECTED]> wrote:

Vivek Goyal <[EMAIL PROTECTED]> writes:

> On Wed, May 02, 2007 at 02:59:11PM -0700, H. Peter Anvin wrote:
>> Jeremy Fitzhardinge wrote:
>> >
>> > So the bzImage structure is currently:
>> >
>> >1. old-style boot sector
>> >2. old-style boot info, followed by 0xaa55 at the end of the sector
>> >3. the HdrS boot param block
>> >4. setup.S boot code
>> >5. the self-decompressing kernel
>> >


Eric,

With the latest change that make vmlinux to be elf64 and make bzImage
do switch to 64bit long mode, the kernel started via kexec can not get
VGA console. but the serial console works well. I wonder if the
setup.S is skipped in bzImage via kexec path.

or i missed sth?

#!/bin/bash
./kexec -t bzImage -l bzImage_2.6.22_k8.1 --command-line="apic=debug
acpi_dbg_level=0x0007 pci=routeirq snd-hda-intel.enable_msi=1
ramdisk_size=65536 root=/dev/ram0 rw ip=dhcp console=tty0
console=ttyS0,9600n8" --ramdisk=mydisk8_x86_64.gz


YH
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-03 Thread Jeremy Fitzhardinge
Eric W. Biederman wrote:
> Yes.  I guess in this context, I am generally for building the ELF
> headers by hand instead of with a linker script, because then we
> know exactly what is happening and can ensure everything is just so.
>   

Yes, it seems easiest - particularly given how flaky binutils can get
when you really try to control its ELF generation.

> Sorry, for not being clear I have been expecting to do this for years,
> it is one of the reasons I keep coming back to putting an ELF header
> on the bzImage. 
>   

OK.  It seems obvious, but I just wanted to make sure ;)

>> In the Xen case, its obviously the domain builder who creates the
>> mappings, and we can easily implement p != v mappings.  But when booting
>> native, presumably paging is off at this stage, and only identity maps
>> can be implemented.  I guess the rough rule is that if paging is enabled
>> on entry, the kernel should expect all the bzImage mappings to be in
>> place, but if paging is off, well, the question is moot.
>> 
>
> Right.  Except that there is a bit of a catch 22 in the
> para-virtualized environments of setting up the page tables, I'm not
> at all certain what the gain of setting up p != v mappings are.
>   

Well, that's more or less it.  If the decompressor ends up jumping to
startup_32, and that immediately goes into xen_start_kernel(), then
we're still running on the initial bzImage p=v pagetables.  At the
moment, when the domain builder maps the kernel's vmlinux to the vaddrs
in its Phdrs, so there's no need to do any more boot-time pagetable
manipulation.  If we come out of bzImage with only identity mappings,
then obviously the Xen case will need to do the same pagetable setup as
the native case - which is good so long as we can work out how to share
the code to do so.

For i386, it looks like this will be tricky because at this point:

* we're not running at the linked address, so C code will be tricky
  and non-standard
* we need to deal with multiple hypervisors and their constraints on
  what can be in a pagetable
* we could be running with no paging, or paging in either non-PAE or
  PAE modes

Writing some code which can deal with all of those at once will be an
interesting exercise.

> Part of what I find compelling about this is our initial page tables
> for linux have always had more going on than the virtual addresses
> just being at a constant offset from of the physical addresses, so
> the actions of the current domain builders have me concerned that they
> may be violating some early linux booting assumptions and are
> currently just getting lucky.  Moving the page table setup code into
> the kernel removes that dependency from the domain builders.

The nice thing about having the domain builder create the pagetables is
that it turns it from a tricky bootstrap problem into a relatively easy
job.  The main thing is that the domain builder can create a scaffolding
pagetable which is enough to get everything started.  Once you have that
in place, its pretty easy to update it to set precisely the right bits
in the ptes, etc.

It also means that the path for Xen vs native will be more similar,
because the bzImage code won't need to deal with pagetable setup at all:
for native it won't matter, and for Xen it has already been done.  It
only matters once we hit the 32-bit kernel-proper code, and we diverge
at that point anyway.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-03 Thread Eric W. Biederman
Jeremy Fitzhardinge <[EMAIL PROTECTED]> writes:

> OK, whatever you think will work.  But I do think it should be a proper
> ELF file with a correct magic number, so that you can just point an ELF
> file parser at it and have it work (which means, of course, that all the
> file offsets are offsets from the start of the Ehdr, rather than from
> the start of the bzImage).

Yes.  I guess in this context, I am generally for building the ELF
headers by hand instead of with a linker script, because then we
know exactly what is happening and can ensure everything is just so.

> You haven't specifically commented on using the Phdrs as a way of
> specifying the mappings required for decompression and early kernel
> execution.  It seems pretty natural to me, but I guess that raises the
> general question of what execution environment the kernel can expect to
> find itself in, and which modes of booting will actually enable paging
> and establish any kinds of mapping at all.

Sorry, for not being clear I have been expecting to do this for years,
it is one of the reasons I keep coming back to putting an ELF header
on the bzImage.  arch/x86_64/kernel already does this to some extent
as it has to setup up some identity page mappings for itself in the
case it has to do the switch from real to protected mode itself.

> In the Xen case, its obviously the domain builder who creates the
> mappings, and we can easily implement p != v mappings.  But when booting
> native, presumably paging is off at this stage, and only identity maps
> can be implemented.  I guess the rough rule is that if paging is enabled
> on entry, the kernel should expect all the bzImage mappings to be in
> place, but if paging is off, well, the question is moot.

Right.  Except that there is a bit of a catch 22 in the
para-virtualized environments of setting up the page tables, I'm not
at all certain what the gain of setting up p != v mappings are.

Having just written some C code that runs fairly successfully in p !=
v, on arch/i386 I'm not too concerned.  arch/x86_64 ought to work with
a similar level of effort although the expectations there are a little
different. So while I don't necessarily considering running in p != v
when compiled to run at v general it should work for the cases we
are interested in.  Setting up the page tables for arch/x86_64 will
be more interesting.

Part of what I find compelling about this is our initial page tables
for linux have always had more going on than the virtual addresses
just being at a constant offset from of the physical addresses, so
the actions of the current domain builders have me concerned that they
may be violating some early linux booting assumptions and are
currently just getting lucky.  Moving the page table setup code into
the kernel removes that dependency from the domain builders.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-03 Thread Jeremy Fitzhardinge
Eric W. Biederman wrote:
> Vivek Goyal <[EMAIL PROTECTED]> writes:
>
>   
>> On Wed, May 02, 2007 at 02:59:11PM -0700, H. Peter Anvin wrote:
>> 
>>> Jeremy Fitzhardinge wrote:
>>>   
 So the bzImage structure is currently:

1. old-style boot sector
2. old-style boot info, followed by 0xaa55 at the end of the sector
3. the HdrS boot param block
4. setup.S boot code
5. the self-decompressing kernel

 If we make 5 actually an ELF file, containing properly formed Ehdr,
 Phdrs (for all the mappings required), and the actual kernel
 decompressor, relocator and compressed kernel data, then it would be
 easy for the Xen domain builder to find that and use it as a basis for
 loading.  I think it would just require the bzImage boot param block to
 contain an offset of the start of the ELF file.  The contents of the ELF
 file would be in a form where the normal boot code could just jump over
 the ELF headers, directly into the segment data itself.

 ie:

1. old-style boot sector
2. old-style boot info, followed by 0xaa55 at the end of the sector
3. the HdrS boot param block
4. setup.S boot code (jumps directly into 5.3)
5. 32-bit self-decompressing kernel:
  1. Ehdr
  2. Phdrs for all necessary mappings
  3. decompressor/relocator .text
  4. compressed kernel data

 Does that sound reasonable?

 
>>> I don't know if that would break any programs that are currently
>>> bypassing the setup.
>>>   
>
> I think everything will break, unless we make 5.1 and 5.2 
> into 4.2 and 4.3.  In the above design.
>
>   
>> I think kexec bzImage loader will break. It bypasses the setup code and
>> directly jumps to the code present after setup sectors(decompressor).
>> 
>
> Quite likely.The boot sector except for a handful of bytes actually
> goes unused so we can put extra header information there, I actually
> have patches for placing an ELF header there.

OK, whatever you think will work.  But I do think it should be a proper
ELF file with a correct magic number, so that you can just point an ELF
file parser at it and have it work (which means, of course, that all the
file offsets are offsets from the start of the Ehdr, rather than from
the start of the bzImage).

You haven't specifically commented on using the Phdrs as a way of
specifying the mappings required for decompression and early kernel
execution.  It seems pretty natural to me, but I guess that raises the
general question of what execution environment the kernel can expect to
find itself in, and which modes of booting will actually enable paging
and establish any kinds of mapping at all.

In the Xen case, its obviously the domain builder who creates the
mappings, and we can easily implement p != v mappings.  But when booting
native, presumably paging is off at this stage, and only identity maps
can be implemented.  I guess the rough rule is that if paging is enabled
on entry, the kernel should expect all the bzImage mappings to be in
place, but if paging is off, well, the question is moot.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Eric W. Biederman
Vivek Goyal <[EMAIL PROTECTED]> writes:

> On Wed, May 02, 2007 at 02:59:11PM -0700, H. Peter Anvin wrote:
>> Jeremy Fitzhardinge wrote:
>> > 
>> > So the bzImage structure is currently:
>> > 
>> >1. old-style boot sector
>> >2. old-style boot info, followed by 0xaa55 at the end of the sector
>> >3. the HdrS boot param block
>> >4. setup.S boot code
>> >5. the self-decompressing kernel
>> > 
>> > If we make 5 actually an ELF file, containing properly formed Ehdr,
>> > Phdrs (for all the mappings required), and the actual kernel
>> > decompressor, relocator and compressed kernel data, then it would be
>> > easy for the Xen domain builder to find that and use it as a basis for
>> > loading.  I think it would just require the bzImage boot param block to
>> > contain an offset of the start of the ELF file.  The contents of the ELF
>> > file would be in a form where the normal boot code could just jump over
>> > the ELF headers, directly into the segment data itself.
>> > 
>> > ie:
>> > 
>> >1. old-style boot sector
>> >2. old-style boot info, followed by 0xaa55 at the end of the sector
>> >3. the HdrS boot param block
>> >4. setup.S boot code (jumps directly into 5.3)
>> >5. 32-bit self-decompressing kernel:
>> >  1. Ehdr
>> >  2. Phdrs for all necessary mappings
>> >  3. decompressor/relocator .text
>> >  4. compressed kernel data
>> > 
>> > Does that sound reasonable?
>> > 
>> 
>> I don't know if that would break any programs that are currently
>> bypassing the setup.

I think everything will break, unless we make 5.1 and 5.2 
into 4.2 and 4.3.  In the above design.

> I think kexec bzImage loader will break. It bypasses the setup code and
> directly jumps to the code present after setup sectors(decompressor).

Quite likely.The boot sector except for a handful of bytes actually
goes unused so we can put extra header information there, I actually
have patches for placing an ELF header there.

If we wanted to do an ELF header in the middle we would have to put
it at the end of the setup sectors rather then the beginning of the
raw protected mode kernel image.

>> The existing setup protocol definitely allows
>> invoking an entry point which isn't 0x10 (rather, the 32-bit
>> entrypoint is defined by code32_start); I'm not sure how Eric's
>> relocatable kernel patches (2.05 protocol) affect that, mostly because I
>> haven't seen any boot loaders which actually use it so I can't comment
>> on what their code looks like.
>
> With relocatable patches, if a boot loader decides to load protected mode
> component at non-1MB address, then it shall have to modify code32_start to
> reflect the new location of protected mode code.

Yes.  And this aspect of the relocatable kernel is all Vivek.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Vivek Goyal
On Wed, May 02, 2007 at 02:59:11PM -0700, H. Peter Anvin wrote:
> Jeremy Fitzhardinge wrote:
> > 
> > So the bzImage structure is currently:
> > 
> >1. old-style boot sector
> >2. old-style boot info, followed by 0xaa55 at the end of the sector
> >3. the HdrS boot param block
> >4. setup.S boot code
> >5. the self-decompressing kernel
> > 
> > If we make 5 actually an ELF file, containing properly formed Ehdr,
> > Phdrs (for all the mappings required), and the actual kernel
> > decompressor, relocator and compressed kernel data, then it would be
> > easy for the Xen domain builder to find that and use it as a basis for
> > loading.  I think it would just require the bzImage boot param block to
> > contain an offset of the start of the ELF file.  The contents of the ELF
> > file would be in a form where the normal boot code could just jump over
> > the ELF headers, directly into the segment data itself.
> > 
> > ie:
> > 
> >1. old-style boot sector
> >2. old-style boot info, followed by 0xaa55 at the end of the sector
> >3. the HdrS boot param block
> >4. setup.S boot code (jumps directly into 5.3)
> >5. 32-bit self-decompressing kernel:
> >  1. Ehdr
> >  2. Phdrs for all necessary mappings
> >  3. decompressor/relocator .text
> >  4. compressed kernel data
> > 
> > Does that sound reasonable?
> > 
> 
> I don't know if that would break any programs that are currently
> bypassing the setup.

I think kexec bzImage loader will break. It bypasses the setup code and
directly jumps to the code present after setup sectors(decompressor).

> The existing setup protocol definitely allows
> invoking an entry point which isn't 0x10 (rather, the 32-bit
> entrypoint is defined by code32_start); I'm not sure how Eric's
> relocatable kernel patches (2.05 protocol) affect that, mostly because I
> haven't seen any boot loaders which actually use it so I can't comment
> on what their code looks like.

With relocatable patches, if a boot loader decides to load protected mode
component at non-1MB address, then it shall have to modify code32_start to
reflect the new location of protected mode code.

Thanks
Vivek
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Rusty Russell
On Wed, 2007-05-02 at 14:09 -0700, H. Peter Anvin wrote:
> Jeremy Fitzhardinge wrote:
> > 
> > Hm, that's unfortunate.  How about an ELF file wrapped in some other
> > container, so that we can easily extract a properly formed ELF file?
> > 
> 
> Effectively the same thing as changing the magic number.  Note that the
> format for bzImage is pretty rigid, and it would be *highly* undesirable
> to muck that up.

To add some code to the debate, here's how lguest loads a bzImage (from
my draft documentation).  Almost anything would be an improvement:


/* A bzImage, unlike an ELF file, is not meant to be loaded.  You're
 * supposed to jump into it and it will unpack itself.  We can't do that
 * because the Guest can't run the unpacking code, and adding features to
 * lguest kills puppies, so we don't want to.
 *
 * The bzImage is formed by putting the decompressing code in front of the
 * compressed kernel code.  So we can simple scan through it looking for the
 * first "gzip" header, and start decompressing from there. */
static unsigned long load_bzimage(int fd, unsigned long *page_offset)
{
unsigned char c;
int state = 0;

/* GZIP header is 0x1F 0x8B  ... . */
while (read(fd, &c, 1) == 1) {
switch (state) {
case 0:
if (c == 0x1F)
state++;
break;
case 1:
if (c == 0x8B)
state++;
else
state = 0;
break;
case 2 ... 8:
state++;
break;
case 9:
/* Seek back to the start of the gzip header. */
lseek(fd, -10, SEEK_CUR);
/* One final check: "compressed under UNIX". */
if (c != 0x03)
state = -1;
else
return unpack_bzimage(fd, page_offset);
}
}
errx(1, "Could not find kernel in bzImage");
}

/* Unfortunately the entire ELF image isn't compressed: the segments
 * which need loading are extracted and compressed raw.  This denies us the
 * information we need to make a fully-general loader. */
static unsigned long unpack_bzimage(int fd, unsigned long *page_offset)
{
gzFile f;
int ret, len = 0;
/* A bzImage always gets loaded at physical address 1M.  This is
 * actually configurable as CONFIG_PHYSICAL_START, but as the comment
 * there says, "Don't change this unless you know what you are doing".
 * Indeed. */
void *img = (void *)0x10;

/* gzdopen takes our file descriptor (carefully placed at the start of
 * the GZIP header we found) and returns a gzFile. */
f = gzdopen(fd, "rb");
/* Unfortunately, if we made a mistake and it wasn't really a gzip
 * header, it will still read the file, but directly without
 * decompressing it.  For us, that's a misfeature. */
if (gzdirect(f))
errx(1, "did not find correct gzip header");
/* We read it into memory in 64k chunks until we hit the end. */
while ((ret = gzread(f, img + len, 65536)) > 0)
len += ret;
if (ret < 0)
err(1, "reading image from bzImage");

verbose("Unpacked size %i addr %p\n", len, img);

/* Without the ELF header, we can't tell virtual-physical gap.  This is
 * CONFIG_PAGE_OFFSET, and people do actually change it.  Fortunately,
 * I have a clever way of figuring it out from the code itself.  */
*page_offset = intuit_page_offset(img, len);

/* Entry is physical address: convert to virtual */
return (unsigned long)img + *page_offset;
}

/* Prepare to be SHOCKED and AMAZED.  And possibly a trifle nauseated.
 *
 * We know that CONFIG_PAGE_OFFSET sets what virtual address the kernel expects
 * to be.  We don't know what that option was, but we can figure it out
 * approximately by looking at the addresses in the code.  I chose the common
 * case of reading a memory location into the %eax register:
 *
 *  movl , %eax
 *
 * This gets encoded as five bytes: "0xA1 <4-byte-address>".  For example,
 * "0xA1 0x18 0x60 0x47 0xC0" reads the address 0xC0476018 into %eax.
 *
 * In this example can guess that the kernel was compiled with
 * CONFIG_PAGE_OFFSET set to 0xC000 (it's always a round number).  If the
 * kernel were larger than 16MB, we might see 0xC1 addresses show up, but our
 * kernel isn't that bloated yet.
 *
 * Unfortunately, x86 has variable-length instructions, so finding this
 * particular instruction properly involves writing a disassembler.  Instead,
 * we rely on statistics.  We look for "0xA1" and tally the different bytes
 * which occur 4

Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Jeremy Fitzhardinge
H. Peter Anvin wrote:
> I don't know if that would break any programs that are currently
> bypassing the setup.  The existing setup protocol definitely allows
> invoking an entry point which isn't 0x10 (rather, the 32-bit
> entrypoint is defined by code32_start); I'm not sure how Eric's
> relocatable kernel patches (2.05 protocol) affect that, mostly because I
> haven't seen any boot loaders which actually use it so I can't comment
> on what their code looks like.

Yes, I'd expect that code32_start would point into the ELF text
segment.   You could align things so that the entrypoint is still
actually 0x10, or bump it up a bit to fit the ELF headers.  I have
to admit I don't quite understand how all that fits together at the moment.

J

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote:
> 
> So the bzImage structure is currently:
> 
>1. old-style boot sector
>2. old-style boot info, followed by 0xaa55 at the end of the sector
>3. the HdrS boot param block
>4. setup.S boot code
>5. the self-decompressing kernel
> 
> If we make 5 actually an ELF file, containing properly formed Ehdr,
> Phdrs (for all the mappings required), and the actual kernel
> decompressor, relocator and compressed kernel data, then it would be
> easy for the Xen domain builder to find that and use it as a basis for
> loading.  I think it would just require the bzImage boot param block to
> contain an offset of the start of the ELF file.  The contents of the ELF
> file would be in a form where the normal boot code could just jump over
> the ELF headers, directly into the segment data itself.
> 
> ie:
> 
>1. old-style boot sector
>2. old-style boot info, followed by 0xaa55 at the end of the sector
>3. the HdrS boot param block
>4. setup.S boot code (jumps directly into 5.3)
>5. 32-bit self-decompressing kernel:
>  1. Ehdr
>  2. Phdrs for all necessary mappings
>  3. decompressor/relocator .text
>  4. compressed kernel data
> 
> Does that sound reasonable?
> 

I don't know if that would break any programs that are currently
bypassing the setup.  The existing setup protocol definitely allows
invoking an entry point which isn't 0x10 (rather, the 32-bit
entrypoint is defined by code32_start); I'm not sure how Eric's
relocatable kernel patches (2.05 protocol) affect that, mostly because I
haven't seen any boot loaders which actually use it so I can't comment
on what their code looks like.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Jeremy Fitzhardinge
H. Peter Anvin wrote:
> Jeremy Fitzhardinge wrote:
>   
>> Hm, that's unfortunate.  How about an ELF file wrapped in some other
>> container, so that we can easily extract a properly formed ELF file?
>>
>> 
>
> Effectively the same thing as changing the magic number.  Note that the
> format for bzImage is pretty rigid, and it would be *highly* undesirable
> to muck that up.

So the bzImage structure is currently:

   1. old-style boot sector
   2. old-style boot info, followed by 0xaa55 at the end of the sector
   3. the HdrS boot param block
   4. setup.S boot code
   5. the self-decompressing kernel

If we make 5 actually an ELF file, containing properly formed Ehdr,
Phdrs (for all the mappings required), and the actual kernel
decompressor, relocator and compressed kernel data, then it would be
easy for the Xen domain builder to find that and use it as a basis for
loading.  I think it would just require the bzImage boot param block to
contain an offset of the start of the ELF file.  The contents of the ELF
file would be in a form where the normal boot code could just jump over
the ELF headers, directly into the segment data itself.

ie:

   1. old-style boot sector
   2. old-style boot info, followed by 0xaa55 at the end of the sector
   3. the HdrS boot param block
   4. setup.S boot code (jumps directly into 5.3)
   5. 32-bit self-decompressing kernel:
 1. Ehdr
 2. Phdrs for all necessary mappings
 3. decompressor/relocator .text
 4. compressed kernel data


Does that sound reasonable?

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> 
>> So we won't do this casually and if it there are real problems we will
>> remove the ELF magic number.
>> 
>
> I think we can use ELF-compatible format just fine, but it would make
> more sense to use a non-ELF magic number from the start, instead of
> signalling it with a note.  Since bootloaders need to be aware, anyway,
> they can just detect this magic and treat is as an Linux calling
> convention ELF image, or they can not detect it, and treat it as a
> bzImage.  As a side benefit, we:
>
> a) can use a magic number that contains a jump instruction (to keep the
> non-bootsector happy);
> b) get a proper Linux kernel magic number.

To the best of my knowledge I have already resolved both of those concerns,
in my current code.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread H. Peter Anvin
Eric W. Biederman wrote:
> 
> So we won't do this casually and if it there are real problems we will
> remove the ELF magic number.
> 

I think we can use ELF-compatible format just fine, but it would make
more sense to use a non-ELF magic number from the start, instead of
signalling it with a note.  Since bootloaders need to be aware, anyway,
they can just detect this magic and treat is as an Linux calling
convention ELF image, or they can not detect it, and treat it as a
bzImage.  As a side benefit, we:

a) can use a magic number that contains a jump instruction (to keep the
non-bootsector happy);
b) get a proper Linux kernel magic number.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Jeremy Fitzhardinge wrote:
>> 
>> True.  But the plan is already to make bzImage an ELF file, so notes
>> would seem to be the best option.  At worst, it could be ELF notes
>> wrapped in some other container, but that's not pretty.
>> 
>
> It's not going to happen.  Too many boot loaders make assumptions about
> ELF files which aren't really compatible; the entry conditions for an
> ELF from a boot loader are pretty ill-defined, so I think this is a bad
> idea.
>
> At the very least, it shouldn't present the ELF magic number IMNSHO.

I agree that there are some issues.

However we need the information that is contained in ELF headers or
a semantic equivalent so we might as well play with the possibility.

There are two practical issues for ELF and bootloaders.
virtual vs. physical addresses.   In a bzImage header all
we will present will be physical addresses so that isn't an
issue.

The other issue is what is the format of the arguments that the
executable expects.  There seems to be 0 consensus on this so
bootloaders simply can't agree, and any bootloader that is
prepared to deal with kernels from different locations is going
to have to cope.

So I figure we keep our current calling conventions and have a
note saying that we are linux so the format can be auto-detected.

There are of course plenty of bootloaders that load whatever happens
to be their OS kernel however they managed to get ld to spit it out,
and there are some really weird things going on there.  But that doesn't
matter because those bootloaders can make no pretense at being general
purpose.

There is a lot of future flexibility that comes from this in addition
to making x86 closer to the other architectures.

I do agree we need to tread carefully, but I have yet to hear about
any show stopper bugs, and it works well enough at least one major distro
has shipped a linux kernel bzImage with an ELF header.

So we won't do this casually and if it there are real problems we will
remove the ELF magic number.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote:
> 
> Hm, that's unfortunate.  How about an ELF file wrapped in some other
> container, so that we can easily extract a properly formed ELF file?
> 

Effectively the same thing as changing the magic number.  Note that the
format for bzImage is pretty rigid, and it would be *highly* undesirable
to muck that up.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Jeremy Fitzhardinge
H. Peter Anvin wrote:
> Jeremy Fitzhardinge wrote:
>   
>> True.  But the plan is already to make bzImage an ELF file, so notes
>> would seem to be the best option.  At worst, it could be ELF notes
>> wrapped in some other container, but that's not pretty.
>>
>> 
>
> It's not going to happen.  Too many boot loaders make assumptions about
> ELF files which aren't really compatible; the entry conditions for an
> ELF from a boot loader are pretty ill-defined, so I think this is a bad
> idea.
>
> At the very least, it shouldn't present the ELF magic number IMNSHO.
>   

Hm, that's unfortunate.  How about an ELF file wrapped in some other
container, so that we can easily extract a properly formed ELF file?

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote:
> 
> True.  But the plan is already to make bzImage an ELF file, so notes
> would seem to be the best option.  At worst, it could be ELF notes
> wrapped in some other container, but that's not pretty.
> 

It's not going to happen.  Too many boot loaders make assumptions about
ELF files which aren't really compatible; the entry conditions for an
ELF from a boot loader are pretty ill-defined, so I think this is a bad
idea.

At the very least, it shouldn't present the ELF magic number IMNSHO.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Jeremy Fitzhardinge
Gerd Hoffmann wrote:
> Doesn't need to be ELF notes.  The current (3.0.5+) domain builder has
> pluggable binary parsers.  Right now there are two:  ELF (obviously
> ...) and binary (with a multiboot-like header).  Filling the
> informations such as virt_base is a function of the parser, so when
> adding one more parser to the domain builder for bzImage kernels the
> parser could do something completely different to gather the needed
> information ...

True.  But the plan is already to make bzImage an ELF file, so notes
would seem to be the best option.  At worst, it could be ELF notes
wrapped in some other container, but that's not pretty.

>> That works OK for a kernel which is compiled to run under Xen and can't
>> run in any other environment, but now that we can generate a single
>> kernel which can run in any number of different environments, its
>> unfortunate that we still need multiple variants of the kernel image.
>
> Yep, although already much better than completely different kernels.
> Most space of a typical distro kernel is modules which are shared even
> with different kernel binaries.

Yep.

>> So, I have no problem in also building a boot protocol info structure,
>> and passing that in %esi, so long as I can store a pointer to the
>> Xen-specific info as well.
>
> Yep, should work fine.
>
>> I think I'd prefer to have the domain builder decompress/relocate the
>> kernel from the bzImage and start it directly, rather than have it
>> decompress/relocate itself,
>
> I'd expect that work better too.
>
>> It depends
>> on how well it can deal with having paging enabled and being in ring 1. 
>
> Xen direct paging mode requiring (leaf) page tables being mapped
> read-only makes page table manipulation a bit difficult.  Xen has to
> care whenever the memory it maps is a page table.  Native hasn't.
>
> Also switching to a completely different set of page tables isn't easy
> under Xen.  My xen guest kexec patches have to perform some intresting
> tricks because of that ...

Yeah, that's tricky.  I ended up copying the Xen pagetables's pmd into
the kernel's so that they could share ptes.  Making a completely new
pagetable means you need to update the RO state on both old and new.

>> Looks like it might just be a matter of starting up with "enough" memory
>> mapped.
>
> Doesn't solve the problem of having to switch from identity mapping to
> the 0xc000 one ...

Hm.  That's right.  Xen will boot a vmlinux with its pagetable
pre-constructed to map it at its virtual address.  Going through bzImage
would mean it would be identity mapped, and someone early would need to
construct the virtual mapping.

But if the path is:

   1. enter bzImage in 32-bit mode
   2. decompress kernel
   3. jump to startup_32
   4. detect paravirt and choose appropriate backend
   5. run Xen startup code

then the Xen startup code can construct the virtual mapping before going
on with the rest of the kernel boot - steps 1-4 can be run with identity
mapping.


J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-02 Thread Gerd Hoffmann

Jeremy Fitzhardinge wrote:

Eric W. Biederman wrote:

I have several ideas on how we can make this work but first I have to
ask what is it that you are trying to accomplish?


The requirements are:

   1. the domain builder needs to get various information about the
  guest kernel by inspecting its ELF notes


Doesn't need to be ELF notes.  The current (3.0.5+) domain builder has 
pluggable binary parsers.  Right now there are two:  ELF (obviously ...) 
and binary (with a multiboot-like header).  Filling the informations 
such as virt_base is a function of the parser, so when adding one more 
parser to the domain builder for bzImage kernels the parser could do 
something completely different to gather the needed information ...



That works OK for a kernel which is compiled to run under Xen and can't
run in any other environment, but now that we can generate a single
kernel which can run in any number of different environments, its
unfortunate that we still need multiple variants of the kernel image.


Yep, although already much better than completely different kernels. 
Most space of a typical distro kernel is modules which are shared even 
with different kernel binaries.



So, I have no problem in also building a boot protocol info structure,
and passing that in %esi, so long as I can store a pointer to the
Xen-specific info as well.


Yep, should work fine.


I think I'd prefer to have the domain builder decompress/relocate the
kernel from the bzImage and start it directly, rather than have it
decompress/relocate itself,


I'd expect that work better too.


It depends
on how well it can deal with having paging enabled and being in ring 1. 


Xen direct paging mode requiring (leaf) page tables being mapped 
read-only makes page table manipulation a bit difficult.  Xen has to 
care whenever the memory it maps is a page table.  Native hasn't.


Also switching to a completely different set of page tables isn't easy 
under Xen.  My xen guest kexec patches have to perform some intresting 
tricks because of that ...



Looks like it might just be a matter of starting up with "enough" memory
mapped.


Doesn't solve the problem of having to switch from identity mapping to 
the 0xc000 one ...


cheers,
  Gerd


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-01 Thread Jeremy Fitzhardinge
Rusty Russell wrote:
> Well there aren't that many instructions between startup_32 and
> lguest_init at the moment, but I guess if we end up going through
> bzImage decompression it makes more sense...

Yes, that's what I was thinking.  If we boot compressed kernels in a
novel environment, there's going to be plenty of early debugging going
on.  Fortunately for me, I can just start it up under gdb, so it isn't
all that arduous.

J

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-05-01 Thread Rusty Russell
On Mon, 2007-04-30 at 22:37 -0700, Jeremy Fitzhardinge wrote:
> Eric W. Biederman wrote:
> > I'm not going to worry about going farther until the patches in flight
> > settle down a little bit, but this looks promising.
> >   
> 
> Is there any value in adding an "early-putchar" function pointer into
> the structure somehow?  I could easily arrange for the domain builder to
> put a bit of code into the domain so that the early boot code can emit
> something.

Well there aren't that many instructions between startup_32 and
lguest_init at the moment, but I guess if we end up going through
bzImage decompression it makes more sense...

Rusty.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
Jeremy Fitzhardinge <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> I'm not going to worry about going farther until the patches in flight
>> settle down a little bit, but this looks promising.
>>   
>
> Is there any value in adding an "early-putchar" function pointer into
> the structure somehow?  I could easily arrange for the domain builder to
> put a bit of code into the domain so that the early boot code can emit
> something.

I don't think so.  Once we know what subarch it is we can do a specific
hypervisor call if we need to for early printing.  There are weird
issues like physical vs virtual that would seem to make anything more
generic very difficult to get right, because the code pointed at
would need to be fully pic.

So as a trivial hypervisor call certainly, but I'm pretty doubtful
about a function pointer.  

Then we can do:

if (xen)
   blah
else if (lguest)
   blah2


Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Rusty Russell wrote:
>> 
>> BTW, wrt. a new "platform type" field, should it go something like this?
>> 
>> -0235/3  N/A pad2Unused
>> +0235/1  2.07+   platform_type   Runtime platform (see below)
>> +0236/2  N/A pad2Unused
>> ...
>> +  platform_type:
>> +For kernels which can boot on multiple platforms.  Currently
>> +0 == native (normal), 1 == lguest (paravirtualized).
>> 
>
> Well, yes, but we need to think about if there is more things that
> should be added.  There *definitely* should be space for a platform data
> pointer, to start out with.  I would also like to see a platform data
> field, as well as a bootloader extension field (we're going to have that
> problem soon enough.)

Well in the paravirt case since we are starting virtually mapped
if we don't start with vmlinux but bzImage we need to define what
that virtual address space should contain, and where in the address
space it is safe to put those page tables.

Of the requirements I have heard so far that is the trickiest one.
Because it basically requires us to have a reasonable worst case
estimate of how much memory we are going to use before we start using
the bootmem allocator.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Jeremy Fitzhardinge
Eric W. Biederman wrote:
> I'm not going to worry about going farther until the patches in flight
> settle down a little bit, but this looks promising.
>   

Is there any value in adding an "early-putchar" function pointer into
the structure somehow?  I could easily arrange for the domain builder to
put a bit of code into the domain so that the early boot code can emit
something.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread H. Peter Anvin
Rusty Russell wrote:
> 
> BTW, wrt. a new "platform type" field, should it go something like this?
> 
> -0235/3   N/A pad2Unused
> +0235/1   2.07+   platform_type   Runtime platform (see below)
> +0236/2   N/A pad2Unused
> ...
> +  platform_type:
> + For kernels which can boot on multiple platforms.  Currently
> + 0 == native (normal), 1 == lguest (paravirtualized).
> 

Well, yes, but we need to think about if there is more things that
should be added.  There *definitely* should be space for a platform data
pointer, to start out with.  I would also like to see a platform data
field, as well as a bootloader extension field (we're going to have that
problem soon enough.)

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Rusty Russell
On Mon, 2007-04-30 at 21:00 -0700, H. Peter Anvin wrote:
> H. Peter Anvin wrote:
> > Rusty Russell wrote:
> >> It'd be nicer if there were a "struct boot_params" declaration, but we
> >> can't have everything.
> > 
> > It's in my patchset-under-development.
> > 
> > (Preview snapshot:
> > http://userweb.kernel.org/~hpa/setup-snapshot-2007.04.30.patch)
> 
> Just pushed out a git tree:
> 
> http://git.kernel.org/?p=linux/kernel/git/hpa/linux-2.6-newsetup.git;a=summary

Any chance of splitting off a "struct boot_params" header (includable by
non-kernel code) for inclusion immediately?  The rest can wait until
2.6.23, but it'd be sweet to get this in place sooner.

BTW, wrt. a new "platform type" field, should it go something like this?

-0235/3 N/A pad2Unused
+0235/1 2.07+   platform_type   Runtime platform (see below)
+0236/2 N/A pad2Unused
...
+  platform_type:
+   For kernels which can boot on multiple platforms.  Currently
+   0 == native (normal), 1 == lguest (paravirtualized).

Thanks,
Rusty.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread H. Peter Anvin
H. Peter Anvin wrote:
> Rusty Russell wrote:
>> It'd be nicer if there were a "struct boot_params" declaration, but we
>> can't have everything.
> 
> It's in my patchset-under-development.
> 
> (Preview snapshot:
> http://userweb.kernel.org/~hpa/setup-snapshot-2007.04.30.patch)

Just pushed out a git tree:

http://git.kernel.org/?p=linux/kernel/git/hpa/linux-2.6-newsetup.git;a=summary

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Rusty Russell
On Mon, 2007-04-30 at 20:45 -0700, H. Peter Anvin wrote:
> Rusty Russell wrote:
> > 
> > It'd be nicer if there were a "struct boot_params" declaration, but we
> > can't have everything.
> 
> It's in my patchset-under-development.

Ah ha: excellent!

> > +typedef unsigned long long u64;
> >  typedef uint32_t u32;
> >  typedef uint16_t u16;
> >  typedef uint8_t u8;
> 
> Why not uint64_t to go along with all the other defines?

Because then it's a PITA to printf(): x86-64 has uint64_t as "unsigned
long".  So the lguest64 guys will add all kinds of horrible casts.  This
has the same effect, but ironically is more portable.

Rusty.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
Rusty Russell <[EMAIL PROTECTED]> writes:

> On Mon, 2007-04-30 at 09:34 -0600, Eric W. Biederman wrote:
>> Reading this it occurs to me what I object to wasn't that clear.
>> 
>> I have no problem with the testing of %cs to see if we are not in ring0.
>> That part while a little odd is fine, and we will certainly need a test
>> to skip the protected instructions in head.S
>> 
>> What I object to in particular is having (struct lguest_info?) instead
>> of using the standard format for kernel parameters pointed to in %esi.
>
> Here's a rough patch to see what it looks like from an lguest POV.  It's
> an improvement in many ways: I chose to hardcode the search for matching
> backend rather than use paravirt_probe-style magic.

Cool.

> It'd be nicer if there were a "struct boot_params" declaration, but we
> can't have everything.

Well it will come.  I have an old one in kexec-tools and HPA looks like
he has one in his C rewrite.

I'm not going to worry about going farther until the patches in flight
settle down a little bit, but this looks promising.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread H. Peter Anvin
Rusty Russell wrote:
> 
> It'd be nicer if there were a "struct boot_params" declaration, but we
> can't have everything.

It's in my patchset-under-development.

(Preview snapshot:
http://userweb.kernel.org/~hpa/setup-snapshot-2007.04.30.patch)

> diff -r 9a673a220ad6 Documentation/lguest/lguest.c
> --- a/Documentation/lguest/lguest.c   Mon Apr 30 20:10:26 2007 +1000
> +++ b/Documentation/lguest/lguest.c   Tue May 01 13:19:02 2007 +1000
> @@ -30,10 +30,12 @@
>  #include 
>  #include 
>  #include 
> +typedef unsigned long long u64;
>  typedef uint32_t u32;
>  typedef uint16_t u16;
>  typedef uint8_t u8;

Why not uint64_t to go along with all the other defines?

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Rusty Russell
On Mon, 2007-04-30 at 09:34 -0600, Eric W. Biederman wrote:
> Reading this it occurs to me what I object to wasn't that clear.
> 
> I have no problem with the testing of %cs to see if we are not in ring0.
> That part while a little odd is fine, and we will certainly need a test
> to skip the protected instructions in head.S
> 
> What I object to in particular is having (struct lguest_info?) instead
> of using the standard format for kernel parameters pointed to in %esi.

Here's a rough patch to see what it looks like from an lguest POV.  It's
an improvement in many ways: I chose to hardcode the search for matching
backend rather than use paravirt_probe-style magic.

It'd be nicer if there were a "struct boot_params" declaration, but we
can't have everything.

Cheers,
Rusty.

diff -r 9a673a220ad6 Documentation/lguest/lguest.c
--- a/Documentation/lguest/lguest.c Mon Apr 30 20:10:26 2007 +1000
+++ b/Documentation/lguest/lguest.c Tue May 01 13:19:02 2007 +1000
@@ -30,10 +30,12 @@
 #include 
 #include 
 #include 
+typedef unsigned long long u64;
 typedef uint32_t u32;
 typedef uint16_t u16;
 typedef uint8_t u8;
 #include "../../include/linux/lguest_launcher.h"
+#include "../../include/asm-i386/e820.h"
 
 #define PAGE_PRESENT 0x7   /* Present, RW, Execute */
 #define NET_PEERNUM 1
@@ -915,10 +917,10 @@ static void usage(void)
 
 int main(int argc, char *argv[])
 {
-   unsigned long mem, pgdir, start, page_offset;
+   unsigned long mem, pgdir, start, page_offset, initrd_size = 0;
int c, lguest_fd, waker_fd;
struct device_list device_list;
-   struct lguest_boot_info *boot = (void *)0;
+   void *boot = (void *)0;
const char *initrd_name = NULL;
 
device_list.max_infd = -1;
@@ -966,15 +968,24 @@ int main(int argc, char *argv[])
map_device_descriptors(&device_list, mem);
 
/* Map the initrd image if requested */
-   if (initrd_name)
-   boot->initrd_size = load_initrd(initrd_name, mem);
+   if (initrd_name) {
+   initrd_size = load_initrd(initrd_name, mem);
+   *(unsigned long *)(boot+0x218) = mem - initrd_size;
+   *(unsigned long *)(boot+0x21c) = initrd_size;
+   }
 
/* Set up the initial linar pagetables. */
-   pgdir = setup_pagetables(mem, boot->initrd_size, page_offset);
-
-   /* Give the guest the boot information it needs. */
-   concat(boot->cmdline, argv+optind+2);
-   boot->max_pfn = mem/getpagesize();
+   pgdir = setup_pagetables(mem, initrd_size, page_offset);
+
+   /* E820 memory map: ours is a simple, single region. */
+   *(char*)(boot+E820NR) = 1;
+   *((struct e820entry *)(boot+E820MAP)) 
+   = ((struct e820entry) { 0, mem, E820_RAM });
+   /* Command line pointer and command line (at 4096) */
+   *(void **)(boot + 0x228) = boot + 4096;
+   concat(boot + 4096, argv+optind+2);
+   /* Paravirt type: 1 == lguest */
+   *(int *)(boot + 0x23c) = 1;
 
lguest_fd = tell_kernel(pgdir, start, page_offset);
waker_fd = setup_waker(&device_list);
diff -r 9a673a220ad6 arch/i386/kernel/head.S
--- a/arch/i386/kernel/head.S   Mon Apr 30 20:10:26 2007 +1000
+++ b/arch/i386/kernel/head.S   Tue May 01 12:29:55 2007 +1000
@@ -504,34 +504,17 @@ ignore_int:
 #ifdef CONFIG_PARAVIRT
 startup_paravirt:
cld
+   movl %esi, %eax
+   addl $__PAGE_OFFSET, %eax
movl $(init_thread_union+THREAD_SIZE),%esp
 
-   /* We take pains to preserve all the regs. */
-   pushl   %edx
-   pushl   %ecx
-   pushl   %eax
-
-   pushl   $__start_paravirtprobe
-1:
-   movl0(%esp), %eax
-   cmpl$__stop_paravirtprobe, %eax
-   je  unhandled_paravirt
-   pushl   (%eax)
-   movl8(%esp), %eax
-   call*(%esp)
-   popl%eax
-
-   movl4(%esp), %eax
-   movl8(%esp), %ecx
-   movl12(%esp), %edx
-
-   addl$4, (%esp)
-   jmp 1b
-
-unhandled_paravirt:
+#ifdef CONFIG_LGUEST_GUEST
+   cmpl$1, 0x23c(%eax)
+   je  lguest_init
+#endif
/* Nothing wanted us: we're screwed. */
ud2
-#endif
+#endif /* CONFIG_PARAVIRT */
 
 /*
  * Real beginning of normal "text" segment
diff -r 9a673a220ad6 drivers/lguest/lguest.c
--- a/drivers/lguest/lguest.c   Mon Apr 30 20:10:26 2007 +1000
+++ b/drivers/lguest/lguest.c   Tue May 01 13:28:06 2007 +1000
@@ -53,7 +53,6 @@ struct lguest_data lguest_data = {
.blocked_interrupts = { 1 }, /* Block timer interrupts */
 };
 struct lguest_device_desc *lguest_devices;
-static __initdata const struct lguest_boot_info *boot = __va(0);
 
 static enum paravirt_lazy_mode lazy_mode;
 static void lguest_lazy_mode(enum paravirt_lazy_mode mode)
@@ -378,8 +377,7 @@ static __init char *lguest_memory_setup(
/* We do this here because lockcheck barfs if before start_kernel */
atomic_notifier_chain_register(&panic_notifier_list, &paniced);
 
-   e820

Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread H. Peter Anvin
Andi Kleen wrote:
> 
> It's still unclear to me why exactly you want to rewrite it?
> Are there any particular bugs in the current code you want to fix?
> 

It's more the sheer degree of unmaintainability which is grating on my
nerves.  There is way too much hocus-pocus going on, and I dare to say
that probably noone understands what actually happens in there.

In response to the question about what the code looks like, I have put a
development snapshot patch at:

http://userweb.kernel.org/~hpa/setup-snapshot-2007.04.30.patch

Note that it compiles, but it doesn't work yet.  This is not a
submission, just a "what does the code actually look like" sample.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Andi Kleen
On Mon, Apr 30, 2007 at 04:16:10PM -0700, H. Peter Anvin wrote:
> Eric W. Biederman wrote:
> > 
> > I'm tempted to just reload the segments in setup.S, but that might
> > break loadlin support or one of the other bootloaders that starts the
> > kernel in 32bit mode so we need to be careful.
> > 
> 
> We already load all the segments in setup.S.  I'm retaining this in my
> rewrite.

It's still unclear to me why exactly you want to rewrite it?
Are there any particular bugs in the current code you want to fix?

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> 
>> I'm tempted to just reload the segments in setup.S, but that might
>> break loadlin support or one of the other bootloaders that starts the
>> kernel in 32bit mode so we need to be careful.
>> 
>
> We already load all the segments in setup.S.  I'm retaining this in my
> rewrite.

Good.  I guess I had moved it there in my last cleanup but I wasn't
brave enough yet to remove the reloads from both version of head.S
yet.

We should probably load the segment registers in trampoline.S as
well that would simplify things a little bit.

> Given that I'm rewriting the whole thing, if there are things you want
> setup.S to do, now is the time to ask.

The big wish list item would be subarch detection (at least if we need
it early).  As we are quickly moving to infrastructure that can runtime
switch between subarch's if we can detect the difference.

For the paravirt subarchitectures we are actually going to skip past
setup.S

So the big thing we need to start doing is to document the 32bit entry
point and what can be expected of it etc, especially in the paravirt
context.  But that isn't a setup.S problem.

Oh.  Yes.  We need a parameter structure in the kernel, that documents
what %esi points to later.  What arguments can be found in the
bootloader data.  If you are playing with setup.S in C that tends to
be a setup.S function.

Andi already has a call to verify_cpu so we abort if the cpu can't
handle our current kernel.  While that is not perfect aborting
gracefully in setup.S is a lot better then a lot of the alternatives.

Mostly what we need is to sort through the requirements of this
next boot protocol revision for paravirt loaders so we can do that
cleanly.  It will probably need a subarch type field and a subarch
data pointer field, but except for being stored in Setup.S that
isn't much of a setup.S problem either.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread H. Peter Anvin
Eric W. Biederman wrote:
> 
> I'm tempted to just reload the segments in setup.S, but that might
> break loadlin support or one of the other bootloaders that starts the
> kernel in 32bit mode so we need to be careful.
> 

We already load all the segments in setup.S.  I'm retaining this in my
rewrite.

Given that I'm rewriting the whole thing, if there are things you want
setup.S to do, now is the time to ask.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
Jeremy Fitzhardinge <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>>> I think I'd prefer to have the domain builder decompress/relocate the
>>> kernel from the bzImage and start it directly, rather than have it
>>> decompress/relocate itself, but I'm not really set on that.
>>> 
>>
>> We can change a lot more implementation details arbitrarily if you don't
>> know what needs to happen for decompression and relocation.
>
> Yes, and if it can be made to work, it ultimately means less work
> for me ;)

Now you are beginning to sound like a bootloader author.
Make it work and forget about it :)

>> We have to avoid the writes decompressor-prinnt routines 
>
> At worst, we could set up chunk of memory as a dummy framebuffer.  That
> might be useful for debugging anyway.

I'm trying to recall how we handle this on the LinuxBIOS side.
Because we have machines without a framebuffer setup.  Oh yeah,
we started in 32bit mode...

I do have some parameters to parse the command line in misc.c that
would accomplish this goal.

>> and 
>> possibly the reload of the segment registers.  But otherwise
>> we should be fine.  I don't see any other privileged instructions
>> in arch/i386/boot/compressed/{head.S, misc.c}
>>   
>
> Xen will start the domain with a GDT loaded, and all the segment
> registers loaded with flat segments.  I guess boot/compressed/head.S
> could do the %cs ring check before deciding to do privileged
> operations.

I'm tempted to just reload the segments in setup.S, but that might
break loadlin support or one of the other bootloaders that starts the
kernel in 32bit mode so we need to be careful.


> I presume bzImage jumps straight to startup_32 on the newly decompressed
> kernel?

Straight isn't the way I would but it but yes. startup_32 in arch/i386/head.S
is the first piece of code that outside of the decompressor that it runs.

> I haven't checked if it already has this, but it would be nice if the
> bzImage had a memory range/list of memory ranges it needs mapped to get
> the kernel on its feet, so that the domain builder can just go and map
> those areas for it (either P==V mappings, or with a constant offset;
> whichever is more useful).

P==V mappings I suspect.

> Also, if its a PAE kernel, Xen will start with PAE mode enabled, so
> bzImage will have to deal with that.  But if its not touching
> pagetables, it won't matter.

Exactly.

>> What I really want to do is go back to sticking an ELF header on the
>> bzImage.  We still can't support multiple entry points that way but we
>> can include ELF notes fairly easily.
>>   
>
> That's OK.  We'll be able to use the boot info to go into the
> Xen-specific path shortly after startup_32 anyway.

Yes.

> BTW, the test for a non-ring 0 %cs won't always be a good test for
> paravirtualization; we're likely to start seeing hybrid execution models
> where we run a largely paravirtualized kernel in a SVM/VT container.  If
> we can just unconditionally use the bootloader arch definition to
> determine the entry path into the kernel, it will clean things up nicely.

Yes.  That is why we need a distinct field for this and not overloading
the bootloader id.  That way if the field is non-zero we need to do
something special.

>> It looks like for the next version of booting lguest and Xen are
>> actually coming closer together again.  Yea.
>>
>> For boot protocol. 2.0.7 We currently need a subarchitecture field (16bits?).
>> default == 0, Xen, lguest, voyager?, visws?, numaq?, efi?
>>
>> We need a subarchitecture data pointer field (32bits).
>>   
>
> Do we want to support starting a 64-bit guest in 64-bit mode?

It's the only way that will be sane.  When I was doing my ELF header on
bzImage work I had that working.  But it got dropped due to some unexplained,
unreproducible testing failures and not really being necessary at the
time.  We also need that if we want to be certain we don't play with
page tables.

The other thing the ELF headers gave was a precise accounting of where
the kernel was, which is essentially what needs to be mapped at boot
time.

The hard part I suspect is going to be handling Xen when setup the
physical == virtual page tables

>> We need to target .23 because it is to late for .22.
>
> Yes.  I'll need to do a moderate amount of work on the Xen side to make
> this work, I think.

I think we all will but the upside if we design this carefully is
something that we won't have to change.

Eric

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Jeremy Fitzhardinge
Jeremy Fitzhardinge wrote:
> I haven't checked if it already has this, but it would be nice if the
> bzImage had a memory range/list of memory ranges it needs mapped to get
> the kernel on its feet, so that the domain builder can just go and map
> those areas for it (either P==V mappings, or with a constant offset;
> whichever is more useful).
>   

Of course if it were a properly formed ELF file, you could encode this
in the PHDRs.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Jeremy Fitzhardinge
Eric W. Biederman wrote:
>> I think I'd prefer to have the domain builder decompress/relocate the
>> kernel from the bzImage and start it directly, rather than have it
>> decompress/relocate itself, but I'm not really set on that.
>> 
>
> We can change a lot more implementation details arbitrarily if you don't
> know what needs to happen for decompression and relocation.

Yes, and if it can be made to work, it ultimately means less work for me ;)

> We have to avoid the writes decompressor-prinnt routines 

At worst, we could set up chunk of memory as a dummy framebuffer.  That
might be useful for debugging anyway.

> and 
> possibly the reload of the segment registers.  But otherwise
> we should be fine.  I don't see any other privileged instructions
> in arch/i386/boot/compressed/{head.S, misc.c}
>   

Xen will start the domain with a GDT loaded, and all the segment
registers loaded with flat segments.  I guess boot/compressed/head.S
could do the %cs ring check before deciding to do privileged operations.

I presume bzImage jumps straight to startup_32 on the newly decompressed
kernel?

>> It depends
>> on how well it can deal with having paging enabled and being in ring 1. 
>> Looks like it might just be a matter of starting up with "enough" memory
>> mapped.
>> 
>
> Yes.  I think so.  There is an additional issue of exactly how do we
> get the fixmap region allocated so we can use it but that is minor.
>   

I haven't checked if it already has this, but it would be nice if the
bzImage had a memory range/list of memory ranges it needs mapped to get
the kernel on its feet, so that the domain builder can just go and map
those areas for it (either P==V mappings, or with a constant offset;
whichever is more useful).

Also, if its a PAE kernel, Xen will start with PAE mode enabled, so
bzImage will have to deal with that.  But if its not touching
pagetables, it won't matter.

> What I really want to do is go back to sticking an ELF header on the
> bzImage.  We still can't support multiple entry points that way but we
> can include ELF notes fairly easily.
>   

That's OK.  We'll be able to use the boot info to go into the
Xen-specific path shortly after startup_32 anyway.

BTW, the test for a non-ring 0 %cs won't always be a good test for
paravirtualization; we're likely to start seeing hybrid execution models
where we run a largely paravirtualized kernel in a SVM/VT container.  If
we can just unconditionally use the bootloader arch definition to
determine the entry path into the kernel, it will clean things up nicely.

> It looks like for the next version of booting lguest and Xen are
> actually coming closer together again.  Yea.
>
> For boot protocol. 2.0.7  We currently need a subarchitecture field (16bits?).
> default == 0, Xen, lguest, voyager?, visws?, numaq?, efi?
>
> We need a subarchitecture data pointer field (32bits).
>   

Do we want to support starting a 64-bit guest in 64-bit mode?

> We need to target .23 because it is to late for .22.

Yes.  I'll need to do a moderate amount of work on the Xen side to make
this work, I think.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
Jeremy Fitzhardinge <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> I have several ideas on how we can make this work but first I have to
>> ask what is it that you are trying to accomplish?
>>   
>
> The requirements are:
>
>1. the domain builder needs to get various information about the
>   guest kernel by inspecting its ELF notes
>2. we start the kernel in 32-bit mode with paging enabled, in ring 1
>3. the guest kernel needs various pieces of runtime information from
>   the hypervisor about its runtime environment
>
> At the moment we just load a bare vmlinux kernel with a xen-specific
> entrypoint, so 1 and 2 are easy.  3 is achieved by having the domain
> builder start the kernel with %esi pointing to a Xen info structure
> which tells the kernel what it needs to know.
>
> That works OK for a kernel which is compiled to run under Xen and can't
> run in any other environment, but now that we can generate a single
> kernel which can run in any number of different environments, its
> unfortunate that we still need multiple variants of the kernel image.

Yes.

> Clearly the Xen domain builder needs to be extended to deal with a
> bzImage format kernel directly, so we can use the same actual kernel
> image for native and Xen booting.  Since we're changing the domain
> builder anyway, I can change the details of how it works so long as the
> 3 requirements can still be met.

Ok.

> So, I have no problem in also building a boot protocol info structure,
> and passing that in %esi, so long as I can store a pointer to the
> Xen-specific info as well.  Some info will be duplicated, like the
> initrd location, but that's OK.

Reasonable.

> I'd already reserved a Xen bootloader ID specifically with this in mind;
> all I really need is a place where I can stash the pointer.

Right.

So if you are using the standard linux kernel calling convention and
placing the standard arguments in %esi supporting bzImage gets easier.

> I think I'd prefer to have the domain builder decompress/relocate the
> kernel from the bzImage and start it directly, rather than have it
> decompress/relocate itself, but I'm not really set on that.

We can change a lot more implementation details arbitrarily if you don't
know what needs to happen for decompression and relocation.  Although
I think there is a reasonable argument to support a bImage format.
bzImage without compression.  The current bootloaders would not care
but in the embedded space you can save space but not including the
decompressor in the kernel.

We have to avoid the writes decompressor-prinnt routines and 
possibly the reload of the segment registers.  But otherwise
we should be fine.  I don't see any other privileged instructions
in arch/i386/boot/compressed/{head.S, misc.c}

> It depends
> on how well it can deal with having paging enabled and being in ring 1. 
> Looks like it might just be a matter of starting up with "enough" memory
> mapped.

Yes.  I think so.  There is an additional issue of exactly how do we
get the fixmap region allocated so we can use it but that is minor.

> So the biggest unknown is where to put the Xen ELF notes.

What I really want to do is go back to sticking an ELF header on the
bzImage.  We still can't support multiple entry points that way but we
can include ELF notes fairly easily.

It looks like for the next version of booting lguest and Xen are
actually coming closer together again.  Yea.

For boot protocol. 2.0.7  We currently need a subarchitecture field (16bits?).
default == 0, Xen, lguest, voyager?, visws?, numaq?, efi?

We need a subarchitecture data pointer field (32bits).

We need some subarchitecture kernel information for the different
bootloader.

We need to target .23 because it is to late for .22.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Jeremy Fitzhardinge
Eric W. Biederman wrote:
> I have several ideas on how we can make this work but first I have to
> ask what is it that you are trying to accomplish?
>   

The requirements are:

   1. the domain builder needs to get various information about the
  guest kernel by inspecting its ELF notes
   2. we start the kernel in 32-bit mode with paging enabled, in ring 1
   3. the guest kernel needs various pieces of runtime information from
  the hypervisor about its runtime environment

At the moment we just load a bare vmlinux kernel with a xen-specific
entrypoint, so 1 and 2 are easy.  3 is achieved by having the domain
builder start the kernel with %esi pointing to a Xen info structure
which tells the kernel what it needs to know.

That works OK for a kernel which is compiled to run under Xen and can't
run in any other environment, but now that we can generate a single
kernel which can run in any number of different environments, its
unfortunate that we still need multiple variants of the kernel image.

Clearly the Xen domain builder needs to be extended to deal with a
bzImage format kernel directly, so we can use the same actual kernel
image for native and Xen booting.  Since we're changing the domain
builder anyway, I can change the details of how it works so long as the
3 requirements can still be met.

So, I have no problem in also building a boot protocol info structure,
and passing that in %esi, so long as I can store a pointer to the
Xen-specific info as well.  Some info will be duplicated, like the
initrd location, but that's OK.

I'd already reserved a Xen bootloader ID specifically with this in mind;
all I really need is a place where I can stash the pointer.

I think I'd prefer to have the domain builder decompress/relocate the
kernel from the bzImage and start it directly, rather than have it
decompress/relocate itself, but I'm not really set on that.  It depends
on how well it can deal with having paging enabled and being in ring 1. 
Looks like it might just be a matter of starting up with "enough" memory
mapped.

So the biggest unknown is where to put the Xen ELF notes.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> 
>> Sure.
>> 
>> Peter do we want to use the bootloader byte and assign lguest it's own
>> bootloader type or do we want to add another field specific to 
>> paravirtualized environments?
>> 
>
> The bootloader byte is already a bit too overused; I'm a little scared
> that we're going to run out of boot loader IDs as it is.
>
> We probably should add another field, and while we're at it maybe we
> should add a boot loader extension field.

A dedicated subarchitecture field would make sense.  One of the pieces
that would be nice is if we could detect other non paravirt
subarchitectures.

James is there a reasonable way to detect voyager at boot time?
So we could potentially have a generic kernel that can also boot on
voyager?

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread H. Peter Anvin
Eric W. Biederman wrote:
> 
> Sure.
> 
> Peter do we want to use the bootloader byte and assign lguest it's own
> bootloader type or do we want to add another field specific to 
> paravirtualized environments?
> 

The bootloader byte is already a bit too overused; I'm a little scared
that we're going to run out of boot loader IDs as it is.

We probably should add another field, and while we're at it maybe we
should add a boot loader extension field.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-30 Thread Eric W. Biederman
Rusty Russell <[EMAIL PROTECTED]> writes:

> On Sun, 2007-04-29 at 21:38 -0700, H. Peter Anvin wrote:
>> Rusty Russell wrote:
>> > 
>> > Dammit, Eric, you spend a lot of time using words like "insane" where
>> > you mean we didn't do everything all at once.
>> > 
>> > It's *not* clear that using %esi is sane, but nothing in the current
>> > code prevents that.
>> 
>> Why not?
>
> (I assume you mean why isn't it clear?)
>
> Because VMI uses the presence of a ROM to indicate it's not native.  KVM
> uses a magic MSR IIRC.
>
> I think it makes sense for lguest to change over, tho.  Patches welcome
> 8)

Reading this it occurs to me what I object to wasn't that clear.

I have no problem with the testing of %cs to see if we are not in ring0.
That part while a little odd is fine, and we will certainly need a test
to skip the protected instructions in head.S

What I object to in particular is having (struct lguest_info?) instead
of using the standard format for kernel parameters pointed to in %esi.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread Eric W. Biederman
Rusty Russell <[EMAIL PROTECTED]> writes:

> On Sun, 2007-04-29 at 21:38 -0700, H. Peter Anvin wrote:
>> Rusty Russell wrote:
>> > 
>> > Dammit, Eric, you spend a lot of time using words like "insane" where
>> > you mean we didn't do everything all at once.
>> > 
>> > It's *not* clear that using %esi is sane, but nothing in the current
>> > code prevents that.
>> 
>> Why not?
>
> (I assume you mean why isn't it clear?)
>
> Because VMI uses the presence of a ROM to indicate it's not native.  KVM
> uses a magic MSR IIRC.

Reasonable, if you don't mid a little hardware emulation.

> I think it makes sense for lguest to change over, tho.  Patches welcome
> 8)

Sure.

Peter do we want to use the bootloader byte and assign lguest it's own
bootloader type or do we want to add another field specific to 
paravirtualized environments?

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread Rusty Russell
On Sun, 2007-04-29 at 21:38 -0700, H. Peter Anvin wrote:
> Rusty Russell wrote:
> > 
> > Dammit, Eric, you spend a lot of time using words like "insane" where
> > you mean we didn't do everything all at once.
> > 
> > It's *not* clear that using %esi is sane, but nothing in the current
> > code prevents that.
> 
> Why not?

(I assume you mean why isn't it clear?)

Because VMI uses the presence of a ROM to indicate it's not native.  KVM
uses a magic MSR IIRC.

I think it makes sense for lguest to change over, tho.  Patches welcome
8)

Rusty.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread Rusty Russell
On Sun, 2007-04-29 at 00:24 -0700, Jeremy Fitzhardinge wrote:
> Is it possible to decompress and extract the kernel image from the
> bzImage without executing it?  Ie, is there enough information to find
> the compressed data part of the bzImage by inspection?
> 
> At some point we'll need to change the Xen domain builder to handle
> bzImage files, and it would be best if we didn't need to run them.

Almost.  See lguest's launcher code: load_bzimage().  You'll hate it 8)

Rusty.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread H. Peter Anvin
Rusty Russell wrote:
> 
> Dammit, Eric, you spend a lot of time using words like "insane" where
> you mean we didn't do everything all at once.
> 
> It's *not* clear that using %esi is sane, but nothing in the current
> code prevents that.
> 

Why not?

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread Rusty Russell
On Sun, 2007-04-29 at 09:11 -0600, Eric W. Biederman wrote:
>   Right now I'm a little frustrated that insanity below slipped into
>   head.S right after the 32bit entry point after the review said
>   use the normal linux parameters for parameter passing.
>   
>   > #ifdef CONFIG_PARAVIRT
>   > movl %cs, %eax
>   > testl $0x3, %eax
>   > jnz startup_paravirt
>   > #endif
>   
>   The whole thing should be based on a value in the linux parameter block
>   pointed to by %esi, instead of the insane preserve all registers and
>   attempt to be super compatible with everyone.

Dammit, Eric, you spend a lot of time using words like "insane" where
you mean we didn't do everything all at once.

It's *not* clear that using %esi is sane, but nothing in the current
code prevents that.

I was trying to get Xen to use this entry point rather than their own: I
failed, and only lguest now uses it.

Fortunately, this also means it's trivial to change.
Rusty.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Jeremy Fitzhardinge wrote:
>> Eric W. Biederman wrote:
>>> All it does is set a flag that tells a bootloader.
>>> "Hey. I can run when loaded a non-default address, and this is what
>>>  you have to align me to."
>>>
>>> All relocation processing happens in the kernel itself.
>>>   
>> 
>> Is it possible to decompress and extract the kernel image from the
>> bzImage without executing it?  Ie, is there enough information to find
>> the compressed data part of the bzImage by inspection?
>> 
>> At some point we'll need to change the Xen domain builder to handle
>> bzImage files, and it would be best if we didn't need to run them.
>> 
>
> Probabilistically, you might be able to (search for a gzip header), but
> it is *definitely* not guaranteed by protocol.

I suspect the issue isn't so much skipping the decompression
but either getting at the Xen ELF notes or bypassing privileged instructions.


Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote:
> Eric W. Biederman wrote:
>> All it does is set a flag that tells a bootloader.
>> "Hey. I can run when loaded a non-default address, and this is what
>>  you have to align me to."
>>
>> All relocation processing happens in the kernel itself.
>>   
> 
> Is it possible to decompress and extract the kernel image from the
> bzImage without executing it?  Ie, is there enough information to find
> the compressed data part of the bzImage by inspection?
> 
> At some point we'll need to change the Xen domain builder to handle
> bzImage files, and it would be best if we didn't need to run them.
> 

Probabilistically, you might be able to (search for a gzip header), but
it is *definitely* not guaranteed by protocol.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread Eric W. Biederman
Jeremy Fitzhardinge <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> All it does is set a flag that tells a bootloader.
>> "Hey. I can run when loaded a non-default address, and this is what
>>  you have to align me to."
>>
>> All relocation processing happens in the kernel itself.
>>   
>
> Is it possible to decompress and extract the kernel image from the
> bzImage without executing it?  Ie, is there enough information to find
> the compressed data part of the bzImage by inspection?
>
> At some point we'll need to change the Xen domain builder to handle
> bzImage files, and it would be best if we didn't need to run them.

/sbin/kexec bzImage 

There is a 32bit entry point that is reasonably well specified
you can use.  I'm guessing you want to recover the 64bit ELF,
with all of your nice ELF notes etc.  vmlinux is run through
"objcopy -O binary" as part of the bzImage build process so all
of the ELF metadata is lost.

I have several ideas on how we can make this work but first I have to
ask what is it that you are trying to accomplish?


  Right now I'm a little frustrated that insanity below slipped into
  head.S right after the 32bit entry point after the review said
  use the normal linux parameters for parameter passing.
  
  > #ifdef CONFIG_PARAVIRT
  > movl %cs, %eax
  > testl $0x3, %eax
  > jnz startup_paravirt
  > #endif
  
  The whole thing should be based on a value in the linux parameter block
  pointed to by %esi, instead of the insane preserve all registers and
  attempt to be super compatible with everyone.

  Yes we do need a branch there, but no we don't need to be changing 
  the format we pass arguments to the kernel in.


Anyway since it seems there is interest in going farther in tweaking
the linux boot process let's open thread up to what is needed/wanted
for future enhancements to linux booting, and let's see if we can
design something that works and isn't brain dead.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-29 Thread Jeremy Fitzhardinge
Eric W. Biederman wrote:
> All it does is set a flag that tells a bootloader.
> "Hey. I can run when loaded a non-default address, and this is what
>  you have to align me to."
>
> All relocation processing happens in the kernel itself.
>   

Is it possible to decompress and extract the kernel image from the
bzImage without executing it?  Ie, is there enough information to find
the compressed data part of the bzImage by inspection?

At some point we'll need to change the Xen domain builder to handle
bzImage files, and it would be best if we didn't need to run them.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-28 Thread Vivek Goyal
On Sat, Apr 28, 2007 at 02:46:18PM -0600, Eric W. Biederman wrote:
> "H. Peter Anvin" <[EMAIL PROTECTED]> writes:
> 
> > Eric W. Biederman wrote:
> >> 
> >> The boot protocol change is in 2.6.21 for arch/i386.
> >> 
> >> HPA looked at it a while ago.
> >> 
> >> All it does is set a flag that tells a bootloader.
> >> "Hey. I can run when loaded a non-default address, and this is what
> >>  you have to align me to."
> >> 
> >> All relocation processing happens in the kernel itself.
> >> 
> >> So it is all pretty trivial.
> >> 
> >
> > Indeed.  We *did* find some problems with Grub with the early versions,
> > those were addressed.
> 
> We found some failures that weren't root caused so we went to this
> more conservative version.
> 
> RHEL5 is actually shipping the original version of these patches if I
> recall correctly.
> 

Yes, RHEL5 is shipping original version of patches where an where and ELF
header has been added to describe bzImage.

Thanks
Vivek
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-28 Thread Eric W. Biederman
"H. Peter Anvin" <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
>> 
>> The boot protocol change is in 2.6.21 for arch/i386.
>> 
>> HPA looked at it a while ago.
>> 
>> All it does is set a flag that tells a bootloader.
>> "Hey. I can run when loaded a non-default address, and this is what
>>  you have to align me to."
>> 
>> All relocation processing happens in the kernel itself.
>> 
>> So it is all pretty trivial.
>> 
>
> Indeed.  We *did* find some problems with Grub with the early versions,
> those were addressed.

We found some failures that weren't root caused so we went to this
more conservative version.

RHEL5 is actually shipping the original version of these patches if I
recall correctly.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-28 Thread Jeff Garzik
No specific concern; the patch description did not say that bootloader 
people had ACK'd the change, or describe the testing regimen.


Just reading the patch, the impact and preparation were unknowns.

Jeff



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-28 Thread H. Peter Anvin
Eric W. Biederman wrote:
> 
> The boot protocol change is in 2.6.21 for arch/i386.
> 
> HPA looked at it a while ago.
> 
> All it does is set a flag that tells a bootloader.
> "Hey. I can run when loaded a non-default address, and this is what
>  you have to align me to."
> 
> All relocation processing happens in the kernel itself.
> 
> So it is all pretty trivial.
> 

Indeed.  We *did* find some problems with Grub with the early versions,
those were addressed.

-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patches] [PATCH] [21/22] x86_64: Extend bzImage protocol for relocatable bzImage

2007-04-28 Thread Eric W. Biederman
Jeff Garzik <[EMAIL PROTECTED]> writes:

> Andi Kleen wrote:
>> From: Vivek Goyal <[EMAIL PROTECTED]>
>> 
>> 
>> o Extend the bzImage protocol (same as i386) to allow bzImage loaders to
>>   load the protected mode kernel at non-1MB address. Now protected mode
>>   component is relocatable and can be loaded at non-1MB addresses.
>> 
>> o As of today kdump uses it to run a second kernel from a reserved memory
>>   area.
>> 
>> Signed-off-by: Vivek Goyal <[EMAIL PROTECTED]>
>> Signed-off-by: Vivek Goyal <[EMAIL PROTECTED]>
>> Signed-off-by: Andi Kleen <[EMAIL PROTECTED]>
>
> Can you point to / link to threads where the bootloader folks looked 
> over the reloc changes from their side, and commented?

Jeff what is your concern.

The boot protocol change is in 2.6.21 for arch/i386.

HPA looked at it a while ago.

All it does is set a flag that tells a bootloader.
"Hey. I can run when loaded a non-default address, and this is what
 you have to align me to."

All relocation processing happens in the kernel itself.

So it is all pretty trivial.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/