Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Carsten Otte
I have been closely following thisvery interresting discussion. Here's 
my summary:
- PV capabilities is something we'll want
- being able to surface virtual devices to the guest as PCI is 
preferable to Windows
- we need an additional way to surface virtual devices to the guest. 
We don't have PCI on s390, and Ron doesn't want PCI in his guests.
- complex interfaces are a mess to implement and maintain in different 
hypervisors and guest operating systems, we need a simple and clear 
structure like plan9 has today

To me, it looks like we need a virtual device abstraction both in the 
guest kernel and in the kvm/qemu. This abstraction needs to be simple 
and fast, and needs to be representable as PCI device and in a simpler 
way. PCI obstacles are supposed to be transparent to the virutal device.
For me, plan9 does provide answers to a lot of above requirements. 
However, it does not provide capabilities for shared memory and it 
adds extra complexity. It's been designed to solve a different problem.

I think the virtual device abstraction should provide the following 
functionality:
- hypercall guest to host with parameters and return value
- interrupt from host to guest with parameters
- thin interrupt from host to guest, no parameters
- shared memory between guest and host
- dma access to guest memory, possibly via kmap on the host
- copy from/to guest memory

so long,
Carsten

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] qemu/kvm seems to take ALSA all for itself?

2007-05-23 Thread Andreas Hasenack
On Tuesday 22 May 2007 23:37:56 David Abrahams wrote:
> on Mon May 21 2007, Avi Kivity 
 wrote:
> > David Abrahams wrote:
> >> When I have windows XP running under kvm, I get
> >>
> >>   [EMAIL PROTECTED]:/tmp$ aplay /usr/share/sounds/gaim/receive.wav
> >>   ALSA lib pcm_dmix.c:864:(snd_pcm_dmix_open) unable to open slave
> >>   aplay: main:550: audio open error: Device or resource busy
> >>
> >> As soon as I shut down my VM, though, it works perfectly.  Is this
> >> expected behavior?
> >
> > I think you have to set up a mixer or something.  But I'd rather be deaf
> > than have to wade through all the pseudo-documentation in order to find
> > out how.
>
> Maybe I wasn't sufficiently clear.  Sound in the VM works fine; it
> just seems to kill sound in the host... or is the mixer somehow
> supposed to cure that?

Same issue here, even though my sound card supports hardware mixing (i.e., I 
don't use any sound daemons and can play more than one sound at the same 
time).

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] 1 Bug found for compiling on 32 Bit machine

2007-05-23 Thread Daniel Hecken
Avi Kivity schrieb:
> Daniel Hecken wrote:
>> Hello,
>>
>> I have found an issue for compiling on 32 Bit machines in
>> v2.6.22-rc1-g1ab29f3.
>>
>> I'm not sure if I have set the #ifdef CONFIG_X86_64 at the right place.
>> Please have a look at it. With this patch v2.6.22-rc1-g1ab29f3 compiles
>> und runs fine.
>>
>>   
>
> v2.6.22-rc1-170-ga6935db compiles fine here.  Can you double-check?
>


Hello Avi,

as we discovered on IRC EFER_SCE is only defined below 2.6.22 in
include/asm-i386/msr-index.h or include/asm-386/msr.h so I made a patch
for external-module-compat.h. I hope I defined it in the right way.

Daniel
--- kvm-trunk/kernel/external-module-compat.h	2007-05-23 13:28:47.0 +0200
+++ kvm-trunk_old/kernel/external-module-compat.h	2007-05-23 11:01:54.0 +0200
@@ -151,3 +151,17 @@
 #define CPU_DEAD_FROZEN(CPU_DEAD | CPU_TASKS_FROZEN)
 
 #endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+
+#ifndef _EFER_SCE
+#define _EFER_SCE		0  /* SYSCALL/SYSRET */
+#endif
+
+#ifndef EFER_SCE
+#define EFER_SCE		(1<<_EFER_SCE)
+#endif
+
+#endif
+
+
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Avi Kivity
Eric Van Hensbergen wrote:
> On 5/22/07, Christoph Hellwig <[EMAIL PROTECTED]> wrote:
>> >
>> > I didn't think we were talking about the general case, I thought we
>> > were discussing the PV case.
>> >
>>
>> In case of KVM no one is speaking of pure PV.
>>
>
> Why not?  It seems worthwhile to come up with something that can cover
> the whole spectrum instead of having different hypervisors (and
> interfaces).
>

That's the plan.  PV I/O and PV mmu are on the roadmap.  PV timers and
interrupts should be easily doable too.  The far end of the spectrum (PV
with no hardware virtualization extensions) is possible, but no one is
planning to do it AFAIK.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] 1 Bug found for compiling on 32 Bit machine

2007-05-23 Thread Avi Kivity
Daniel Hecken wrote:
> Avi Kivity schrieb:
>   
>> Daniel Hecken wrote:
>> 
>>> Hello,
>>>
>>> I have found an issue for compiling on 32 Bit machines in
>>> v2.6.22-rc1-g1ab29f3.
>>>
>>> I'm not sure if I have set the #ifdef CONFIG_X86_64 at the right place.
>>> Please have a look at it. With this patch v2.6.22-rc1-g1ab29f3 compiles
>>> und runs fine.
>>>
>>>   
>>>   
>> v2.6.22-rc1-170-ga6935db compiles fine here.  Can you double-check?
>>
>> 
>
>
> Hello Avi,
>
> as we discovered on IRC EFER_SCE is only defined below 2.6.22 in
> include/asm-i386/msr-index.h or include/asm-386/msr.h so I made a patch
> for external-module-compat.h. I hope I defined it in the right way.
>   

Looks good.  Applied & thanks.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Avi Kivity
Christoph Hellwig wrote:
> On Tue, May 22, 2007 at 10:00:42AM -0700, ron minnich wrote:
>   
>> On 5/22/07, Eric Van Hensbergen <[EMAIL PROTECTED]> wrote:
>>
>> 
>>> I'm not opposed to supporting emulation environments, just don't make
>>> a large pile of crap the default like Xen -- and having to integrate
>>> PCI probing code in my guest domains is a large pile of crap.
>>>   
>> Exactly. I'm about to start a pretty large project here, using xen or
>> kvm, not sure. One thing for sure, we are NOT going to use anything
>> but PV devices. Full emulation is nice, but it's just plain silly if
>> you don't have to do it. And we don't have to do it. So let's get the
>> PV devices right, not try to shoehorn them into some framework like
>> PCI.
>> 
>
> If you don't care about full virtualization kvm is the wrong project for
> you.  You might want to take a look at lguest.
>
>   

This is incorrect.  While kvm started out as a full virtualization
project, it will expand with I/O PV and core PV.  Eventually most of the
paravirt_ops interface will have a kvm implementation.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Christoph Hellwig
On Wed, May 23, 2007 at 03:16:50PM +0300, Avi Kivity wrote:
> Christoph Hellwig wrote:
> > On Tue, May 22, 2007 at 10:00:42AM -0700, ron minnich wrote:
> >   
> >> On 5/22/07, Eric Van Hensbergen <[EMAIL PROTECTED]> wrote:
> >>
> >> 
> >>> I'm not opposed to supporting emulation environments, just don't make
> >>> a large pile of crap the default like Xen -- and having to integrate
> >>> PCI probing code in my guest domains is a large pile of crap.
> >>>   
> >> Exactly. I'm about to start a pretty large project here, using xen or
> >> kvm, not sure. One thing for sure, we are NOT going to use anything
> >> but PV devices. Full emulation is nice, but it's just plain silly if
> >> you don't have to do it. And we don't have to do it. So let's get the
> >> PV devices right, not try to shoehorn them into some framework like
> >> PCI.
> >> 
> >
> > If you don't care about full virtualization kvm is the wrong project for
> > you.  You might want to take a look at lguest.
> >
> >   
> 
> This is incorrect.  While kvm started out as a full virtualization
> project, it will expand with I/O PV and core PV.  Eventually most of the
> paravirt_ops interface will have a kvm implementation.

The statement above was a little misworded I think.  It should have
been a "if you care about pure PV ..."


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Avi Kivity
ron minnich wrote:
> On 5/22/07, Eric Van Hensbergen <[EMAIL PROTECTED]> wrote:
>
>   
>> I'm not opposed to supporting emulation environments, just don't make
>> a large pile of crap the default like Xen -- and having to integrate
>> PCI probing code in my guest domains is a large pile of crap.
>> 
>
> Exactly. I'm about to start a pretty large project here, using xen or
> kvm, not sure. One thing for sure, we are NOT going to use anything
> but PV devices. Full emulation is nice, but it's just plain silly if
> you don't have to do it. And we don't have to do it. So let's get the
> PV devices right, not try to shoehorn them into some framework like
> PCI.
>
> What happens to these schemes if I want to try, e.g., 2^16 PV devices?
> Or some other crazy thing that doesn't play well with PCI -- simple
> example -- I want a 256 GB region of memory for a device. PCI rules
> require me to align it on 256GB boundaries and it must be contiguous
> address space. This is a hardware rule, done for hardware reasons, and
> has no place in the PV world. What if I want a bit more than the basic
> set of BARs that PCI gives me? Why would we apply such rules to a PV?
> Why limit ourselves this early in the game?
>
>   

Device discovery and device operation are separate.  Closed operating
systems and older Linuces will need pci as a way to have easy
plug'n'play discovery with no modifications to the kernel. 
Virtualization-friendly systems like newer Linux and s390 can have a
virtual bus for discovery.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Avi Kivity
Nakajima, Jun wrote:
> BTW, I'm presenting this at OLS:
> http://www.linuxsymposium.org/2007/view_abstract.php?content_key=192
>
> This uses direct paging mode today.
>   

Are there patches available anywhere?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Avi Kivity
Carsten Otte wrote:
> I have been closely following thisvery interresting discussion. Here's 
> my summary:
> - PV capabilities is something we'll want
> - being able to surface virtual devices to the guest as PCI is 
> preferable to Windows
> - we need an additional way to surface virtual devices to the guest. 
> We don't have PCI on s390, and Ron doesn't want PCI in his guests.
> - complex interfaces are a mess to implement and maintain in different 
> hypervisors and guest operating systems, we need a simple and clear 
> structure like plan9 has today
>
> To me, it looks like we need a virtual device abstraction both in the 
> guest kernel and in the kvm/qemu. This abstraction needs to be simple 
> and fast, and needs to be representable as PCI device and in a simpler 
> way. PCI obstacles are supposed to be transparent to the virutal device.
> For me, plan9 does provide answers to a lot of above requirements. 
> However, it does not provide capabilities for shared memory and it 
> adds extra complexity. It's been designed to solve a different problem.
>
> I think the virtual device abstraction should provide the following 
> functionality:
> - hypercall guest to host with parameters and return value
> - interrupt from host to guest with parameters
> - thin interrupt from host to guest, no parameters
> - shared memory between guest and host
> - dma access to guest memory, possibly via kmap on the host
> - copy from/to guest memory
>
>   

I agree with all of the above.  In addition, it would be nice if we can
share this interface with other hypervisors.  Unfortunately Xen is
riding the XenBus, but maybe we can share the interface with lguest and VMI.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] qemu/kvm seems to take ALSA all for itself?

2007-05-23 Thread Avi Kivity
David Abrahams wrote:
> on Mon May 21 2007, Avi Kivity 
>  wrote:
>
>   
>> David Abrahams wrote:
>> 
>>> When I have windows XP running under kvm, I get 
>>>
>>>   [EMAIL PROTECTED]:/tmp$ aplay /usr/share/sounds/gaim/receive.wav 
>>>   ALSA lib pcm_dmix.c:864:(snd_pcm_dmix_open) unable to open slave
>>>   aplay: main:550: audio open error: Device or resource busy
>>>
>>> As soon as I shut down my VM, though, it works perfectly.  Is this
>>> expected behavior?
>>>   
>>>   
>> I think you have to set up a mixer or something.  But I'd rather be deaf 
>> than have to wade through all the pseudo-documentation in order to find 
>> out how.
>> 
>
> Maybe I wasn't sufficiently clear.  Sound in the VM works fine; it
> just seems to kill sound in the host... or is the mixer somehow
> supposed to cure that?
>
>   

I have a similar problem where running a Java virtual machine kills
sound to other apps.  I assume that a mixer will fix this, but have been
unable to get it to work.

Looks like this is a similar problem.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] qemu/kvm seems to take ALSA all for itself?

2007-05-23 Thread Avi Kivity
Jon wrote:
> On Mon, May 21, 2007 at 08:37:48AM -0700, Shahar Frank wrote:
>
>   
>> You have to make QEMU use ALSA as your sound system and specify a 
>> mixer device for input and output. This can be done using some 
>> environment variables that should be set before the qemu binary is 
>> run.
>> 
>
> >From the ALSA wiki:
>
> "For ALSA 1.0.9rc2 and higher you don't need to setup dmix. Dmix is 
> enabled as default for soundcards which don't support hw mixing."
>
> I've found this to be the case on my laptop, where I use:
>
> export QEMU_AUDIO_DRV=alsa
> export QEMU_AUDIO_DAC_FIXED_FREQ=48000
> export QEMU_AUDIO_ADC_FIXED_FREQ=48000
> export QEMU_ALSA_DAC_BUFFER_SIZE=16384
>
> Buffer size is very important, else it crackles and pops for me.
>
>   

This works for me (alsa 1.0.14rc3).  Thanks.

> Now if only sound could survive a loadvm/savevm it'd be perfect. :-)
>   

Is qemu-devel aware of this issue?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm slides at NLUUG?

2007-05-23 Thread Avi Kivity
Jun Koi wrote:
> Hi Avi,
>
> Could you make your slides/paper at NLUGG available?
> (http://www.nluug.nl/events/vj07/)
>   

The paper should be available as part of the Proceedings.  I looked and
couldn't find it on the site, maybe you can drop them an email and ask
if it is available online.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm slides at NLUUG?

2007-05-23 Thread Jun Koi
On 5/23/07, Avi Kivity <[EMAIL PROTECTED]> wrote:
> Jun Koi wrote:
> > Hi Avi,
> >
> > Could you make your slides/paper at NLUGG available?
> > (http://www.nluug.nl/events/vj07/)
> >
>
> The paper should be available as part of the Proceedings.  I looked and
> couldn't find it on the site, maybe you can drop them an email and ask
> if it is available online.

OK, I will. But I guess it doesnt harm if we put it (and others) at
kvm homepage. The technical documentation on kvm is still quite scarce
now.

Thanks,
Jun

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm slides at NLUUG?

2007-05-23 Thread Lucas Bonnet
Avi Kivity a écrit :
> The paper should be available as part of the Proceedings.  I looked and
> couldn't find it on the site, maybe you can drop them an email and ask
> if it is available online.

If you do so, please tell me if you obtained the paper or the slides, I'm
interested too.

Regards,
-- 
Lucas Bonnet

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-22 and Vista support

2007-05-23 Thread Avi Kivity
Jorge Lucángeli Obes wrote:
> I had some time on my hands lately and tried to debug this a little. I
> found that there's actually something showing in dmesg:
>
> [ 3872.221039] emulation failed but !mmio_needed? rip 9a12 0f 09 66 25
>
> Does that help? I'm running kvm-24 now, but the exception still
> happens. I've been looking through x86_emulate.c and kvmctl.c trying
> to print more information but with no success yet.
>   

Does the attached patch help?  It implements 0f 09, wbinvd.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.

diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index 7ade090..6123c02 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -152,7 +152,7 @@ static u8 opcode_table[256] = {
 static u16 twobyte_table[256] = {
 	/* 0x00 - 0x0F */
 	0, SrcMem | ModRM | DstReg, 0, 0, 0, 0, ImplicitOps, 0,
-	0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0,
+	0, ImplicitOps, 0, 0, 0, ImplicitOps | ModRM, 0, 0,
 	/* 0x10 - 0x1F */
 	0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0,
 	/* 0x20 - 0x2F */
@@ -1304,6 +1304,8 @@ twobyte_special_insn:
 	/* Disable writeback. */
 	dst.orig_val = dst.val;
 	switch (b) {
+	case 0x09:		/* wbinvd */
+		break;
 	case 0x0d:		/* GrpP (prefetch) */
 	case 0x18:		/* Grp16 (prefetch/nop) */
 		break;
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm slides at NLUUG?

2007-05-23 Thread Jun Koi
On 5/23/07, Lucas Bonnet <[EMAIL PROTECTED]> wrote:
> Avi Kivity a écrit :
> > The paper should be available as part of the Proceedings.  I looked and
> > couldn't find it on the site, maybe you can drop them an email and ask
> > if it is available online.
>
> If you do so, please tell me if you obtained the paper or the slides, I'm
> interested too.
>

Certainly. I emailed them, and I will forward it here if they send me.
But it would be much easier/quicker for us all if Avi can put it
online :-)

Thanks,
Jun.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm slides at NLUUG?

2007-05-23 Thread Avi Kivity
Jun Koi wrote:
> On 5/23/07, Lucas Bonnet <[EMAIL PROTECTED]> wrote:
>   
>> Avi Kivity a écrit :
>> 
>>> The paper should be available as part of the Proceedings.  I looked and
>>> couldn't find it on the site, maybe you can drop them an email and ask
>>> if it is available online.
>>>   
>> If you do so, please tell me if you obtained the paper or the slides, I'm
>> interested too.
>>
>> 
>
> Certainly. I emailed them, and I will forward it here if they send me.
> But it would be much easier/quicker for us all if Avi can put it
> online :-

They have requested to be the first to publish.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm slides at NLUUG?

2007-05-23 Thread Lucas Bonnet
Avi Kivity a écrit :

> They have requested to be the first to publish.

Ah I see, I hope they publish your paper soon enough then.

Thanks,
-- 
Lucas Bonnet

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] qemu/kvm seems to take ALSA all for itself?

2007-05-23 Thread David Abrahams

on Wed May 23 2007, Avi Kivity  wrote:

> Jon wrote:
>> On Mon, May 21, 2007 at 08:37:48AM -0700, Shahar Frank wrote:
>>
>>   
>>> You have to make QEMU use ALSA as your sound system and specify a 
>>> mixer device for input and output. This can be done using some 
>>> environment variables that should be set before the qemu binary is 
>>> run.
>>> 
>>
>> >From the ALSA wiki:
>>
>> "For ALSA 1.0.9rc2 and higher you don't need to setup dmix. Dmix is 
>> enabled as default for soundcards which don't support hw mixing."
>>
>> I've found this to be the case on my laptop, where I use:
>>
>> export QEMU_AUDIO_DRV=alsa
>> export QEMU_AUDIO_DAC_FIXED_FREQ=48000
>> export QEMU_AUDIO_ADC_FIXED_FREQ=48000
>> export QEMU_ALSA_DAC_BUFFER_SIZE=16384
>>
>> Buffer size is very important, else it crackles and pops for me.
>>
>>   
>
> This works for me (alsa 1.0.14rc3).  Thanks.

OK, but *where* do you use this incantation?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 00/10] in-kernel APIC v7 (kernel side)

2007-05-23 Thread Gregory Haskins
I am pleased to announce v7 of the patch series.  This includes v6 with the
following changes:

1) Minor bug fixes/cleanup
2) Added better support for level-sensitive interrupts
3) Now officially includes in-kernel HLT support
4) Enhanced the HLT support from the last drop to include the following
a) Only enables itself if in-kernel APIC is also enabled (see userspace
   announcement for details)
b) Added support for unmasking all signals while HLT'ed
c) Added support for breaking out of HLT if userspace requests an
   interrupt window

As before, I have tested 32 bit XP w/ACPI and 64 bit linux (2.6.16 based) on
VMX. Both seem to run just fine.  I have confirmed that we are forward and
backward compatible between all permuations of old and new userspace/kernel.
I have also confirmed that "level-0" mode offers identical performance to
kvm-trunk, and "level-1" mode offers a 13% speed improvement for a kernel
build test.

For the performance test, I had the following setup:

Dual-core/Dual-socket Xeon 5130 (2Ghz)
64 bit host (2.6.21.1 + external KVM HEAD modules + APIC patches)
64 bit guest (2.6.16.21 based)

I then built a 2.6.21.1 kernel in the guest using:

"make mrproper; make defconfig; time make"

The result for trunk and level-0 came out consistently around 9m30s.  The
level-1 mode came out around 8m15s.

Regards,
-Greg


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 01/10] KVM: Adds support for in-kernel mmio handlers

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/kvm.h  |   60 +++
 drivers/kvm/kvm_main.c |   94 ++--
 2 files changed, 142 insertions(+), 12 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 5f056d9..a292556 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -256,6 +256,65 @@ struct kvm_stat {
u32 light_exits;
 };
 
+struct kvm_io_device {
+   void (*read)(struct kvm_io_device *this,
+gpa_t addr,
+int len,
+void *val);
+   void (*write)(struct kvm_io_device *this,
+ gpa_t addr,
+ int len,
+ const void *val);
+   int (*in_range)(struct kvm_io_device *this, gpa_t addr);
+   void (*destructor)(struct kvm_io_device *this);
+
+   void *private;
+};
+
+static inline void kvm_iodevice_read(struct kvm_io_device *dev,
+gpa_t addr,
+int len,
+void *val)
+{
+   dev->read(dev, addr, len, val);
+}
+
+static inline void kvm_iodevice_write(struct kvm_io_device *dev,
+ gpa_t addr,
+ int len,
+ const void *val)
+{
+   dev->write(dev, addr, len, val);
+}
+
+static inline int kvm_iodevice_inrange(struct kvm_io_device *dev, gpa_t addr)
+{
+   return dev->in_range(dev, addr);
+}
+
+static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
+{
+   dev->destructor(dev);
+}
+
+/*
+ * It would be nice to use something smarter than a linear search, TBD...
+ * Thankfully we dont expect many devices to register (famous last words :),
+ * so until then it will suffice.  At least its abstracted so we can change
+ * in one place.
+ */
+struct kvm_io_bus {
+   int   dev_count;
+#define NR_IOBUS_DEVS 6
+   struct kvm_io_device *devs[NR_IOBUS_DEVS];
+};
+
+void kvm_io_bus_init(struct kvm_io_bus *bus);
+void kvm_io_bus_destroy(struct kvm_io_bus *bus);
+struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus, gpa_t addr);
+void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
+struct kvm_io_device *dev);
+
 struct kvm_vcpu {
struct kvm *kvm;
union {
@@ -379,6 +438,7 @@ struct kvm {
unsigned long rmap_overflow;
struct list_head vm_list;
struct file *filp;
+   struct kvm_io_bus mmio_bus;
 };
 
 struct descriptor_table {
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 1288cff..6ff30a2 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -317,6 +317,7 @@ static struct kvm *kvm_create_vm(void)
 
spin_lock_init(&kvm->lock);
INIT_LIST_HEAD(&kvm->active_mmu_pages);
+   kvm_io_bus_init(&kvm->mmio_bus);
for (i = 0; i < KVM_MAX_VCPUS; ++i) {
struct kvm_vcpu *vcpu = &kvm->vcpus[i];
 
@@ -414,6 +415,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
spin_lock(&kvm_lock);
list_del(&kvm->vm_list);
spin_unlock(&kvm_lock);
+   kvm_io_bus_destroy(&kvm->mmio_bus);
kvm_free_vcpus(kvm);
kvm_free_physmem(kvm);
kfree(kvm);
@@ -1037,12 +1039,25 @@ static int emulator_write_std(unsigned long addr,
return X86EMUL_UNHANDLEABLE;
 }
 
+static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu,
+   gpa_t addr)
+{
+   /*
+* Note that its important to have this wrapper function because
+* in the very near future we will be checking for MMIOs against
+* the LAPIC as well as the general MMIO bus
+*/
+   return kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr);
+}
+
 static int emulator_read_emulated(unsigned long addr,
  void *val,
  unsigned int bytes,
  struct x86_emulate_ctxt *ctxt)
 {
-   struct kvm_vcpu *vcpu = ctxt->vcpu;
+   struct kvm_vcpu  *vcpu = ctxt->vcpu;
+   struct kvm_io_device *mmio_dev;
+   gpa_t gpa;
 
if (vcpu->mmio_read_completed) {
memcpy(val, vcpu->mmio_data, bytes);
@@ -1051,18 +1066,26 @@ static int emulator_read_emulated(unsigned long addr,
} else if (emulator_read_std(addr, val, bytes, ctxt)
   == X86EMUL_CONTINUE)
return X86EMUL_CONTINUE;
-   else {
-   gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr);
 
-   if (gpa == UNMAPPED_GVA)
-   return X86EMUL_PROPAGATE_FAULT;
-   vcpu->mmio_needed = 1;
-   vcpu->mmio_phys_addr = gpa;
-   vcpu->mmio_size = bytes;
-   vcpu->mmio_is_write = 0;
+   gpa = vcpu->mmu.gva_to_gpa(vc

[kvm-devel] [PATCH 02/10] KVM: VMX - fix interrupt checking on light-exit

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/vmx.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 5386461..8ef6193 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1954,13 +1954,13 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct 
kvm_run *kvm_run)
int r;
 
 preempted:
-   if (!vcpu->mmio_read_completed)
-   do_interrupt_requests(vcpu, kvm_run);
-
if (vcpu->guest_debug.enabled)
kvm_guest_debug_pre(vcpu);
 
 again:
+   if (!vcpu->mmio_read_completed)
+   do_interrupt_requests(vcpu, kvm_run);
+
vmx_save_host_state(vcpu);
kvm_load_guest_fpu(vcpu);
 


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 03/10] KVM: Add irqdevice object

2007-05-23 Thread Gregory Haskins
The current code is geared towards using a user-mode (A)PIC.  This patch adds
an "irqdevice" abstraction, and implements a "userint" model to handle the
duties of the original code.  Later, we can develop other irqdevice models
to handle objects like LAPIC, IOAPIC, i8259, etc, as appropriate

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/Makefile|2 
 drivers/kvm/irqdevice.h |  176 +
 drivers/kvm/kvm.h   |   94 +++-
 drivers/kvm/kvm_main.c  |   58 +---
 drivers/kvm/svm.c   |  162 --
 drivers/kvm/userint.c   |  223 +++
 drivers/kvm/vmx.c   |  161 +-
 7 files changed, 769 insertions(+), 107 deletions(-)

diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index c0a789f..540afbc 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module
 #
 
-kvm-objs := kvm_main.o mmu.o x86_emulate.o
+kvm-objs := kvm_main.o mmu.o x86_emulate.o userint.o
 obj-$(CONFIG_KVM) += kvm.o
 kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
diff --git a/drivers/kvm/irqdevice.h b/drivers/kvm/irqdevice.h
new file mode 100644
index 000..097d179
--- /dev/null
+++ b/drivers/kvm/irqdevice.h
@@ -0,0 +1,176 @@
+/*
+ * Defines an interface for an abstract interrupt controller.  The model
+ * consists of a unit with an arbitrary number of input lines N (IRQ0-(N-1)),
+ * an arbitrary number of output lines (INTR) (LINT, EXTINT, NMI, etc), and
+ * methods for completing an interrupt-acknowledge cycle (INTA).  A particular
+ * implementation of this model will define various policies, such as
+ * irq-to-vector translation, INTA/auto-EOI policy, etc.
+ *
+ * In addition, the INTR callback mechanism allows the unit to be "wired" to
+ * an interruptible source in a very flexible manner. For instance, an
+ * irqdevice could have its INTR wired to a VCPU (ala LAPIC), or another
+ * interrupt controller (ala cascaded i8259s)
+ *
+ * Copyright (C) 2007 Novell
+ *
+ * Authors:
+ *   Gregory Haskins <[EMAIL PROTECTED]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef __IRQDEVICE_H
+#define __IRQDEVICE_H
+
+struct kvm_irqdevice;
+
+typedef enum {
+   kvm_irqpin_localint,
+   kvm_irqpin_extint,
+   kvm_irqpin_smi,
+   kvm_irqpin_nmi,
+   kvm_irqpin_invalid, /* must always be last */
+} kvm_irqpin_t;
+
+
+struct kvm_irqsink {
+   void (*set_intr)(struct kvm_irqsink *this,
+struct kvm_irqdevice *dev,
+kvm_irqpin_t pin);
+
+   void *private;
+};
+
+#define KVM_IRQACKDATA_VECTOR_VALID   (1 << 0)
+#define KVM_IRQACKDATA_VECTOR_PENDING (1 << 1)
+
+#define KVM_IRQACK_FLAG_PEEK  (1 << 0)
+
+struct kvm_irqack_data {
+   int flags;
+   int vector;
+};
+
+struct kvm_irqdevice {
+   int  (*ack)(struct kvm_irqdevice *this, int flags,
+   struct kvm_irqack_data *data);
+   int  (*set_pin)(struct kvm_irqdevice *this, int pin, int level);
+   void (*destructor)(struct kvm_irqdevice *this);
+
+   void   *private;
+   struct kvm_irqsink  sink;
+};
+
+/**
+ * kvm_irqdevice_init - initialize the kvm_irqdevice for use
+ * @dev: The device
+ *
+ * Description: Initialize the kvm_irqdevice for use.  Should be called before
+ *  calling any derived implementation init functions
+ *
+ * Returns: (void)
+ */
+static inline void kvm_irqdevice_init(struct kvm_irqdevice *dev)
+{
+   memset(dev, 0, sizeof(*dev));
+}
+
+/**
+ * kvm_irqdevice_ack - read and ack the highest priority vector from the device
+ * @dev: The device
+ * @flags: Modifies default behavior
+ *   [ KVM_IRQACK_FLAG_PEEK - Dont ack vector, just check status ]
+ * @data: A pointer to a kvm_irqack_data structure to hold the result
+ *
+ * Description: Read the highest priority pending vector from the device,
+ *  potentially invoking auto-EOI depending on device policy
+ *
+ *  Successful return indicates that the *data* structure is valid
+ *
+ *   data.flags -
+ *  [KVM_IRQACKDATA_VECTOR_VALID - data.vector is valid]
+ *  [KVM_IRQACKDATA_VECTOR_PENDING - more vectors are pending]
+ *
+ * Returns: (int)
+ *   [-1 = failure]
+ *   [ 0 = success]
+ */
+static inline int kvm_irqdevice_ack(struct kvm_irqdevice *dev, int flags,
+   struct kvm_irqack_data *data)
+{
+   return dev->ack(dev, flags, data);
+}
+
+/**
+ * kvm_irqdevice_set_pin - allows the caller to assert/deassert an IRQ
+ * @dev: The device
+ * @pin: The input pin to alter
+ * @level: The value to set (1 = assert, 0 = deassert)
+ *
+ * Description: Allows the caller to assert/deassert an IRQ input pin to the

[kvm-devel] [PATCH 04/10] KVM: Adds ability to preempt an executing VCPU

2007-05-23 Thread Gregory Haskins
The VCPU executes synchronously w.r.t. userspace today, and therefore
interrupt injection is pretty straight forward.  However, we will soon need
to be able to inject interrupts asynchronous to the execution of the VCPU
due to the introduction of SMP, paravirtualized drivers, and asynchronous
hypercalls.  This patch adds support to the interrupt mechanism to force
a VCPU to VMEXIT when a new interrupt is pending.

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/kvm.h  |1 +
 drivers/kvm/kvm_main.c |   59 +---
 drivers/kvm/svm.c  |   52 --
 drivers/kvm/vmx.c  |   38 +++
 4 files changed, 143 insertions(+), 7 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 9eb8846..b9d 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -331,6 +331,7 @@ struct kvm_vcpu_irq {
struct kvm_irqdevice dev;
int  pending;
int  deferred;
+   int  guest_cpu;
 };
 
 struct kvm_vcpu {
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index a2e1e50..3517563 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2332,6 +2332,20 @@ out1:
 }
 
 /*
+ * This function is invoked whenever we want to interrupt a vcpu that is
+ * currently executing in guest-mode.  It currently is a no-op because
+ * the simple delivery of the IPI to execute this function accomplishes our
+ * goal: To cause a VMEXIT.  We pass the vcpu (which contains the
+ * vcpu->irq.task, etc) for future use
+ */
+static void kvm_vcpu_guest_intr(void *info)
+{
+#ifdef NOT_YET
+   struct kvm_vcpu *vcpu = (struct kvm_vcpu*)info;
+#endif
+}
+
+/*
  * This function will be invoked whenever the vcpu->irq.dev raises its INTR
  * line
  */
@@ -2340,11 +2354,48 @@ static void kvm_vcpu_intr(struct kvm_irqsink *this,
  kvm_irqpin_t pin)
 {
struct kvm_vcpu *vcpu = (struct kvm_vcpu*)this->private;
-   unsigned long flags;
+   int direct_ipi = -1;
 
-   spin_lock_irqsave(&vcpu->irq.lock, flags);
-   __set_bit(pin, &vcpu->irq.pending);
-   spin_unlock_irqrestore(&vcpu->irq.lock, flags);
+   spin_lock_irq(&vcpu->irq.lock);
+
+   if (!test_bit(pin, &vcpu->irq.pending)) {
+   /*
+* Record the change..
+*/
+   __set_bit(pin, &vcpu->irq.pending);
+
+   /*
+* then wake up the vcpu (if necessary)
+*/
+   if (vcpu->irq.guest_cpu != -1) {
+   /*
+* If we are in guest mode, we must send a host-IPI
+* to the CPU which is running the guest to cause
+* a VMEXIT.
+*/
+   direct_ipi = vcpu->irq.guest_cpu;
+   BUG_ON(direct_ipi == smp_processor_id());
+   }
+   }
+
+   spin_unlock_irq(&vcpu->irq.lock);
+
+   /*
+* we can safely send the IPI outside of the lock-scope because the
+* irq.pending has already been updated.  This code assumes that
+* userspace will not sleep on anything other than HLT instructions.
+* HLT is covered in a race-free way because irq.pending was updated
+* in the critical section, and handle_halt() which check if any
+* interrupts are pending before returning to userspace.
+*
+* If it turns out that userspace can sleep on conditions other than
+* HLT, this code will need to be enhanced to allow the irq.pending
+* flags to be exported to userspace
+*/
+   if (direct_ipi != -1)
+   smp_call_function_single(direct_ipi,
+kvm_vcpu_guest_intr,
+vcpu, 0, 0);
 }
 
 static void kvm_vcpu_irqsink_init(struct kvm_vcpu *vcpu)
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index a9d917a..c79bfc0 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1544,9 +1544,43 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct 
kvm_run *kvm_run)
int r;
 
 again:
+   /*
+* We disable interrupts until the next VMEXIT to eliminate a race
+* condition for delivery of virtual interrutps.  Note that this is
+* probably not as bad as it sounds, as interrupts will still invoke
+* a VMEXIT once transitioned to GUEST mode (and thus exit this lock
+* scope) even if they are disabled.
+*/
+   local_irq_disable();
+
spin_lock(&vcpu->irq.lock);
 
/*
+* If there are any signals pending (virtual interrupt related or
+* otherwise), don't even bother trying to enter guest mode...
+*/
+   if (signal_pending(current)) {
+   kvm_run->exit_reason = KVM_EXIT_INTR;
+   spin_unlock(&v

[kvm-devel] [PATCH 05/10] KVM: Add support for in-kernel LAPIC model

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/Makefile   |2 
 drivers/kvm/kernint.c  |  149 +
 drivers/kvm/kvm.h  |   35 +
 drivers/kvm/kvm_main.c |  198 ++-
 drivers/kvm/lapic.c| 1418 
 drivers/kvm/svm.c  |   13 
 drivers/kvm/userint.c  |8 
 drivers/kvm/vmx.c  |   16 -
 include/linux/kvm.h|   15 +
 9 files changed, 1809 insertions(+), 45 deletions(-)

diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index 540afbc..1aad737 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module
 #
 
-kvm-objs := kvm_main.o mmu.o x86_emulate.o userint.o
+kvm-objs := kvm_main.o mmu.o x86_emulate.o userint.o lapic.o kernint.o
 obj-$(CONFIG_KVM) += kvm.o
 kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
diff --git a/drivers/kvm/kernint.c b/drivers/kvm/kernint.c
new file mode 100644
index 000..b5cbcae
--- /dev/null
+++ b/drivers/kvm/kernint.c
@@ -0,0 +1,149 @@
+/*
+ * Kernel Interrupt IRQ device
+ *
+ * Provides a model for connecting in-kernel interrupt resources to a VCPU.
+ *
+ * A typical modern x86 processor has the concept of an internal Local-APIC
+ * and some external signal pins.  The way in which interrupts are injected is
+ * dependent on whether software enables the LAPIC or not.  When enabled,
+ * interrupts are acknowledged through the LAPIC.  Otherwise they are through
+ * an externally connected PIC (typically an i8259 on the BSP)
+ *
+ * Copyright (C) 2007 Novell
+ *
+ * Authors:
+ *   Gregory Haskins <[EMAIL PROTECTED]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include "kvm.h"
+
+struct kvm_kernint {
+   struct kvm_vcpu  *vcpu;
+   struct kvm_irqdevice *self_irq;
+   struct kvm_irqdevice *ext_irq;
+   struct kvm_irqdevice  apic_irq;
+
+};
+
+static struct kvm_irqdevice *get_irq_dev(struct kvm_kernint *s)
+{
+   struct kvm_irqdevice *dev;
+
+   if (kvm_lapic_enabled(s->vcpu))
+   dev = &s->apic_irq;
+   else
+   dev = s->ext_irq;
+
+   if (!dev)
+   kvm_crash_guest(s->vcpu->kvm);
+
+   return dev;
+}
+
+static int kernint_irqdev_ack(struct kvm_irqdevice *this, int flags,
+ struct kvm_irqack_data *data)
+{
+   struct kvm_kernint *s = (struct kvm_kernint*)this->private;
+
+   return kvm_irqdevice_ack(get_irq_dev(s), flags, data);
+}
+
+static int kernint_irqdev_set_pin(struct kvm_irqdevice *this,
+ int irq, int level)
+{
+   /* no-op */
+   return 0;
+}
+
+static void kernint_irqdev_destructor(struct kvm_irqdevice *this)
+{
+   struct kvm_kernint *s = (struct kvm_kernint*)this->private;
+
+   kvm_irqdevice_destructor(&s->apic_irq);
+   kvm_lapic_destroy(s->vcpu);
+   kfree(s);
+}
+
+static void kvm_apic_intr(struct kvm_irqsink *this,
+ struct kvm_irqdevice *dev,
+ kvm_irqpin_t pin)
+{
+   struct kvm_kernint *s = (struct kvm_kernint*)this->private;
+
+   /*
+* If the LAPIC sent us an interrupt it *must* be enabled,
+* just forward it on to the CPU
+*/
+   kvm_irqdevice_set_intr(s->self_irq, pin);
+}
+
+static void kvm_ext_intr(struct kvm_irqsink *this,
+struct kvm_irqdevice *dev,
+kvm_irqpin_t pin)
+{
+   struct kvm_kernint *s = (struct kvm_kernint*)this->private;
+
+   /*
+* If the EXTINT device sent us an interrupt, forward it to the LINT0
+* pin of the LAPIC
+*/
+   if (pin != kvm_irqpin_localint)
+   return;
+
+   /*
+* "irq 0" = LINT0, 1 = LINT1
+*/
+   kvm_irqdevice_set_pin(&s->apic_irq, 0, 1);
+}
+
+int kvm_kernint_init(struct kvm_vcpu *vcpu)
+{
+   struct kvm_irqdevice *irqdev = &vcpu->irq.dev;
+   struct kvm_kernint *s;
+   struct kvm_irqsink apicsink;
+
+   s = kzalloc(sizeof(*s), GFP_KERNEL);
+   if (!s)
+   return -ENOMEM;
+
+   s->vcpu = vcpu;
+
+   /*
+* Configure the irqdevice interface
+*/
+   irqdev->ack = kernint_irqdev_ack;
+   irqdev->set_pin = kernint_irqdev_set_pin;
+   irqdev->destructor  = kernint_irqdev_destructor;
+
+   irqdev->private = s;
+   s->self_irq = irqdev;
+
+   /*
+* Configure the EXTINT device if this is the BSP processor
+*/
+   if (!vcpu_slot(vcpu)) {
+   struct kvm_irqsink extsink = {
+   .set_intr   = kvm_ext_intr,
+   .private= s
+   };
+   s->ext_irq = &vcpu->kvm->isa_irq;
+   kvm_irqdevice_register_sink(s->ext_irq, &extsink);
+   }
+
+   /*
+* Configure the LA

[kvm-devel] [PATCH 06/10] KVM: Adds support for real NMI injection on VMX processors

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/vmx.c |   57 -
 drivers/kvm/vmx.h |3 +++
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 3ef5da8..f532c87 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1281,7 +1281,14 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
   PIN_BASED_VM_EXEC_CONTROL,
   PIN_BASED_EXT_INTR_MASK   /* 20.6.1 */
   | PIN_BASED_NMI_EXITING   /* 20.6.1 */
+  | PIN_BASED_VIRTUAL_NMI   /* 20.6.1 */
);
+
+   if (!(vmcs_read32(PIN_BASED_VM_EXEC_CONTROL) & PIN_BASED_VIRTUAL_NMI))
+   printk(KERN_DEBUG "KVM: Warning - Host processor does " \
+  "not support virtual-NMI injection.  Using IRQ " \
+  "method\n");
+ 
vmcs_write32_fixedbits(MSR_IA32_VMX_PROCBASED_CTLS,
   CPU_BASED_VM_EXEC_CONTROL,
   CPU_BASED_HLT_EXITING /* 20.6.2 */
@@ -1427,6 +1434,37 @@ static void inject_rmode_irq(struct kvm_vcpu *vcpu, int 
irq)
vmcs_writel(GUEST_RSP, (vmcs_readl(GUEST_RSP) & ~0x) | (sp - 6));
 }
 
+static void do_nmi_requests(struct kvm_vcpu *vcpu)
+{
+   int nmi_window = 0;
+
+   BUG_ON(!(test_bit(kvm_irqpin_nmi, &vcpu->irq.pending)));
+
+   nmi_window =
+   (((vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 0xb) == 0)
+&& (vmcs_read32(VM_ENTRY_INTR_INFO_FIELD)
+& INTR_INFO_VALID_MASK));
+
+   if (nmi_window) {
+   if (vcpu->rmode.active)
+   inject_rmode_irq(vcpu, 2);
+   else
+   vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
+2 |
+INTR_TYPE_NMI |
+INTR_INFO_VALID_MASK);
+
+   __clear_bit(kvm_irqpin_nmi, &vcpu->irq.pending);
+   } else {
+   /*
+* NMIs blocked.  Wait for unblock.
+*/
+   u32 cbvec = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
+   cbvec |= CPU_BASED_NMI_EXITING;
+   vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cbvec); 
+   }
+}
+
 static void do_intr_requests(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run,
kvm_irqpin_t pin)
@@ -1459,9 +1497,11 @@ static void do_intr_requests(struct kvm_vcpu *vcpu,
break;
case kvm_irqpin_nmi:
/*
-* FIXME: Someday we will handle this using the
-* specific VMX NMI features.  For now, just inject
-* the NMI as a standard interrupt on vector 2
+* We should only get here if the processor does
+* not support virtual NMIs.  Inject the NMI as a
+* standard interrupt on vector 2.  The implication is
+* that NMIs are going to be subject to RFLAGS.IF
+* masking, unfortunately.
 */
ack.flags |= KVM_IRQACKDATA_VECTOR_VALID;
ack.vector = 2;
@@ -1504,7 +1544,8 @@ static void do_intr_requests(struct kvm_vcpu *vcpu,
 static void clear_pending_controls(struct kvm_vcpu *vcpu)
 {
u32 cbvec = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
-   cbvec &= ~CPU_BASED_VIRTUAL_INTR_PENDING;
+   cbvec &= ~(CPU_BASED_VIRTUAL_INTR_PENDING
+  | CPU_BASED_NMI_EXITING);
vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cbvec);
 }
 
@@ -1521,7 +1562,6 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
switch (pin) {
case kvm_irqpin_localint:
case kvm_irqpin_extint:
-   case kvm_irqpin_nmi:
do_intr_requests(vcpu, kvm_run, pin);
break;
case kvm_irqpin_smi:
@@ -1529,6 +1569,13 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
printk(KERN_WARNING "KVM: dropping unhandled SMI\n");
__clear_bit(pin, &vcpu->irq.pending);
break;
+   case kvm_irqpin_nmi:
+   if (vmcs_read32(PIN_BASED_VM_EXEC_CONTROL)
+   & PIN_BASED_VIRTUAL_NMI)
+   do_nmi_requests(vcpu);
+   else
+   do_intr_requests(vcpu, kvm_run, pin);   
+   break;
case kvm_irqpin_invalid:
/* drop */
break;
diff --git a/drivers/kvm/vmx.h b/drivers/kvm/vmx.h
index d0dc93d..d3fe017 100644
--- a/

[kvm-devel] [PATCH 07/10] KVM: Adds basic plumbing to support TPR shadow features

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/irqdevice.h |3 +++
 drivers/kvm/kvm.h   |1 +
 drivers/kvm/lapic.c |   17 +
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/kvm/irqdevice.h b/drivers/kvm/irqdevice.h
index 097d179..173313d 100644
--- a/drivers/kvm/irqdevice.h
+++ b/drivers/kvm/irqdevice.h
@@ -45,12 +45,14 @@ struct kvm_irqsink {
 
 #define KVM_IRQACKDATA_VECTOR_VALID   (1 << 0)
 #define KVM_IRQACKDATA_VECTOR_PENDING (1 << 1)
+#define KVM_IRQACKDATA_NEXT_VALID (1 << 2)
 
 #define KVM_IRQACK_FLAG_PEEK  (1 << 0)
 
 struct kvm_irqack_data {
int flags;
int vector;
+   int next;
 };
 
 struct kvm_irqdevice {
@@ -92,6 +94,7 @@ static inline void kvm_irqdevice_init(struct kvm_irqdevice 
*dev)
  *   data.flags -
  *  [KVM_IRQACKDATA_VECTOR_VALID - data.vector is valid]
  *  [KVM_IRQACKDATA_VECTOR_PENDING - more vectors are pending]
+ *  [KVM_IRQACKDATA_NEXT_VALID - next-vector is valid]
  *
  * Returns: (int)
  *   [-1 = failure]
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index ef3268e..a9ee8bd 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -180,6 +180,7 @@ void kvm_lapic_save(struct kvm_vcpu *vcpu, struct kvm_sregs 
*sregs);
 void kvm_lapic_restore(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
 void kvm_lapic_reset(struct kvm_vcpu *vcpu);
 int  kvm_lapic_enabled(struct kvm_vcpu *vcpu);
+void *kvm_lapic_get_regs(struct kvm_vcpu *vcpu);
 
 /*
  * x86 supports 3 paging modes (4-level 64-bit, 3-level 64-bit, and 2-level
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 9f0ab7e..602e94c 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -1154,6 +1154,13 @@ int kvm_lapic_enabled(struct kvm_vcpu *vcpu)
return ret;
 }
 
+void *kvm_lapic_get_regs(struct kvm_vcpu *vcpu)
+{
+   struct kvm_kern_apic *apic = (struct kvm_kern_apic*)vcpu->apic.dev;
+   return apic->regs;
+}
+EXPORT_SYMBOL_GPL(kvm_lapic_get_regs);
+
 /*
  *--
  * timer interface
@@ -1286,6 +1293,16 @@ static int apic_irqdev_ack(struct kvm_irqdevice *this, 
int flags,
if ((irq & 0xf0) > apic_get_reg(apic, APIC_PROCPRI))
data->flags |= KVM_IRQACKDATA_VECTOR_PENDING;
 
+   if (irq) {
+   /*
+* We report the next pending vector here so that the system
+* can assess TPR thresholds for TPR-shadowing purposes
+* (if applicable)
+*/
+   data->next   = irq;
+   data->flags |= KVM_IRQACKDATA_NEXT_VALID;
+   }
+
  out:
spin_unlock_bh(&apic->lock);
 


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 08/10] KVM: Add statistics from interrupt subsystem

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/kvm.h  |6 ++
 drivers/kvm/kvm_main.c |   23 ---
 drivers/kvm/vmx.c  |2 ++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index a9ee8bd..efc9be5 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -276,6 +276,12 @@ struct kvm_stat {
u32 request_irq_exits;
u32 irq_exits;
u32 light_exits;
+   u32 irq_posted;
+   u32 irq_ignored;
+   u32 irq_accepted;
+   u32 guest_preempt;
+   u32 apic_mmio;
+   u32 local_mmio;
 };
 
 struct kvm_io_device {
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 941a4c6..a4c180f 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -72,6 +72,12 @@ static struct kvm_stats_debugfs_item {
{ "request_irq", STAT_OFFSET(request_irq_exits) },
{ "irq_exits", STAT_OFFSET(irq_exits) },
{ "light_exits", STAT_OFFSET(light_exits) },
+   { "irq_posted", STAT_OFFSET(irq_posted) },
+   { "irq_ignored", STAT_OFFSET(irq_ignored) },
+   { "irq_accepted", STAT_OFFSET(irq_accepted) },
+   { "guest_preempt", STAT_OFFSET(guest_preempt) },
+   { "apic_mmio", STAT_OFFSET(apic_mmio) },
+   { "local_mmio", STAT_OFFSET(local_mmio) },
{ NULL }
 };
 
@@ -1136,13 +1142,19 @@ static struct kvm_io_device *vcpu_find_mmio_dev(struct 
kvm_vcpu *vcpu,
/*
 * First check if the LAPIC will snarf this request
 */
-   if (dev && dev->in_range(dev, addr))
+   if (dev && dev->in_range(dev, addr)) {
+   ++vcpu->stat.apic_mmio;
return dev;
+   }
 
/*
 * And then fallback to allow any device to participate
 */
-   return kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr);
+   dev = kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr);
+   if (dev)
+   ++vcpu->stat.local_mmio;
+
+   return dev;
 }
 
 static int emulator_read_emulated(unsigned long addr,
@@ -2446,6 +2458,8 @@ static void kvm_vcpu_intr(struct kvm_irqsink *this,
struct kvm_vcpu *vcpu = (struct kvm_vcpu*)this->private;
int direct_ipi = -1;
 
+   ++vcpu->stat.irq_posted;
+
spin_lock_irq(&vcpu->irq.lock);
 
if (!test_bit(pin, &vcpu->irq.pending)) {
@@ -2465,8 +2479,11 @@ static void kvm_vcpu_intr(struct kvm_irqsink *this,
 */
direct_ipi = vcpu->irq.guest_cpu;
BUG_ON(direct_ipi == smp_processor_id());
+   ++vcpu->stat.guest_preempt;
}
-   }
+   } else
+   ++vcpu->stat.irq_ignored;
+
 
spin_unlock_irq(&vcpu->irq.lock);
 
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index f532c87..357fb86 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1522,6 +1522,8 @@ static void do_intr_requests(struct kvm_vcpu *vcpu,
 ack.vector |
 INTR_TYPE_EXT_INTR |
 INTR_INFO_VALID_MASK);
+
+   ++vcpu->stat.irq_accepted;
}
}
 


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 09/10] KVM: Support level-sensitive interrupts better

2007-05-23 Thread Gregory Haskins
This patch adds better support for level-sensitive interrupts with the
in-kernel APIC.

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/lapic.c |   79 +++
 1 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 602e94c..7873748 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -354,14 +354,9 @@ static int apic_match_dest(struct kvm_kern_apic *target,
return result;
 }
 
-/*
- * Add a pending IRQ into lapic.
- * Return 1 if successfully added and 0 if discarded.
- */
-static int __apic_accept_irq(struct kvm_kern_apic *apic,
+static int __apic_assert_irq(struct kvm_kern_apic *apic,
 int delivery_mode,
 int vector,
-int level,
 int trig_mode)
 {
kvm_irqpin_t pin = kvm_irqpin_invalid;
@@ -405,11 +400,9 @@ static int __apic_accept_irq(struct kvm_kern_apic *apic,
break;
case APIC_DM_INIT:
apic_debug("INIT interrupt\n");
-   if (level) {
-   spin_unlock_bh(&apic->lock);
-   kvm_lapic_reset(apic->vcpu);
-   spin_lock_bh(&apic->lock);
-   }
+   spin_unlock_bh(&apic->lock);
+   kvm_lapic_reset(apic->vcpu);
+   spin_lock_bh(&apic->lock);
break;
case APIC_DM_STARTUP: /* FIXME: currently no support for SMP */
default:
@@ -434,6 +427,61 @@ static int __apic_accept_irq(struct kvm_kern_apic *apic,
return 0;
 }
 
+static int __apic_deassert_irq(struct kvm_kern_apic *apic,
+  int delivery_mode,
+  int vector,
+  int trig_mode)
+{
+   switch (delivery_mode) {
+   case APIC_DM_FIXED:
+   case APIC_DM_LOWEST:
+   if (unlikely(!apic_enabled(apic)))
+   break;
+
+   /*
+* Deasserts only have an effect on level-senstitive lines
+*/
+   if (trig_mode) {
+   __clear_bit(vector, apic->regs + APIC_IRR);
+   __clear_bit(vector, apic->regs + APIC_TMR);
+
+   apic_debug("FIXED/LOWEST interrupt deassert for " \
+  "vector %d\n", vector);
+   }
+   break;
+   default:
+   break;
+   }
+
+   return 1;
+}
+
+/*
+ * Add a pending IRQ into lapic.
+ * Return 1 if successfully added and 0 if discarded.
+ */
+static int __apic_accept_irq(struct kvm_kern_apic *apic,
+int delivery_mode,
+int vector,
+int level,
+int trig_mode)
+{
+   if (!trig_mode || (trig_mode && level))
+   /*
+* If we are edge-triggered, or if we are level-triggered
+* and the level is high, assert the vector
+*/
+   return __apic_assert_irq(apic, delivery_mode, vector,
+trig_mode);
+   else
+   /*
+* Otherwise, if we are level-triggered and the level is
+* low, deassert
+*/
+   return __apic_deassert_irq(apic, delivery_mode, vector,
+  trig_mode);
+}
+
 static int apic_accept_irq(struct kvm_kern_apic *apic,
   int delivery_mode,
   int vector,
@@ -1256,7 +1304,14 @@ static int apic_irqdev_ack(struct kvm_irqdevice *this, 
int flags,
BUG_ON (irq < 0x10);
 
__set_bit(irq, apic->regs + APIC_ISR);
-   __clear_bit(irq, apic->regs + APIC_IRR);
+
+   /*
+* Level sensitive interrupts remain pending
+* until they are cleared
+*/
+   if (!test_bit(irq, apic->regs + APIC_TMR))
+   __clear_bit(irq, apic->regs + APIC_IRR);
+
apic_update_ppr(apic);
 
/*


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 10/10] KVM: Adds support for halting in the kernel

2007-05-23 Thread Gregory Haskins
Halting in userspace requires a relatively cumbersome mechanism to signal the
halted VCPU.  Implementing halt in kernel should be relatively straight
forward and it eliminates the need for the signaling

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 drivers/kvm/kvm.h  |3 +
 drivers/kvm/kvm_main.c |   97 
 drivers/kvm/svm.c  |7 ---
 drivers/kvm/vmx.c  |7 ---
 4 files changed, 102 insertions(+), 12 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index efc9be5..f05f174 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -273,6 +273,7 @@ struct kvm_stat {
u32 signal_exits;
u32 irq_window_exits;
u32 halt_exits;
+   u32 halt_wakeup;
u32 request_irq_exits;
u32 irq_exits;
u32 light_exits;
@@ -354,6 +355,7 @@ struct kvm_vcpu_irq {
int  pending;
int  deferred;
int  guest_cpu;
+   wait_queue_head_twq;
 };
 
 struct kvm_lapic {
@@ -632,6 +634,7 @@ void kvm_mmu_module_exit(void);
 
 int kvm_apicbus_send(struct kvm *kvm, int dest, int trig_mode, int level,
 int dest_mode, int delivery_mode, int vector);
+int kvm_vcpu_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
 
 void kvm_mmu_destroy(struct kvm_vcpu *vcpu);
 int kvm_mmu_create(struct kvm_vcpu *vcpu);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index a4c180f..ebd6cb4 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -69,6 +69,7 @@ static struct kvm_stats_debugfs_item {
{ "signal_exits", STAT_OFFSET(signal_exits) },
{ "irq_window", STAT_OFFSET(irq_window_exits) },
{ "halt_exits", STAT_OFFSET(halt_exits) },
+   { "halt_wakeup", STAT_OFFSET(halt_wakeup) },
{ "request_irq", STAT_OFFSET(request_irq_exits) },
{ "irq_exits", STAT_OFFSET(irq_exits) },
{ "light_exits", STAT_OFFSET(light_exits) },
@@ -333,6 +334,7 @@ static struct kvm *kvm_create_vm(void)
memset(&vcpu->irq, 0, sizeof(vcpu->irq));
spin_lock_init(&vcpu->irq.lock);
vcpu->irq.deferred = -1;
+   init_waitqueue_head(&vcpu->irq.wq);
 
vcpu->cpu = -1;
vcpu->kvm = kvm;
@@ -2434,6 +2436,91 @@ out1:
 }
 
 /*
+ * The vCPU has executed a HLT instruction with in-kernel mode enabled.
+ */
+static int kvm_vcpu_kern_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
+{
+   DECLARE_WAITQUEUE(wait, current);
+   sigset_t sigblocked, sigsaved;
+   int r = 1;
+
+   /*
+* Unmask all signals while we wait
+*/
+   memset(&sigblocked, 0, sizeof(sigblocked));
+   sigprocmask(SIG_SETMASK, &sigblocked, &sigsaved);
+
+   spin_lock_irq(&vcpu->irq.lock);
+   __add_wait_queue(&vcpu->irq.wq, &wait);
+
+   /*
+* We will block until either an interrupt or a signal wakes us up
+*/
+   while(!__kvm_vcpu_irq_pending(vcpu)
+ && !signal_pending(current)
+ && !kvm_run->request_interrupt_window) {
+   set_current_state(TASK_INTERRUPTIBLE);
+
+   spin_unlock_irq(&vcpu->irq.lock);
+   vcpu_put(vcpu);
+
+   schedule();
+
+   vcpu_load(vcpu);
+   spin_lock_irq(&vcpu->irq.lock);
+   }
+
+   /*
+* If userspace is waiting for an injection point, we cant sleep here
+*/
+   if (kvm_run->request_interrupt_window
+   && !__kvm_vcpu_irq_pending(vcpu)) {
+   kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
+   r = 0;
+   }
+
+   __remove_wait_queue(&vcpu->irq.wq, &wait);
+   __set_current_state(TASK_RUNNING);
+   spin_unlock_irq(&vcpu->irq.lock);
+
+   /*
+* Restore the signal mask before returning
+*/
+   sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+
+   return r;
+}
+
+/*
+ * The vCPU has executed a HLT instruction.
+ */
+int kvm_vcpu_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
+{
+   int r = -EINVAL;
+
+   ++vcpu->stat.halt_exits;
+
+   if (vcpu->kvm->enable_kernel_pic)
+   /*
+* If the in-kernel PIC is enabled, we will perform HLT
+* in-kernel as well
+*/
+   r = kvm_vcpu_kern_halt(vcpu, kvm_run);
+   else {
+   /*
+* Else, we decide to go back to userspace or vmenter depending
+* on whether there are interrupts currently pending or not
+*/
+   r = kvm_vcpu_irq_pending(vcpu) ? 1 : 0;
+   if (!r)
+   kvm_run->exit_reason = KVM_EXIT_HLT;
+   }
+
+   return r;
+}
+EXPORT_SYMBOL_GPL(kvm_vcpu_halt);
+
+/*
  * This function is invoked whenever we want to interrupt a vcpu that is
  * currently executing in guest-mode.  It currently is a no-op because
  * the s

[kvm-devel] [PATCH 0/6] in-kernel APIC v7 (userspace side)

2007-05-23 Thread Gregory Haskins
This is the userspace series corresponding to the kernel side v7 I just made:

Here are the changes:

1) Fixed a bug in qemu-kvm.c which was exposed with in-kernel HLT turned on.
   Therefore, the in-kernel HLT feature will only enable itself if the
   in-kernel APIC is also enabled.  The assumption is that the bug is fixed in
   userspace that is in-kernel APIC aware.
2) Slightly changed the way IOAPIC interrupts are delivered.  In previous
   generations, the IOAPIC would push the APIC_MSG objects to the kernel on
   demand.  The new version queues the interrupts until the next "try_to_push"
   window.  This makes the APIC and the PIC subsystem operate more closely
   with one another.

Regards,
-Greg

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 1/6] KVM-USER: Fix for CPU interrupts in QEMU

2007-05-23 Thread Gregory Haskins
QEMU-KVM has a bug where the interruptibility of the CPU is predicated on
pending interrupts.  If the reason that a CPU is interrupted is because we
need to inject interrupts, the current code will just keep looping and miss
the event window.

This doesnt seem to cause problems with in-trunk KVM.  However, once we turn
on in-kernel HALTING, QEMU starts to have some serious problems that were
attributed to this bug.

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 qemu/qemu-kvm.c |5 +
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 1849997..5b5c739 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -452,11 +452,8 @@ void kvm_save_registers(CPUState *env)
 int kvm_cpu_exec(CPUState *env)
 {
 int r;
-int pending = (!env->ready_for_interrupt_injection ||
-   ((env->interrupt_request & CPU_INTERRUPT_HARD) &&
-  (env->eflags & IF_MASK)));
 
-if (!pending && (env->interrupt_request & CPU_INTERRUPT_EXIT)) {
+if (env->interrupt_request & CPU_INTERRUPT_EXIT) {
 env->interrupt_request &= ~CPU_INTERRUPT_EXIT;
 env->exception_index = EXCP_INTERRUPT;
 cpu_loop_exit();


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 2/6] KVM: Updates for compiling in-kernel APIC support with external-modules

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 kernel/Kbuild |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/Kbuild b/kernel/Kbuild
index e9bcda7..103a179 100644
--- a/kernel/Kbuild
+++ b/kernel/Kbuild
@@ -1,5 +1,5 @@
 EXTRA_CFLAGS := -I$(src)/include -include $(src)/external-module-compat.h
 obj-m := kvm.o kvm-intel.o kvm-amd.o
-kvm-objs := kvm_main.o mmu.o x86_emulate.o
+kvm-objs := kvm_main.o mmu.o x86_emulate.o userint.o kernint.o lapic.o
 kvm-intel-objs := vmx.o vmx-debug.o
 kvm-amd-objs := svm.o


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 3/6] KVM-USER: Make the kvm_allowed flag always defined so we dont need #ifdefs

2007-05-23 Thread Gregory Haskins
Non-performance critical code is made more awkward by having to always define
both "#ifdef KVM" and "if (kvm_allowed)".  Define "kvm_allowed = 0" by
default.  Anthony Ligouri is credited with the idea.

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 qemu/qemu-kvm.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 5b5c739..f13db08 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -3,6 +3,14 @@
 #include "config-host.h"
 
 #ifdef USE_KVM
+ #define KVM_ALLOWED_DEFAULT 1
+#else
+ #define KVM_ALLOWED_DEFAULT 0
+#endif
+
+int kvm_allowed = KVM_ALLOWED_DEFAULT;
+
+#ifdef USE_KVM
 
 #include "exec.h"
 
@@ -14,7 +22,6 @@
 
 extern void perror(const char *s);
 
-int kvm_allowed = 1;
 kvm_context_t kvm_context;
 static struct kvm_msr_list *kvm_msr_list;
 static int kvm_has_msr_star;


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 4/6] KVM-USER: Add ability to specify APIC emulation type from the command-line

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 qemu/qemu-kvm.c |   27 +++
 qemu/qemu-kvm.h |5 +
 qemu/vl.c   |   10 ++
 qemu/vl.h   |1 +
 4 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index f13db08..106772b 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -10,6 +10,17 @@
 
 int kvm_allowed = KVM_ALLOWED_DEFAULT;
 
+struct kvm_apic
+{
+int user_specified;
+int level;
+};
+
+struct kvm_apic kvm_apic = {
+.user_specified = 0,
+.level = 1,
+};
+
 #ifdef USE_KVM
 
 #include "exec.h"
@@ -927,4 +938,20 @@ int kvm_get_phys_ram_page_bitmap(unsigned char *bitmap)
  out:
 return r;
 }
+
+int kvm_qemu_set_apic_level(int level)
+{
+if (level < 0 || level > 1)
+   return -1;
+
+kvm_apic.user_specified = 1;
+kvm_apic.level = level;
+return 0;
+}
+
+int kvm_qemu_get_apic_level(void)
+{
+return kvm_apic.level;
+}
+
 #endif
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8a1c25d..c4cb34e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -3,6 +3,8 @@
 
 #include "kvmctl.h"
 
+
+
 int kvm_qemu_init(void);
 int kvm_qemu_create_context(void);
 void kvm_qemu_destroy(void);
@@ -16,6 +18,9 @@ int kvm_physical_memory_set_dirty_tracking(int enable);
 int kvm_update_dirty_pages_log(void);
 int kvm_get_phys_ram_page_bitmap(unsigned char *bitmap);
 
+int kvm_qemu_set_apic_level(int level);
+int kvm_qemu_get_apic_level(void);
+
 #define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))
 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
 #endif
diff --git a/qemu/vl.c b/qemu/vl.c
index 7df1c80..4bf61e8 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -6531,6 +6531,7 @@ enum {
 QEMU_OPTION_vnc,
 QEMU_OPTION_no_acpi,
 QEMU_OPTION_no_kvm,
+QEMU_OPTION_kvm_apic,
 QEMU_OPTION_no_reboot,
 QEMU_OPTION_daemonize,
 QEMU_OPTION_option_rom,
@@ -6600,6 +6601,7 @@ const QEMUOption qemu_options[] = {
 #endif
 #ifdef USE_KVM
 { "no-kvm", 0, QEMU_OPTION_no_kvm },
+{ "kvm_apic", HAS_ARG, QEMU_OPTION_kvm_apic },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
 { "g", 1, QEMU_OPTION_g },
@@ -7309,6 +7311,14 @@ int main(int argc, char **argv)
case QEMU_OPTION_no_kvm:
kvm_allowed = 0;
break;
+   case QEMU_OPTION_kvm_apic:
+   if (kvm_qemu_set_apic_level(atoi(optarg)) < 0) {
+   fprintf(stderr, "kvm_apic = %d is not supported by " \
+   "userspace\n", atoi(optarg));
+   exit(1);
+   }
+   
+   break;
 #endif
 case QEMU_OPTION_usb:
 usb_enabled = 1;
diff --git a/qemu/vl.h b/qemu/vl.h
index debd17c..4e93a81 100644
--- a/qemu/vl.h
+++ b/qemu/vl.h
@@ -158,6 +158,7 @@ extern int graphic_depth;
 extern const char *keyboard_layout;
 extern int kqemu_allowed;
 extern int kvm_allowed;
+extern struct kvm_apic kvm_apic;
 extern int win2k_install_hack;
 extern int usb_enabled;
 extern int smp_cpus;


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 5/6] KVM: in-kernel-apic modification to QEMU

2007-05-23 Thread Gregory Haskins
Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 qemu/hw/apic.c  |   35 ++-
 qemu/hw/pc.c|   34 --
 qemu/qemu-kvm.c |   49 +++--
 qemu/qemu-kvm.h |2 ++
 qemu/vl.h   |   11 ++-
 user/kvmctl.c   |   33 -
 user/kvmctl.h   |   31 ++-
 user/main.c |2 +-
 8 files changed, 160 insertions(+), 37 deletions(-)

diff --git a/qemu/hw/apic.c b/qemu/hw/apic.c
index 5704224..dee547d 100644
--- a/qemu/hw/apic.c
+++ b/qemu/hw/apic.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "vl.h"
+#include "qemu-kvm.h"
 
 //#define DEBUG_APIC
 //#define DEBUG_IOAPIC
@@ -87,6 +88,7 @@ typedef struct APICState {
 } APICState;
 
 struct IOAPICState {
+CPUState *cpu_env;
 uint8_t id;
 uint8_t ioregsel;
 
@@ -866,7 +868,7 @@ int apic_init(CPUState *env)
 return 0;
 }
 
-static void ioapic_service(IOAPICState *s)
+void ioapic_service(IOAPICState *s)
 {
 uint8_t i;
 uint8_t trig_mode;
@@ -895,15 +897,29 @@ static void ioapic_service(IOAPICState *s)
 vector = pic_read_irq(isa_pic);
 else
 vector = entry & 0xff;
-
-apic_get_delivery_bitmask(deliver_bitmask, dest, dest_mode);
-apic_bus_deliver(deliver_bitmask, delivery_mode, 
- vector, polarity, trig_mode);
+ 
+   if (use_kernel_apic())
+   ext_apic_bus_deliver(dest, trig_mode, dest_mode,
+delivery_mode, vector);
+   else {
+   apic_get_delivery_bitmask(deliver_bitmask, dest,
+ dest_mode);
+   apic_bus_deliver(deliver_bitmask, delivery_mode, 
+vector, polarity, trig_mode);
+   }
 }
 }
 }
 }
 
+static void __ioapic_service(IOAPICState *s)
+{
+if (use_kernel_apic())
+   cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);  
+else
+   ioapic_service(s);
+}
+
 void ioapic_set_irq(void *opaque, int vector, int level)
 {
 IOAPICState *s = opaque;
@@ -916,7 +932,7 @@ void ioapic_set_irq(void *opaque, int vector, int level)
 /* level triggered */
 if (level) {
 s->irr |= mask;
-ioapic_service(s);
+__ioapic_service(s);
 } else {
 s->irr &= ~mask;
 }
@@ -924,7 +940,7 @@ void ioapic_set_irq(void *opaque, int vector, int level)
 /* edge triggered */
 if (level) {
 s->irr |= mask;
-ioapic_service(s);
+__ioapic_service(s);
 }
 }
 }
@@ -996,7 +1012,7 @@ static void ioapic_mem_writel(void *opaque, 
target_phys_addr_t addr, uint32_t va
 s->ioredtbl[index] &= ~0xULL;
 s->ioredtbl[index] |= val;
 }
-ioapic_service(s);
+__ioapic_service(s);
 }
 }
 }
@@ -1052,7 +1068,7 @@ static CPUWriteMemoryFunc *ioapic_mem_write[3] = {
 ioapic_mem_writel,
 };
 
-IOAPICState *ioapic_init(void)
+IOAPICState *ioapic_init(CPUState *env)
 {
 IOAPICState *s;
 int io_memory;
@@ -1061,6 +1077,7 @@ IOAPICState *ioapic_init(void)
 if (!s)
 return NULL;
 ioapic_reset(s);
+s->cpu_env = env;
 s->id = last_apic_id++;
 
 io_memory = cpu_register_io_memory(0, ioapic_mem_read, 
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index eda49cf..8de5911 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -46,6 +46,8 @@ static PITState *pit;
 static IOAPICState *ioapic;
 static PCIDevice *i440fx_state;
 
+void ioapic_service(IOAPICState *s);
+
 static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
 {
 }
@@ -91,16 +93,20 @@ int cpu_get_pic_interrupt(CPUState *env)
 {
 int intno;
 
-intno = apic_get_interrupt(env);
-if (intno >= 0) {
-/* set irq request if a PIC irq is still pending */
-/* XXX: improve that */
-pic_update_irq(isa_pic); 
-return intno;
-}
-/* read the irq from the PIC */
-if (!apic_accept_pic_intr(env))
-return -1;
+if (!use_kernel_apic()) {
+   intno = apic_get_interrupt(env);
+   if (intno >= 0) {
+   /* set irq request if a PIC irq is still pending */
+   /* XXX: improve that */
+   pic_update_irq(isa_pic); 
+   return intno;
+   }
+   
+   /* read the irq from the PIC */
+   if (!apic_accept_pic_intr(env))
+   return -1;
+} else
+   ioapic_service(ioapic);
 
 intno = pic_read_irq(isa_pic);
 return intno;
@@ -483,9 +489,9 @@ stati

[kvm-devel] [PATCH 6/6] KVM-USER: Check kvm extensions at runtime

2007-05-23 Thread Gregory Haskins
Newer userspace may run on an older kernel.  Therefore we need a way to 
check the capabilities of the kernel so that we can downgrade userspace
dynamically if necessary

Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]>
---

 qemu/qemu-kvm.c |   27 +++
 user/kvmctl.c   |   14 ++
 user/kvmctl.h   |8 
 3 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 53990d8..b14eadc 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -706,6 +706,33 @@ int kvm_qemu_init()
 int kvm_qemu_create_context(void)
 {
 int i;
+struct kvm_extensions ext;
+
+if (kvm_check_extension(kvm_context, &ext) < 0) {
+   kvm_qemu_destroy();
+   return -1;
+}
+
+if (!ext.lapic && kvm_apic.level) {
+   /*
+* Opps... the kernel doesnt support apic-emulation even though
+* the userspace is currently configured to enable it.  If this was
+* just simply because of our defaults, silently disable the feature
+* and continue.
+*/
+   if (!kvm_apic.user_specified)
+   kvm_apic.level = 0;
+   else {
+   /*
+* Otherwise, its a fatal error that the user must correct
+*/
+
+   /* FIXME: Should we also log this officially */
+   printf("FATAL: kernel does not support -kvm_apic = %d setting",
+  kvm_apic.level);
+   exit(-1);
+   }
+}
 
 if (kvm_create(kvm_context, phys_ram_size, kvm_apic.level,
   (void**)&phys_ram_base) < 0) {
diff --git a/user/kvmctl.c b/user/kvmctl.c
index 70f9626..596c9cc 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -1076,3 +1076,17 @@ int kvm_set_signal_mask(kvm_context_t kvm, int vcpu, 
const sigset_t *sigset)
free(sigmask);
return r;
 }
+
+int kvm_check_extension(kvm_context_t kvm, struct kvm_extensions *ext)
+{
+   memset(ext, 0, sizeof(*ext));
+
+   int r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_APIC_MSG);
+   if (r < 0)
+   return r;
+
+   if (r)
+   ext->lapic = 1;
+
+   return 0;
+}
diff --git a/user/kvmctl.h b/user/kvmctl.h
index 9aab269..3a7726c 100644
--- a/user/kvmctl.h
+++ b/user/kvmctl.h
@@ -426,4 +426,12 @@ int kvm_dirty_pages_log_enable_all(kvm_context_t kvm);
  */
 int kvm_dirty_pages_log_reset(kvm_context_t kvm);
 
+struct kvm_extensions
+{
+int lapic; /* Today we only have one.  Add more here as they come up */
+};
+
+int kvm_check_extension(kvm_context_t kvm, struct kvm_extensions *ext);
+
+
 #endif


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [ANNOUNCE] kvm-25 release

2007-05-23 Thread Avi Kivity
Regular readers of this column will not be surprised to hear that kvm-25
is much faster than earlier versions.

Changes since kvm-24:
- massive performance increase (Eddie Dong)
- regenerate bios from latest bochs sources, hopefully fixing a
regression with some guests
- some testsuite work (Anthony Lihuori, Eddie Dong, me)
- minor fixes (various)

Notes:
  If you use the modules from kvm-25, you can use any version of Linux
from 2.6.9 upwards.
  If you use the modules from Linux 2.6.20, you need to use kvm-12.
  If you use the modules from Linux 2.6.21, you need to use kvm-17.

  API/ABI stability is planned for Linux 2.6.22.

http://kvm.qumranet.com

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Eric Van Hensbergen
On 5/23/07, Carsten Otte <[EMAIL PROTECTED]> wrote:
>
> For me, plan9 does provide answers to a lot of above requirements.
> However, it does not provide capabilities for shared memory and it
> adds extra complexity. It's been designed to solve a different problem.
>

As a point of clarification, plan9 protocols have been used over
shared memory for resource access on virtualized systems for the past
3 years.  There are certainly ways it can be further optimized, but it
is not a restriction.  As far as complexity goes, our guest-side stack
is around 2000 lines of code (with an additional 1000 lines of support
routines that could likely be replaced by standard library or OS
services in more conventional platforms) and supports console, file
system, network, and block device access.

> I think the virtual device abstraction should provide the following
> functionality:
> - hypercall guest to host with parameters and return value
> - interrupt from host to guest with parameters
> - thin interrupt from host to guest, no parameters
> - shared memory between guest and host
> - dma access to guest memory, possibly via kmap on the host
> - copy from/to guest memory
>

Good list.  We can certainly work within these parameters.  It would
be nice to have some facility for direct guest<->guest communication
-- however, I understand the difficulties in doing that in a secure
and safe way.  Still, having the ability to provision such a direct
interface would be nice for those that can take advantage of it.

-eric

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [ANNOUNCE] kvm-25 release

2007-05-23 Thread Laurent Vivier
Avi Kivity wrote:
> Regular readers of this column will not be surprised to hear that kvm-25
> is much faster than earlier versions.
> 
> Changes since kvm-24:
> - massive performance increase (Eddie Dong)
> - regenerate bios from latest bochs sources, hopefully fixing a
> regression with some guests
> - some testsuite work (Anthony Lihuori, Eddie Dong, me)
> - minor fixes (various)
> 
> Notes:
>   If you use the modules from kvm-25, you can use any version of Linux
> from 2.6.9 upwards.
>   If you use the modules from Linux 2.6.20, you need to use kvm-12.
>   If you use the modules from Linux 2.6.21, you need to use kvm-17.
> 
>   API/ABI stability is planned for Linux 2.6.22.
> 
> http://kvm.qumranet.com
> 

Compilation fails on my system (Debian etch on x86_64)

gcc -I /home/vivierl/kvm-25/kernel/include -MMD -MF test/.bootstrap.d -g
-fomit-frame-pointer -Wall -m64  -fno-stack-protector   -std=gnu99
-ffreestanding -c -nostdlib -o test/bootstrap.o test/bootstrap.S
test/bootstrap.S:2:3: error: invalid preprocessing directive #minimal

You should remove ASM style comments from bootstrap.S ("#  ")

Regards,
Laurent

-- 
- [EMAIL PROTECTED]  --
   "Any sufficiently advanced technology is
  indistinguishable from magic." - Arthur C. Clarke



signature.asc
Description: OpenPGP digital signature
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-22 and Vista support

2007-05-23 Thread Jorge Lucángeli Obes
On 5/23/07, Avi Kivity <[EMAIL PROTECTED]> wrote:
> Jorge Lucángeli Obes wrote:
> > I had some time on my hands lately and tried to debug this a little. I
> > found that there's actually something showing in dmesg:
> >
> > [ 3872.221039] emulation failed but !mmio_needed? rip 9a12 0f 09 66 25
> >
> > Does that help? I'm running kvm-24 now, but the exception still
> > happens. I've been looking through x86_emulate.c and kvmctl.c trying
> > to print more information but with no success yet.
> >
>
> Does the attached patch help?  It implements 0f 09, wbinvd.

It actually did! I still cannot get to the login prompt, but there's
no more Exception 13. Now I get:

[EMAIL PROTECTED]:~$ sudo qemu-system-x86_64 -localtime -no-rtc -no-reboot
-m 512 stuff/qemu/vista.img
Bus error

That's the same thing I get with kvm-25, which I found has the above
patch applied (or something equivalent). I'm able to catch a glimpse
of what I think is Vista's bootloader and then QEMU/KVM exits with the
above error. It sounded like a QEMU error to me, but it doesn't happen
when running with '-no-kvm'.

I still don't get a login prompt when running plain QEMU (it stops
halfway through the boot process - I've not looked deep into that),
but nonetheless I get further than with QEMU/KVM. Any ideas?

Cheers,
Jorge

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Arnd Bergmann
On Wednesday 23 May 2007, Eric Van Hensbergen wrote:
> On 5/23/07, Carsten Otte <[EMAIL PROTECTED]> wrote:
> >
> > For me, plan9 does provide answers to a lot of above requirements.
> > However, it does not provide capabilities for shared memory and it
> > adds extra complexity. It's been designed to solve a different problem.
> >
> As a point of clarification, plan9 protocols have been used over
> shared memory for resource access on virtualized systems for the past
> 3 years.  There are certainly ways it can be further optimized, but it
> is not a restriction.

I think what Carsten means is to have a mmap interface over 9p, not
implementing 9p by means of shared memory, which is what I guess
you are referring to.

If you want to share memory areas between a guest and the host
or another guest, you can't do that with the regular Tread/Twrite
interface that 9p has on a file.

> As far as complexity goes, our guest-side stack 
> is around 2000 lines of code (with an additional 1000 lines of support
> routines that could likely be replaced by standard library or OS
> services in more conventional platforms) and supports console, file
> system, network, and block device access.

Another interface that I think is missing in 9p is a notification
for hotplugging. Of course you can have a long-running read on a
special file that returns the file names for virtual devices that
have been added or removed in the guest, but that sounds a little
clumsy compared to an specialized interface (e.g. Tnotify).

Arnd <><

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Eric Van Hensbergen
On 5/23/07, Arnd Bergmann <[EMAIL PROTECTED]> wrote:
> On Wednesday 23 May 2007, Eric Van Hensbergen wrote:
> > On 5/23/07, Carsten Otte <[EMAIL PROTECTED]> wrote:
> > >
> > > For me, plan9 does provide answers to a lot of above requirements.
> > > However, it does not provide capabilities for shared memory and it
> > > adds extra complexity. It's been designed to solve a different problem.
> > >
> > As a point of clarification, plan9 protocols have been used over
> > shared memory for resource access on virtualized systems for the past
> > 3 years. There are certainly ways it can be further optimized, but it
> > is not a restriction.
>
> I think what Carsten means is to have a mmap interface over 9p, not
> implementing 9p by means of shared memory, which is what I guess
> you are referring to.
>
> If you want to share memory areas between a guest and the host
> or another guest, you can't do that with the regular Tread/Twrite
> interface that 9p has on a file.
>

Well, there's nothing strictly preventing a mmap interface over 9p (in
fact we are working with that in a Cell project internally) --
however, I'm not sure that makes the best sense for device access
anyways.  The real thing missing from the current implementation is a
better underlying transport which can pass payloads by reference to
shared memory as opposed to marshaling operations through a shared
memory transport -- however, this is what Los Alamos and IBM are
working on right now.

> > As far as complexity goes, our guest-side stack
> > is around 2000 lines of code (with an additional 1000 lines of support
> > routines that could likely be replaced by standard library or OS
> > services in more conventional platforms) and supports console, file
> > system, network, and block device access.
>
> Another interface that I think is missing in 9p is a notification
> for hotplugging. Of course you can have a long-running read on a
> special file that returns the file names for virtual devices that
> have been added or removed in the guest, but that sounds a little
> clumsy compared to an specialized interface (e.g. Tnotify).
>

Discovery and hot-plugging would be synthetic file system semantic
issues that need to be resolved and in general are probably, as Rusty
and others suggested, best handled as a separate set of topics.  That
being said, specialized interfaces always seemed a bit more clunky to
me (just look at ioctl), but I suppose that's largely a matter of
taste.  The advantage of having a file system interface to event
notification is it creates a much more flexible environment, allowing
even simple shell scripting languages to resolve events versus having
to build a complex infrastructure -- and since 9p can be transitively
mounted over a network, you can build cluster management suites
without secondary layers of gorp for such things.  The LANL guys will
probably have more to say about this at their OLS talk on the KVM
management synthetic file system interface they build with 9p.

-eric

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH/RFC 7/9] Virtual network guest device driver

2007-05-23 Thread Eric Van Hensbergen
On 5/23/07, Eric Van Hensbergen <[EMAIL PROTECTED]> wrote:
> On 5/23/07, Arnd Bergmann <[EMAIL PROTECTED]> wrote:
> > On Wednesday 23 May 2007, Eric Van Hensbergen wrote:
> > > On 5/23/07, Carsten Otte <[EMAIL PROTECTED]> wrote:
> > > >
> > > > For me, plan9 does provide answers to a lot of above requirements.
> > > > However, it does not provide capabilities for shared memory and it
> > > > adds extra complexity. It's been designed to solve a different problem.
> > > >
> > > As a point of clarification, plan9 protocols have been used over
> > > shared memory for resource access on virtualized systems for the past
> > > 3 years. There are certainly ways it can be further optimized, but it
> > > is not a restriction.
> >
> > I think what Carsten means is to have a mmap interface over 9p, not
> > implementing 9p by means of shared memory, which is what I guess
> > you are referring to.
> >
> > If you want to share memory areas between a guest and the host
> > or another guest, you can't do that with the regular Tread/Twrite
> > interface that 9p has on a file.
> >

ugh.  I'm tired.  Its been a long week -- I realized after I fired off
that last message that you mean establishing a shared mapping versus
support for mmap operations over 9p (which devolve into Tread/Twrite).
 Sorry.  Yes -- that's correct, 9p wouldn't necessarily buy you
something like that.  In fact, the current 9p code relies on someone
else providing that basic mechanism in order for us to establish our
shared memory transport.

What Carsten described as his virtual device abstraction sounded like
a good foundation -- just don't make me use ioctl :)

-eric

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] kvm-22 and Vista support

2007-05-23 Thread Jorge Lucángeli Obes
> > Does the attached patch help?  It implements 0f 09, wbinvd.
>
> It actually did! I still cannot get to the login prompt, but there's
> no more Exception 13. Now I get:
>
> [EMAIL PROTECTED]:~$ sudo qemu-system-x86_64 -localtime -no-rtc -no-reboot
> -m 512 stuff/qemu/vista.img
> Bus error
>
> That's the same thing I get with kvm-25, which I found has the above
> patch applied (or something equivalent). I'm able to catch a glimpse
> of what I think is Vista's bootloader and then QEMU/KVM exits with the
> above error. It sounded like a QEMU error to me, but it doesn't happen
> when running with '-no-kvm'.
>
> I still don't get a login prompt when running plain QEMU (it stops
> halfway through the boot process - I've not looked deep into that),
> but nonetheless I get further than with QEMU/KVM. Any ideas?

I messed up earlier... kvm-25 _does_ need Avi's patch in order not to
show the exception. Nonetheless, I managed to find the operation
generating the "Bus error".

Program received signal SIGBUS, Bus error.
[Switching to Thread 47144860629504 (LWP 5096)]
ldl_phys (addr=4093) at ../cpu-all.h:322
322 return *(uint32_t *)ptr;
(gdb) bt
#0  ldl_phys (addr=4093) at ../cpu-all.h:322
#1  0x0047e99d in kvm_readl (opaque=0x9f, addr=159, data=0x2ae0f551b028)
at /home/tamsyn/local/kvm-25/qemu/qemu-kvm.c:568
#2  0x004de1a3 in handle_mmio (kvm=0x2922010,
kvm_run=0x2ae0f551b000) at kvmctl.c:768
#3  0x004de890 in kvm_run (kvm=0x2922010, vcpu=0) at kvmctl.c:971
#4  0x0047e7c3 in kvm_cpu_exec (env=0x29c4330) at
/home/tamsyn/local/kvm-25/qemu/qemu-kvm.c:469
#5  0x0047fb4a in cpu_x86_exec (env1=0x9f) at
/home/tamsyn/local/kvm-25/qemu/cpu-exec.c:411
#6  0x0040c1ba in main_loop () at
/home/tamsyn/local/kvm-25/qemu/vl.c:6272
#7  0x0040db91 in main (argc=7699712, argv=0x29220f0) at
/home/tamsyn/local/kvm-25/qemu/vl.c:7730

That is:

320: static inline int ldl_le_p(void *ptr)
321: {
322: return *(uint32_t *)ptr;
323: }

However, there's a comment in cpu-all.h that reads:

 *   le   : little endian (not implemented yet)

I find that odd... there's something not implemented that appears as a
function and gets called? Maybe the comment is deprecated. Any ideas?

Cheers,
Jorge

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] qemu/kvm seems to take ALSA all for itself?

2007-05-23 Thread Avi Kivity
David Abrahams wrote:
>>> "For ALSA 1.0.9rc2 and higher you don't need to setup dmix. Dmix is 
>>> enabled as default for soundcards which don't support hw mixing."
>>>
>>> I've found this to be the case on my laptop, where I use:
>>>
>>> export QEMU_AUDIO_DRV=alsa
>>> export QEMU_AUDIO_DAC_FIXED_FREQ=48000
>>> export QEMU_AUDIO_ADC_FIXED_FREQ=48000
>>> export QEMU_ALSA_DAC_BUFFER_SIZE=16384
>>>
>>> Buffer size is very important, else it crackles and pops for me.
>>>
>>>   
>>>   
>> This works for me (alsa 1.0.14rc3).  Thanks.
>> 
>
> OK, but *where* do you use this incantation?
>
>   

~/.bashrc, and log in again.

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel