LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RELEASE] Lguest for 2.6.21
@ 2007-05-02 14:43 Rusty Russell
  2007-05-02 19:33 ` WANG Cong
  2007-05-03 16:02 ` Matt Mackall
  0 siblings, 2 replies; 12+ messages in thread
From: Rusty Russell @ 2007-05-02 14:43 UTC (permalink / raw)
  To: lkml - Kernel Mailing List, virtualization

Hi all,

	Lguest is a simple hypervisor which runs Linux under Linux, without
needing VT hardware.

	Two people asked if I had a version of lguest which worked on
other-than-bleeding-edge-mm kernels, so I did a backport of the latest
version to 2.6.21.

	http://lguest.ozlabs.org/lguest-2.6.21-254.patch.gz

See Documentation/lguest/lguest.txt for how to run,
drivers/lguest/README for the draft code documentation journey.

Bug or even success reports always welcome!
Rusty.


Quickstart:

$ cd linux-2.6.21
$ zcat /tmp/lguest-2.6.21-254.patch.gz | patch -p1
$ make
	- Say "y" to CONFIG_EXPERIMENTAL, "m" to CONFIG_LGUEST.
$ make modules_install
$ make -C Documentation/lguest
$ sudo Documentation/lguest/lguest --block=<some-convenient-raw-image> \
	128 vmlinux root=/dev/lgba

Three ^C's within one second will kill the guest.




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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-02 14:43 [RELEASE] Lguest for 2.6.21 Rusty Russell
@ 2007-05-02 19:33 ` WANG Cong
  2007-05-02 19:59   ` WANG Cong
  2007-05-02 23:00   ` Rusty Russell
  2007-05-03 16:02 ` Matt Mackall
  1 sibling, 2 replies; 12+ messages in thread
From: WANG Cong @ 2007-05-02 19:33 UTC (permalink / raw)
  To: Rusty Russell; +Cc: lkml - Kernel Mailing List, virtualization

Hi Rusty!

I found you forgot to check the return value of copy_from_user, and here is the fix for drivers/lguest/interrupts_and_traps.c.

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

---

--- linux-2.6.21-rc7-mm2/drivers/lguest/interrupts_and_traps.c.orig	2007-05-03 03:10:44.000000000 +0800
+++ linux-2.6.21-rc7-mm2/drivers/lguest/interrupts_and_traps.c	2007-05-03 03:11:42.000000000 +0800
@@ -75,7 +75,8 @@ void maybe_do_interrupt(struct lguest *l
 		set_bit(0, lg->irqs_pending);
 
 	/* Mask out any interrupts they have blocked. */
-	copy_from_user(&blk, lg->lguest_data->blocked_interrupts, sizeof(blk));
+	if (copy_from_user(&blk, lg->lguest_data->blocked_interrupts, sizeof(blk)))
+		return;
 	bitmap_andnot(blk, lg->irqs_pending, blk, LGUEST_IRQS);
 
 	irq = find_first_bit(blk, LGUEST_IRQS);

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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-02 19:33 ` WANG Cong
@ 2007-05-02 19:59   ` WANG Cong
  2007-05-02 23:00   ` Rusty Russell
  1 sibling, 0 replies; 12+ messages in thread
From: WANG Cong @ 2007-05-02 19:59 UTC (permalink / raw)
  To: Rusty Russell, lkml - Kernel Mailing List, virtualization

On Thu, May 03, 2007 at 03:33:03AM +0800, WANG Cong wrote:
>Hi Rusty!
>
>I found you forgot to check the return value of copy_from_user, and here is the fix for drivers/lguest/interrupts_and_traps.c.
>

Also this one, in drivers/lguest/hypercalls.c.

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

---

--- linux-2.6.21-rc7-mm2/drivers/lguest/hypercalls.c.orig	2007-05-03 03:45:53.000000000 +0800
+++ linux-2.6.21-rc7-mm2/drivers/lguest/hypercalls.c	2007-05-03 03:46:20.000000000 +0800
@@ -102,7 +102,8 @@ static void do_async_hcalls(struct lgues
 	unsigned int i;
 	u8 st[LHCALL_RING_SIZE];
 
-	copy_from_user(&st, &lg->lguest_data->hcall_status, sizeof(st));
+	if (copy_from_user(&st, &lg->lguest_data->hcall_status, sizeof(st)))
+		return;
 	for (i = 0; i < ARRAY_SIZE(st); i++) {
 		struct lguest_regs regs;
 		unsigned int n = lg->next_hcall;

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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-02 19:33 ` WANG Cong
  2007-05-02 19:59   ` WANG Cong
@ 2007-05-02 23:00   ` Rusty Russell
  2007-05-03  3:57     ` WANG Cong
  1 sibling, 1 reply; 12+ messages in thread
From: Rusty Russell @ 2007-05-02 23:00 UTC (permalink / raw)
  To: WANG Cong; +Cc: lkml - Kernel Mailing List, virtualization

On Thu, 2007-05-03 at 03:33 +0800, WANG Cong wrote:
> Hi Rusty!
> 
> I found you forgot to check the return value of copy_from_user, and
> here is the fix for drivers/lguest/interrupts_and_traps.c.
> 
> Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

Hi Wang!

	Thanks for the patch.  This omission (in several places) was
deliberate.  We can't really do anything sensible if the user unmapped
the page.  I assume you saw a gcc warning from this code?

	We could also use lgread() in these places which does this check and
kills the guest if something goes wrong.  I'll check the benchmarks to
make sure the (slight) extra overhead doesn't cause a regression...

Thanks!
Rusty.


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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-02 23:00   ` Rusty Russell
@ 2007-05-03  3:57     ` WANG Cong
  2007-05-03  4:20       ` Rusty Russell
  0 siblings, 1 reply; 12+ messages in thread
From: WANG Cong @ 2007-05-03  3:57 UTC (permalink / raw)
  To: Rusty Russell; +Cc: lkml - Kernel Mailing List, virtualization

On Thu, May 03, 2007 at 09:00:48AM +1000, Rusty Russell wrote:
>On Thu, 2007-05-03 at 03:33 +0800, WANG Cong wrote:
>> Hi Rusty!
>> 
>> I found you forgot to check the return value of copy_from_user, and
>> here is the fix for drivers/lguest/interrupts_and_traps.c.
>> 
>> Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
>
>Hi Wang!
>
>	Thanks for the patch.  This omission (in several places) was
>deliberate.  We can't really do anything sensible if the user unmapped
>the page.  I assume you saw a gcc warning from this code?

Yes. In fact, I got two warnings, another one is in drivers/lguest/hypercalls.c.

If I understand you correctly, you mean we can do nothing useful to fix it?

>
>	We could also use lgread() in these places which does this check and
>kills the guest if something goes wrong.  I'll check the benchmarks to
>make sure the (slight) extra overhead doesn't cause a regression...
>
>Thanks!
>Rusty.

I have sent a mail which described the errors I got when comipling Documentation/lguest/lguest.c. But it seems that you didn't receive it (it didn't appear in lkml.org neither!). It is that, I have already made my .config as you suggested, but I still can't compile Documentation/lguest/lguest.c, errors are:

lguest.c: In function 'add_to_bridge':
lguest.c:779: error: 'SIOCBRADDIF' undeclared (first use in this function)
lguest.c:779: error: (Each undeclared identifier is reported only once
lguest.c:779: error: for each function it appears in.)

Can you help me out?

Thanks!


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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-03  3:57     ` WANG Cong
@ 2007-05-03  4:20       ` Rusty Russell
  2007-05-03  5:43         ` WANG Cong
  0 siblings, 1 reply; 12+ messages in thread
From: Rusty Russell @ 2007-05-03  4:20 UTC (permalink / raw)
  To: WANG Cong; +Cc: lkml - Kernel Mailing List, virtualization

On Thu, 2007-05-03 at 11:57 +0800, WANG Cong wrote:
> On Thu, May 03, 2007 at 09:00:48AM +1000, Rusty Russell wrote:
> >	Thanks for the patch.  This omission (in several places) was
> >deliberate.  We can't really do anything sensible if the user unmapped
> >the page.  I assume you saw a gcc warning from this code?
> 
> Yes. In fact, I got two warnings, another one is in drivers/lguest/hypercalls.c.
> 
> If I understand you correctly, you mean we can do nothing useful to fix it?

We can, but we can ignore those warnings for the moment; they're
harmless.

> I have sent a mail which described the errors I got when comipling
> Documentation/lguest/lguest.c. But it seems that you didn't receive it
> (it didn't appear in lkml.org neither!).

Hmm, no, I didn't get it here either 8(

>  It is that, I have already made my .config as you suggested, but I
> still can't compile Documentation/lguest/lguest.c, errors are:
> 
> lguest.c: In function 'add_to_bridge':
> lguest.c:779: error: 'SIOCBRADDIF' undeclared (first use in this function)
> lguest.c:779: error: (Each undeclared identifier is reported only once
> lguest.c:779: error: for each function it appears in.)

Ah, perhaps older libc headers?  Can you try adding this to the top of
Documentation/lguest/lguest.c after the #define BRIDGE_PFX "bridge:"

#ifndef SIOCBRADDIF
#define SIOCBRADDIF	0x89a2		/* add interface to bridge      */
#endif

Thanks,
Rusty.


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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-03  4:20       ` Rusty Russell
@ 2007-05-03  5:43         ` WANG Cong
  0 siblings, 0 replies; 12+ messages in thread
From: WANG Cong @ 2007-05-03  5:43 UTC (permalink / raw)
  To: Rusty Russell; +Cc: lkml - Kernel Mailing List, virtualization

On Thu, May 03, 2007 at 02:20:32PM +1000, Rusty Russell wrote:
>On Thu, 2007-05-03 at 11:57 +0800, WANG Cong wrote:
>> On Thu, May 03, 2007 at 09:00:48AM +1000, Rusty Russell wrote:
>> >	Thanks for the patch.  This omission (in several places) was
>> >deliberate.  We can't really do anything sensible if the user unmapped
>> >the page.  I assume you saw a gcc warning from this code?
>> 
>> Yes. In fact, I got two warnings, another one is in drivers/lguest/hypercalls.c.
>> 
>> If I understand you correctly, you mean we can do nothing useful to fix it?
>
>We can, but we can ignore those warnings for the moment; they're
>harmless.

OK.

>
>> I have sent a mail which described the errors I got when comipling
>> Documentation/lguest/lguest.c. But it seems that you didn't receive it
>> (it didn't appear in lkml.org neither!).
>
>Hmm, no, I didn't get it here either 8(
>
>>  It is that, I have already made my .config as you suggested, but I
>> still can't compile Documentation/lguest/lguest.c, errors are:
>> 
>> lguest.c: In function 'add_to_bridge':
>> lguest.c:779: error: 'SIOCBRADDIF' undeclared (first use in this function)
>> lguest.c:779: error: (Each undeclared identifier is reported only once
>> lguest.c:779: error: for each function it appears in.)
>
>Ah, perhaps older libc headers?  Can you try adding this to the top of
>Documentation/lguest/lguest.c after the #define BRIDGE_PFX "bridge:"
>
>#ifndef SIOCBRADDIF
>#define SIOCBRADDIF	0x89a2		/* add interface to bridge      */
>#endif
>
>Thanks,
>Rusty.

Yes, it works. Thanks very much for your pointing.

I have already found you also forgot some checking in this user-space code. I will fix them soon. ;)

Regards.
WANG Cong

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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-02 14:43 [RELEASE] Lguest for 2.6.21 Rusty Russell
  2007-05-02 19:33 ` WANG Cong
@ 2007-05-03 16:02 ` Matt Mackall
  2007-05-04  0:13   ` Rusty Russell
  1 sibling, 1 reply; 12+ messages in thread
From: Matt Mackall @ 2007-05-03 16:02 UTC (permalink / raw)
  To: Rusty Russell; +Cc: lkml - Kernel Mailing List, virtualization

On Thu, May 03, 2007 at 12:43:48AM +1000, Rusty Russell wrote:
> Hi all,
> 
> 	Lguest is a simple hypervisor which runs Linux under Linux, without
> needing VT hardware.
> 
> 	Two people asked if I had a version of lguest which worked on
> other-than-bleeding-edge-mm kernels, so I did a backport of the latest
> version to 2.6.21.
> 
> 	http://lguest.ozlabs.org/lguest-2.6.21-254.patch.gz
> 
> See Documentation/lguest/lguest.txt for how to run,
> drivers/lguest/README for the draft code documentation journey.

Your lguest readme is quite lacking in the area of how to configure a
guest kernel as opposed to the host kernel. More hand-holding, please.

Maybe it's obvious once I've actually applied the patch and run
menuconfig, but I'm loathe to attempt anything that isn't a cake walk
at my current loadavg, especially given the fits of blind rage trying
to do anything nontrivial with Xen tends to provoke in me.

-- 
Mathematics is the supreme nostalgia of our time.

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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-03 16:02 ` Matt Mackall
@ 2007-05-04  0:13   ` Rusty Russell
  2007-05-04  0:43     ` Rusty Russell
  0 siblings, 1 reply; 12+ messages in thread
From: Rusty Russell @ 2007-05-04  0:13 UTC (permalink / raw)
  To: Matt Mackall; +Cc: lkml - Kernel Mailing List, virtualization

On Thu, 2007-05-03 at 11:02 -0500, Matt Mackall wrote:
> On Thu, May 03, 2007 at 12:43:48AM +1000, Rusty Russell wrote:
> > 	http://lguest.ozlabs.org/lguest-2.6.21-254.patch.gz
> > 
> > See Documentation/lguest/lguest.txt for how to run,
> > drivers/lguest/README for the draft code documentation journey.
> 
> Your lguest readme is quite lacking in the area of how to configure a
> guest kernel as opposed to the host kernel. More hand-holding, please.

Hi Matt!

	Ah, that's because they are the same kernel.  Turning on CONFIG_LGUEST
builds-in the parts needed to be a guest as well.

Thanks for pointing out that weakness.  I will modify lguest.txt to make
that clear.

Cheers,
Rusty.


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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-04  0:13   ` Rusty Russell
@ 2007-05-04  0:43     ` Rusty Russell
  2007-05-04  3:20       ` Matt Mackall
  0 siblings, 1 reply; 12+ messages in thread
From: Rusty Russell @ 2007-05-04  0:43 UTC (permalink / raw)
  To: Matt Mackall; +Cc: lkml - Kernel Mailing List, virtualization

On Fri, 2007-05-04 at 10:13 +1000, Rusty Russell wrote:
> On Thu, 2007-05-03 at 11:02 -0500, Matt Mackall wrote:
> > On Thu, May 03, 2007 at 12:43:48AM +1000, Rusty Russell wrote:
> > > 	http://lguest.ozlabs.org/lguest-2.6.21-254.patch.gz
> > > 
> > > See Documentation/lguest/lguest.txt for how to run,
> > > drivers/lguest/README for the draft code documentation journey.
> > 
> > Your lguest readme is quite lacking in the area of how to configure a
> > guest kernel as opposed to the host kernel. More hand-holding, please.
> 
> Hi Matt!
> 
> 	Ah, that's because they are the same kernel.  Turning on CONFIG_LGUEST
> builds-in the parts needed to be a guest as well.
> 
> Thanks for pointing out that weakness.  I will modify lguest.txt to make
> that clear.

Something like this:

diff -r 940ec1c6ac5a Documentation/lguest/lguest.txt
--- a/Documentation/lguest/lguest.txt	Thu May 03 23:00:19 2007 +1000
+++ b/Documentation/lguest/lguest.txt	Fri May 04 10:17:23 2007 +1000
@@ -23,7 +23,10 @@ Developer features:
 
 Running Lguest:
 
-- You will need to configure your kernel with the following options:
+- Lguest runs the same kernel as guest and host.  You can configure
+  them differently, but usually it's easiest not to.
+
+  You will need to configure your kernel with the following options:
 
   CONFIG_HIGHMEM64G=n ("High Memory Support" "64GB")[1]
   CONFIG_TUN=y/m ("Universal TUN/TAP device driver support")

Cheers,
Rusty.



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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-04  0:43     ` Rusty Russell
@ 2007-05-04  3:20       ` Matt Mackall
  2007-05-04  3:39         ` Rusty Russell
  0 siblings, 1 reply; 12+ messages in thread
From: Matt Mackall @ 2007-05-04  3:20 UTC (permalink / raw)
  To: Rusty Russell; +Cc: lkml - Kernel Mailing List, virtualization

On Fri, May 04, 2007 at 10:43:09AM +1000, Rusty Russell wrote:
> On Fri, 2007-05-04 at 10:13 +1000, Rusty Russell wrote:
> > On Thu, 2007-05-03 at 11:02 -0500, Matt Mackall wrote:
> > > On Thu, May 03, 2007 at 12:43:48AM +1000, Rusty Russell wrote:
> > > > 	http://lguest.ozlabs.org/lguest-2.6.21-254.patch.gz
> > > > 
> > > > See Documentation/lguest/lguest.txt for how to run,
> > > > drivers/lguest/README for the draft code documentation journey.
> > > 
> > > Your lguest readme is quite lacking in the area of how to configure a
> > > guest kernel as opposed to the host kernel. More hand-holding, please.
> > 
> > Hi Matt!
> > 
> > 	Ah, that's because they are the same kernel.  Turning on CONFIG_LGUEST
> > builds-in the parts needed to be a guest as well.

Ok, I thought that might be a possibility.
 
> -- You will need to configure your kernel with the following options:
> +- Lguest runs the same kernel as guest and host.  You can configure
> +  them differently, but usually it's easiest not to.

I take it both sides of the virtual device drivers are turned on by
the lguest option?

For the purposes of kernel hacking, I'd want to boot into one build
and repeatedly launch another build as a guest, thereby getting
faster hack/build/test cycles than either qemu or full reboot.
How tightly coupled are things here?

-- 
Mathematics is the supreme nostalgia of our time.

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

* Re: [RELEASE] Lguest for 2.6.21
  2007-05-04  3:20       ` Matt Mackall
@ 2007-05-04  3:39         ` Rusty Russell
  0 siblings, 0 replies; 12+ messages in thread
From: Rusty Russell @ 2007-05-04  3:39 UTC (permalink / raw)
  To: Matt Mackall; +Cc: lkml - Kernel Mailing List, virtualization

On Thu, 2007-05-03 at 22:20 -0500, Matt Mackall wrote:
> I take it both sides of the virtual device drivers are turned on by
> the lguest option?

Yeah, to quote the code in drivers/lguest/lguest_bus.c:

/* At the moment we build all the drivers into the kernel because they're so
 * simple: 8144 bytes for all three of them as I type this.  And as the console
 * really needs to be built in, it's actually only 3527 bytes for the network
 * and block drivers.

> For the purposes of kernel hacking, I'd want to boot into one build
> and repeatedly launch another build as a guest, thereby getting
> faster hack/build/test cycles than either qemu or full reboot.
> How tightly coupled are things here?

I do that all the time, too.  The main issue is that we provide no ABI
for lguest (at least, not yet), so if you actually change guest/host
kernel version, you're on your own...

Thanks!
Rusty.



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

end of thread, other threads:[~2007-05-04  3:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-02 14:43 [RELEASE] Lguest for 2.6.21 Rusty Russell
2007-05-02 19:33 ` WANG Cong
2007-05-02 19:59   ` WANG Cong
2007-05-02 23:00   ` Rusty Russell
2007-05-03  3:57     ` WANG Cong
2007-05-03  4:20       ` Rusty Russell
2007-05-03  5:43         ` WANG Cong
2007-05-03 16:02 ` Matt Mackall
2007-05-04  0:13   ` Rusty Russell
2007-05-04  0:43     ` Rusty Russell
2007-05-04  3:20       ` Matt Mackall
2007-05-04  3:39         ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).