Re: KVM-88 fails to build with esd or pulseaudio

2009-07-14 Thread Frederic Bezies

On 13/07/2009 11:18, Avi Kivity wrote:

On 07/13/2009 10:47 AM, Pelle van der Heide wrote:

Hi,

When running '$ ./configure --audio-drv-list=oss,alsa,sdl,esd,pa
make -j2' the build fails, with both esdaudio.o and paaudio.o
complaining about undefined references to audio_pt_* functions.
The complete build output is attached.



Try changing the line

audio-obj-$(AUDIO_PT_INT) += audio_pt_int.o

to

audio-obj-y += audio_pt_int.o

in Makefile.

What version of make are you using?



Same problem for me, under archlinux 64 bits.

fred ~/download/kvm $ yaourt -Qi make
Nom   : make
Version   : 3.81-4
URL   : http://www.gnu.org/software/make
Licences  : GPL
Groupes   : base-devel
Fournit   : --
Dépend de : glibc  bash
Dépendances opt.  : --
Requis par: --
Incompatible avec : --
Remplace  : --
Taille (installé) : 1448,00 K
Paqueteur : Andreas Radke andy...@archlinux.org
Architecture  : x86_64
Compilé le: mar. 17 mars 2009 12:42:18 CET
Installé le   : dim. 03 mai 2009 16:50:58 CEST
Motif d'installation  : Explicitement installé
Script d'installation : Oui
Description   : GNU make utility to maintain groups of programs

Hope it helps ;)



--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: KVM-88 fails to build with esd or pulseaudio

2009-07-14 Thread Daniel Gollub
On Tuesday 14 July 2009 10:31:25 am Frederic Bezies wrote:
[...]
 Same problem for me, under archlinux 64 bits.

Try this patch/commit:

commit c6a5a71a3a1886afad5eeb214eb6e8785f4e0319
Author: Anthony Liguori aligu...@us.ibm.com
Date:   Wed Jul 1 10:07:16 2009 -0500

Fix build for ESD audio

Signed-off-by: Anthony Liguori aligu...@us.ibm.com



http://git.kernel.org/?p=virt/kvm/qemu-
kvm.git;a=commitdiff;h=c6a5a71a3a1886afad5eeb214eb6e8785f4e0319

Best Regards,
Daniel

-- 
Daniel GollubGeschaeftsfuehrer: Ralph Dehner
FOSS Developer   Unternehmenssitz:  Vohburg
B1 Systems GmbH  Amtsgericht:   Ingolstadt
Mobil: +49-(0)-160 47 73 970 Handelsregister:   HRB 3537
EMail: gol...@b1-systems.de  http://www.b1-systems.de

Adresse: B1 Systems GmbH, Osterfeldstraße 7, 85088 Vohburg
http://pgpkeys.pca.dfn.de/pks/lookup?op=getsearch=0xED14B95C2F8CA78D
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: KVM-88 fails to build with esd or pulseaudio

2009-07-14 Thread Frederic Bezies

On 14/07/2009 11:46, Daniel Gollub wrote:

On Tuesday 14 July 2009 10:31:25 am Frederic Bezies wrote:
[...]

Same problem for me, under archlinux 64 bits.


Try this patch/commit:

commit c6a5a71a3a1886afad5eeb214eb6e8785f4e0319
Author: Anthony Liguorialigu...@us.ibm.com
Date:   Wed Jul 1 10:07:16 2009 -0500

 Fix build for ESD audio

 Signed-off-by: Anthony Liguorialigu...@us.ibm.com



http://git.kernel.org/?p=virt/kvm/qemu-
kvm.git;a=commitdiff;h=c6a5a71a3a1886afad5eeb214eb6e8785f4e0319

Best Regards,
Daniel



I will try it asap, but modifying Makefile was a working trick. When I 
need to build again KVM, I will use your patch.


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Kernel oops for virtio_blk: [c048a9f8] __bounce_end_io_read+0x88/0xf8

2009-07-14 Thread SAL
Hello,

  one of my server has multiple oopses for virtio_blk devices. Is this a bug
of virtio_blk driver, or something else? Can it be fixed?
These virtual machines hangs aprox. once per day, mostly at midnight.

  Here is one oops:

BUG: unable to handle kernel paging request at fff82000
IP: [c048a9f8] __bounce_end_io_read+0x88/0xf8
Oops: 0002 [#1] SMP
Modules linked in: ipv6 nf_conntrack_netbios_ns virtio_balloon floppy
virtio_net pcspkr joydev i2c_piix4 i2c_core virtio_pci virtio_ring
virtio_blk virtio [last unloaded: scsi_wait_scan]

Pid: 27956, comm: httpd Not tainted (2.6.27.25-170.2.72.fc10.i686.PAE #1)
EIP: 0060:[c048a9f8] EFLAGS: 00210086 CPU: 2
EIP is at __bounce_end_io_read+0x88/0xf8
EAX: fff82000 EBX: e936ae00 ECX: 0400 EDX: 1000
ESI: ea808000 EDI: fff82000 EBP: c08c5f00 ESP: c08c5edc
 DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process httpd (pid: 27956, ti=c08c5000 task=e994 task.ti=e9571000)
Stack:  f1114340 d134ef80 d134ea00  00200086 c048aa7a 1000
    c08c5f08 c048aa8a c08c5f14 c04b8474 d134ef80 c08c5f28 c05149a8
   d134ef80 1000 ea5d1450 c08c5f60 c0514b22   007310b8
Call Trace:
 [c048aa7a] ? bounce_end_io_read+0x0/0x12
 [c048aa8a] ? bounce_end_io_read+0x10/0x12
 [c04b8474] ? bio_endio+0x2b/0x2e
 [c05149a8] ? req_bio_endio+0x84/0xa1
 [c0514b22] ? __end_that_request_first+0x15d/0x257
 [c05155ef] ? __blk_end_request+0x19/0x3b
 [c051566a] ? end_dequeued_request+0x32/0x35
 [f881d602] ? blk_done+0x3d/0x7b [virtio_blk]
 [f8821216] ? vring_interrupt+0x24/0x2e [virtio_ring]
 [f8824359] ? vp_interrupt+0x65/0x98 [virtio_pci]
 [c046a2cf] ? handle_IRQ_event+0x2f/0x64
 [c046b338] ? handle_fasteoi_irq+0x85/0xc0
 [c046b2b3] ? handle_fasteoi_irq+0x0/0xc0
 [c040af0a] ? do_IRQ+0xc7/0xfe
 [c0409668] ? common_interrupt+0x28/0x30
 [c042007b] ? native_flush_tlb_global+0x3a/0x48
 [c04200b1] ? paravirt_leave_lazy+0x20/0x21
 [c041f67b] ? kvm_leave_lazy_mmu+0x68/0x7d
 [c04820a0] ? unmap_vmas+0x4d5/0x644
 [c0485cef] ? vma_link+0x71/0x7d
 [c04856cf] ? unmap_region+0x7d/0xe4
 [c04864ba] ? do_munmap+0x193/0x1e6
 [c048653d] ? sys_munmap+0x30/0x3f
 [c0408c8a] ? syscall_call+0x7/0xb
 ===

I am trying to understand, where there are two call for bounce_end_io_read,
but no ideas yet. Source code for this function is:

static void bounce_end_io_read(struct bio *bio, int err)
{
__bounce_end_io_read(bio, page_pool, err);
}

How it's possible, that there is an recursive call for this function?

Host is running an updated Fedora 11, guest is an updated Fedora 10.
Fails with kernel 2.6.27 and 2.6.29 too (from fedora-updates-testing).

More in Red Hat bugzilla:
  https://bugzilla.redhat.com/show_bug.cgi?id=510304

Thank you.

SAL
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] Convert irq notifiers lists to RCU locking.

2009-07-14 Thread Paul E. McKenney
On Tue, Jul 14, 2009 at 08:46:12AM +0300, Gleb Natapov wrote:
 On Mon, Jul 13, 2009 at 12:31:39PM -0700, Paul E. McKenney wrote:
  On Mon, Jul 13, 2009 at 04:40:59PM +0300, Michael S. Tsirkin wrote:
   On Mon, Jul 13, 2009 at 04:32:34PM +0300, Gleb Natapov wrote:
Yeah I understand that other RCU read section may introduce delays too.
The question is how big the delay may be.
   
   I recall seeing the number at least 3 jiffies somewhere, but that
   might have changed since.
  
  A grace period lasts a handful of jiffies, depending on kernel
  configuration and how long readers remain in a given RCU read-side
  critical section.
  
  If a handful of jiffies is too long, there are patches that speed up
  the grace period, down into the sub-hundred-microsecond range.
  
I don't think multiple
milliseconds delay in device de-assignment is a big issue though.
   
   Right. My point was that since the sync is done under kvm lock, the
   guest can easily get blocked trying to get kvm lock meanwhile.
  
  I will ask the usual question -- can call_rcu() be used to move
  the grace period out from under the lock?  (Often this can be done,
  but not always.)
  
 It can't. Caller frees the data.

I will then ask the usual next question...  Can the freeing of the
data be moved from the caller?

Thanx, Paul
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] Convert irq notifiers lists to RCU locking.

2009-07-14 Thread Gleb Natapov
On Tue, Jul 14, 2009 at 05:03:09AM -0700, Paul E. McKenney wrote:
 On Tue, Jul 14, 2009 at 08:46:12AM +0300, Gleb Natapov wrote:
  On Mon, Jul 13, 2009 at 12:31:39PM -0700, Paul E. McKenney wrote:
   On Mon, Jul 13, 2009 at 04:40:59PM +0300, Michael S. Tsirkin wrote:
On Mon, Jul 13, 2009 at 04:32:34PM +0300, Gleb Natapov wrote:
 Yeah I understand that other RCU read section may introduce delays 
 too.
 The question is how big the delay may be.

I recall seeing the number at least 3 jiffies somewhere, but that
might have changed since.
   
   A grace period lasts a handful of jiffies, depending on kernel
   configuration and how long readers remain in a given RCU read-side
   critical section.
   
   If a handful of jiffies is too long, there are patches that speed up
   the grace period, down into the sub-hundred-microsecond range.
   
 I don't think multiple
 milliseconds delay in device de-assignment is a big issue though.

Right. My point was that since the sync is done under kvm lock, the
guest can easily get blocked trying to get kvm lock meanwhile.
   
   I will ask the usual question -- can call_rcu() be used to move
   the grace period out from under the lock?  (Often this can be done,
   but not always.)
   
  It can't. Caller frees the data.
 
 I will then ask the usual next question...  Can the freeing of the
 data be moved from the caller?
 
Not really. But don't worry. In the case we discuss a small delay is not
a problem.

--
Gleb.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Problem compiling kvm-88

2009-07-14 Thread Jorge Lucángeli Obes
Hi folks,

I'm getting the following error when compiling kvm-88 against a custom
2.6.31-rc2 kernel on Xubuntu 9.04 64 bits. I've tried enabling and
disabling tracing in the kernel configuration to no avail. kvm-88
compiles well on an older 2.6.29.1 (also custom) kernel, and kvm-87
also does _not_ on the custom 2.6.31-rc2 kernel, giving the same
error. Any ideas?

tam...@rory:~/local/kvm-88$ make
for d in pc-bios/optionrom; do \
make -C $d || exit 1 ; \
done
make[1]: Entering directory `/home/tamsyn/local/kvm-88/pc-bios/optionrom'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/tamsyn/local/kvm-88/pc-bios/optionrom'
make -C /lib/modules/2.6.31-rc2-rory/build M=`pwd` \
LINUXINCLUDE=-I`pwd`/include -Iinclude \
 -Iarch/x86/include -I`pwd`/include-compat \
-include include/linux/autoconf.h \
-include `pwd`/x86/external-module-compat.h  \
$@
  CC [M]  /home/tamsyn/local/kvm-88/kvm/kernel/x86/x86.o
In file included from /home/tamsyn/local/kvm-88/kvm/kernel/x86/trace.h:355,
 from /home/tamsyn/local/kvm-88/kvm/kernel/x86/x86.c:83:
include/trace/define_trace.h:53:43: error: arch/x86/kvm/trace.h: No
such file or directory
make[4]: *** [/home/tamsyn/local/kvm-88/kvm/kernel/x86/x86.o] Error 1
make[3]: *** [/home/tamsyn/local/kvm-88/kvm/kernel/x86] Error 2
make[2]: *** [_module_/home/tamsyn/local/kvm-88/kvm/kernel] Error 2
make[1]: *** [all] Error 2
make: *** [kvm-kmod] Error 2

Thanks in advance.

Jorge
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Kernel oops for virtio_blk: [c048a9f8] __bounce_end_io_read+0x88/0xf8

2009-07-14 Thread Christoph Hellwig
On Tue, Jul 14, 2009 at 01:02:54PM +0200, J??n ONDREJ (SAL) wrote:
 Hello,
 
   one of my server has multiple oopses for virtio_blk devices. Is this a bug
 of virtio_blk driver, or something else? Can it be fixed?
 These virtual machines hangs aprox. once per day, mostly at midnight.
 
   Here is one oops:

It looks more like a bug in the bouncing code than virtio-blk itself.
It is fixed by disabling bouncing of highmem addresses in virtio,
and I've sent a patch for that to Rusty (and this list) a while ago.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] KVM test: Do a better job at handling kvm module failures

2009-07-14 Thread Lucas Meneghel Rodrigues
On Mon, 2009-07-13 at 16:26 -0300, Lucas Meneghel Rodrigues wrote:
 Developers might want to use the KVM test to verify changes
 only on their own local qemu source directory and will use the
 'localsrc' install mode on the KVM test control file, and
 provide 'load_modules': 'no' option on the params dict inside
 the kvm control file. However, that option is not documented and
 defaults to 'yes',  and when the code to load kvm modules can't
 find a built kvm.ko module inside the source dir, an unhandled
 error exception (totally unhelpful) will be thrown.
 
 This patch makes the test throw a much more helpful error message,
 helping the developer to figure out what is wrong and fix the
 problem.

Applied.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] KVM test: Make better documentation of the KVM install test params

2009-07-14 Thread Lucas Meneghel Rodrigues
On Mon, 2009-07-13 at 16:26 -0300, Lucas Meneghel Rodrigues wrote:
 In order to improve understanding of the KVM test control, made
 comments on the kvm_install params dictionary, with all modes
 supported and examples of usage. Also, commented out parameters
 that are not going to be used by the default set on that file
 (KVM install using release tarball).

Applied.


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [AUTOTEST] [PATCH 5/5] view ltp_results.html under kvm guests' results.html

2009-07-14 Thread Lucas Meneghel Rodrigues
On Mon, Jul 13, 2009 at 3:10 AM, sudhir kumarsmalik...@gmail.com wrote:
 This patch creates a link to the results html file generated by the test
 under autotest. This is specific to the kvm part only. The assumption made is
 that the file name is test_name_results.html and it is located under
 test_name/results/ directory. This helps in quickly viewing the test 
 results.

Looks good to me.

 The attached tar file contains the full results directory. The results.html 
 file
 points to ltp_results.html which looks quite fancy.

 Please have a look at the results and the patch and provide your comments.

 Signed-off-by: Sudhir Kumar sku...@linux.vnet.ibm.com

 Index: autotest/client/tests/kvm/kvm_tests.py
 ===
 --- autotest.orig/client/tests/kvm/kvm_tests.py
 +++ autotest/client/tests/kvm/kvm_tests.py
 @@ -391,6 +391,15 @@ def run_autotest(test, params, env):
     if not vm.scp_from_remote(autotest/results/default/*, 
 guest_results_dir):
         logging.error(Could not copy results back from guest)

 +    # Some tests create html file as a result, link it to be viewed under
 +    # the results statistics. We assume this file is located under
 +    # test_name/results/ directory and named as test_name_results.html,
 +    # e.g. ltp_result.html, vmmstress_results.html
 +    html_file = test_name + _results.html
 +    html_path = os.path.join(guest_results_dir, test_name, results,
 html_file)
 +    if os.path.exists(html_path):
 +        os.symlink(html_path, os.path.join(test.debugdir, html_file))
 +
     # Fail the test if necessary
     if status_fail:
         raise error.TestFail(message_fail)



 --
 Sudhir Kumar
 ___
 Autotest mailing list
 autot...@test.kernel.org
 http://test.kernel.org/cgi-bin/mailman/listinfo/autotest




-- 
Lucas Meneghel
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/10] Move irq routing data structure to rcu locking

2009-07-14 Thread Gleb Natapov

Signed-off-by: Gleb Natapov g...@redhat.com
---
 include/linux/kvm_host.h |2 +-
 virt/kvm/irq_comm.c  |   55 +-
 virt/kvm/kvm_main.c  |1 -
 3 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f244f11..2490816 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -166,7 +166,7 @@ struct kvm {
 
struct mutex irq_lock;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
-   struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
+   struct kvm_kernel_irq_routing_entry *irq_routing;
struct hlist_head mask_notifier_list;
 #endif
 
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 100c267..0283a2b 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -150,7 +150,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int 
irq, int level)
 * IOAPIC.  So set the bit in both. The guest will ignore
 * writes to the unused one.
 */
-   list_for_each_entry(e, kvm-irq_routing, link)
+   rcu_read_lock();
+   for (e = rcu_dereference(kvm-irq_routing); e  e-set; e++) {
if (e-gsi == irq) {
int r = e-set(e, kvm, sig_level);
if (r  0)
@@ -158,6 +159,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int 
irq, int level)
 
ret = r + ((ret  0) ? 0 : ret);
}
+   }
+   rcu_read_unlock();
return ret;
 }
 
@@ -170,12 +173,15 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned 
irqchip, unsigned pin)
 
trace_kvm_ack_irq(irqchip, pin);
 
-   list_for_each_entry(e, kvm-irq_routing, link)
+   rcu_read_lock();
+   for (e = rcu_dereference(kvm-irq_routing); e  e-set; e++) {
if (e-irqchip.irqchip == irqchip 
e-irqchip.pin == pin) {
gsi = e-gsi;
break;
}
+   }
+   rcu_read_unlock();
 
hlist_for_each_entry(kian, n, kvm-arch.irq_ack_notifier_list, link)
if (kian-gsi == gsi)
@@ -266,19 +272,11 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, 
bool mask)
kimn-func(kimn, mask);
 }
 
-static void __kvm_free_irq_routing(struct list_head *irq_routing)
-{
-   struct kvm_kernel_irq_routing_entry *e, *n;
-
-   list_for_each_entry_safe(e, n, irq_routing, link)
-   kfree(e);
-}
-
 void kvm_free_irq_routing(struct kvm *kvm)
 {
-   mutex_lock(kvm-irq_lock);
-   __kvm_free_irq_routing(kvm-irq_routing);
-   mutex_unlock(kvm-irq_lock);
+   /* Called only during vm destruction. Nobody can use the pointer
+  at this stage */
+   kfree(kvm-irq_routing);
 }
 
 static int setup_routing_entry(struct kvm_kernel_irq_routing_entry *e,
@@ -328,43 +326,40 @@ int kvm_set_irq_routing(struct kvm *kvm,
unsigned nr,
unsigned flags)
 {
-   struct list_head irq_list = LIST_HEAD_INIT(irq_list);
-   struct list_head tmp = LIST_HEAD_INIT(tmp);
-   struct kvm_kernel_irq_routing_entry *e = NULL;
+   struct kvm_kernel_irq_routing_entry *new, *old;
unsigned i;
int r;
 
+   /* last elemet is left zeored and indicates the end of the array */
+   new = kzalloc(sizeof(*new) * (nr + 1), GFP_KERNEL);
+
+   if (!new)
+   return -ENOMEM;
+
for (i = 0; i  nr; ++i) {
r = -EINVAL;
if (ue-gsi = KVM_MAX_IRQ_ROUTES)
goto out;
if (ue-flags)
goto out;
-   r = -ENOMEM;
-   e = kzalloc(sizeof(*e), GFP_KERNEL);
-   if (!e)
-   goto out;
-   r = setup_routing_entry(e, ue);
+   r = setup_routing_entry(new + i, ue);
if (r)
goto out;
++ue;
-   list_add(e-link, irq_list);
-   e = NULL;
}
 
mutex_lock(kvm-irq_lock);
-   list_splice(kvm-irq_routing, tmp);
-   INIT_LIST_HEAD(kvm-irq_routing);
-   list_splice(irq_list, kvm-irq_routing);
-   INIT_LIST_HEAD(irq_list);
-   list_splice(tmp, irq_list);
+   old = kvm-irq_routing;
+   rcu_assign_pointer(kvm-irq_routing, new);
mutex_unlock(kvm-irq_lock);
 
+   synchronize_rcu();
+
r = 0;
+   new = old;
 
 out:
-   kfree(e);
-   __kvm_free_irq_routing(irq_list);
+   kfree(new);
return r;
 }
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7cd1c10..75bf72f 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -945,7 +945,6 @@ static struct kvm *kvm_create_vm(void)
if (IS_ERR(kvm))
goto out;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
-   INIT_LIST_HEAD(kvm-irq_routing);

[PATCH 03/10] Move irq ack notifier list to arch independent code.

2009-07-14 Thread Gleb Natapov
Mask irq notifier list is already there.

Signed-off-by: Gleb Natapov g...@redhat.com
---
 arch/ia64/include/asm/kvm_host.h |1 -
 arch/x86/include/asm/kvm_host.h  |1 -
 include/linux/kvm_host.h |1 +
 virt/kvm/irq_comm.c  |4 ++--
 virt/kvm/kvm_main.c  |1 +
 5 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index d9b6325..a362e67 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -475,7 +475,6 @@ struct kvm_arch {
struct list_head assigned_dev_head;
struct iommu_domain *iommu_domain;
int iommu_flags;
-   struct hlist_head irq_ack_notifier_list;
 
unsigned long irq_sources_bitmap;
unsigned long irq_states[KVM_IOAPIC_NUM_PINS];
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 08732d7..eb723a7 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -401,7 +401,6 @@ struct kvm_arch{
struct kvm_pic *vpic;
struct kvm_ioapic *vioapic;
struct kvm_pit *vpit;
-   struct hlist_head irq_ack_notifier_list;
int vapics_in_nmi_mode;
 
unsigned int tss_addr;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 2490816..b53a5b8 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -168,6 +168,7 @@ struct kvm {
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
struct kvm_kernel_irq_routing_entry *irq_routing;
struct hlist_head mask_notifier_list;
+   struct hlist_head irq_ack_notifier_list;
 #endif
 
 #ifdef KVM_ARCH_WANT_MMU_NOTIFIER
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 0283a2b..cce32de 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -183,7 +183,7 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned 
irqchip, unsigned pin)
}
rcu_read_unlock();
 
-   hlist_for_each_entry(kian, n, kvm-arch.irq_ack_notifier_list, link)
+   hlist_for_each_entry(kian, n, kvm-irq_ack_notifier_list, link)
if (kian-gsi == gsi)
kian-irq_acked(kian);
 }
@@ -192,7 +192,7 @@ void kvm_register_irq_ack_notifier(struct kvm *kvm,
   struct kvm_irq_ack_notifier *kian)
 {
mutex_lock(kvm-irq_lock);
-   hlist_add_head(kian-link, kvm-arch.irq_ack_notifier_list);
+   hlist_add_head(kian-link, kvm-irq_ack_notifier_list);
mutex_unlock(kvm-irq_lock);
 }
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 75bf72f..ceaa478 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -946,6 +946,7 @@ static struct kvm *kvm_create_vm(void)
goto out;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
INIT_HLIST_HEAD(kvm-mask_notifier_list);
+   INIT_HLIST_HEAD(kvm-irq_ack_notifier_list);
 #endif
 
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
-- 
1.6.2.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/10] Move irq routing to its own locking.

2009-07-14 Thread Gleb Natapov

Signed-off-by: Gleb Natapov g...@redhat.com
---
 include/linux/kvm_host.h |1 +
 virt/kvm/irq_comm.c  |5 ++---
 virt/kvm/kvm_main.c  |1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index b53a5b8..8ca15a0 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -167,6 +167,7 @@ struct kvm {
struct mutex irq_lock;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
struct kvm_kernel_irq_routing_entry *irq_routing;
+   spinlock_t irq_routing_lock;
struct hlist_head mask_notifier_list;
struct hlist_head irq_ack_notifier_list;
 #endif
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index ce8fcd3..3dbba41 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -350,11 +350,10 @@ int kvm_set_irq_routing(struct kvm *kvm,
++ue;
}
 
-   mutex_lock(kvm-irq_lock);
+   spin_lock(kvm-irq_routing_lock);
old = kvm-irq_routing;
rcu_assign_pointer(kvm-irq_routing, new);
-   mutex_unlock(kvm-irq_lock);
-
+   spin_unlock(kvm-irq_routing_lock);
synchronize_rcu();
 
r = 0;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ceaa478..1d70da3 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -945,6 +945,7 @@ static struct kvm *kvm_create_vm(void)
if (IS_ERR(kvm))
goto out;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
+   spin_lock_init(kvm-irq_routing_lock);
INIT_HLIST_HEAD(kvm-mask_notifier_list);
INIT_HLIST_HEAD(kvm-irq_ack_notifier_list);
 #endif
-- 
1.6.2.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/10] Unregister ack notifier callback on PIT freeing.

2009-07-14 Thread Gleb Natapov

Signed-off-by: Gleb Natapov g...@redhat.com
---
 arch/x86/kvm/i8254.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 137e548..472653c 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -672,6 +672,8 @@ void kvm_free_pit(struct kvm *kvm)
if (kvm-arch.vpit) {
kvm_unregister_irq_mask_notifier(kvm, 0,
   kvm-arch.vpit-mask_notifier);
+   kvm_unregister_irq_ack_notifier(kvm,
+   kvm-arch.vpit-pit_state.irq_ack_notifier);
mutex_lock(kvm-arch.vpit-pit_state.lock);
timer = kvm-arch.vpit-pit_state.pit_timer.timer;
hrtimer_cancel(timer);
-- 
1.6.2.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/10] Move irq notifiers lists to its own locking.

2009-07-14 Thread Gleb Natapov

Signed-off-by: Gleb Natapov g...@redhat.com
---
 include/linux/kvm_host.h |1 +
 virt/kvm/irq_comm.c  |   16 
 virt/kvm/kvm_main.c  |1 +
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 8ca15a0..4eb5c85 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -170,6 +170,7 @@ struct kvm {
spinlock_t irq_routing_lock;
struct hlist_head mask_notifier_list;
struct hlist_head irq_ack_notifier_list;
+   spinlock_t irq_notifier_list_lock;
 #endif
 
 #ifdef KVM_ARCH_WANT_MMU_NOTIFIER
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 3dbba41..59c1cde 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -191,17 +191,17 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned 
irqchip, unsigned pin)
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
   struct kvm_irq_ack_notifier *kian)
 {
-   mutex_lock(kvm-irq_lock);
+   spin_lock(kvm-irq_notifier_list_lock);
hlist_add_head_rcu(kian-link, kvm-irq_ack_notifier_list);
-   mutex_unlock(kvm-irq_lock);
+   spin_unlock(kvm-irq_notifier_list_lock);
 }
 
 void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
struct kvm_irq_ack_notifier *kian)
 {
-   mutex_lock(kvm-irq_lock);
+   spin_lock(kvm-irq_notifier_list_lock);
hlist_del_init_rcu(kian-link);
-   mutex_unlock(kvm-irq_lock);
+   spin_unlock(kvm-irq_notifier_list_lock);
synchronize_rcu();
 }
 
@@ -247,18 +247,18 @@ void kvm_free_irq_source_id(struct kvm *kvm, int 
irq_source_id)
 void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq,
struct kvm_irq_mask_notifier *kimn)
 {
-   mutex_lock(kvm-irq_lock);
+   spin_lock(kvm-irq_notifier_list_lock);
kimn-irq = irq;
hlist_add_head_rcu(kimn-link, kvm-mask_notifier_list);
-   mutex_unlock(kvm-irq_lock);
+   spin_unlock(kvm-irq_notifier_list_lock);
 }
 
 void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,
  struct kvm_irq_mask_notifier *kimn)
 {
-   mutex_lock(kvm-irq_lock);
+   spin_lock(kvm-irq_notifier_list_lock);
hlist_del_rcu(kimn-link);
-   mutex_unlock(kvm-irq_lock);
+   spin_unlock(kvm-irq_notifier_list_lock);
synchronize_rcu();
 }
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1d70da3..9553444 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -948,6 +948,7 @@ static struct kvm *kvm_create_vm(void)
spin_lock_init(kvm-irq_routing_lock);
INIT_HLIST_HEAD(kvm-mask_notifier_list);
INIT_HLIST_HEAD(kvm-irq_ack_notifier_list);
+   spin_lock_init(kvm-irq_notifier_list_lock);
 #endif
 
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
-- 
1.6.2.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/10] Move IO APIC to its own lock.

2009-07-14 Thread Gleb Natapov

Signed-off-by: Gleb Natapov g...@redhat.com
---
 arch/ia64/kvm/kvm-ia64.c |   27 ++--
 arch/x86/kvm/lapic.c |5 +---
 arch/x86/kvm/x86.c   |   30 ++-
 virt/kvm/ioapic.c|   50 -
 virt/kvm/ioapic.h|1 +
 5 files changed, 73 insertions(+), 40 deletions(-)

diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 0ad09f0..dd7ef2d 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -850,9 +850,16 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm,
 
r = 0;
switch (chip-chip_id) {
-   case KVM_IRQCHIP_IOAPIC:
-   memcpy(chip-chip.ioapic, ioapic_irqchip(kvm),
-   sizeof(struct kvm_ioapic_state));
+   case KVM_IRQCHIP_IOAPIC: {
+   struct kvm_ioapic *ioapic = ioapic_irqchip(kvm);
+   if (ioapic) {
+   spin_lock(ioapic-lock);
+   memcpy(chip-chip.ioapic, ioapic,
+  sizeof(struct kvm_ioapic_state));
+   spin_unlock(ioapic-lock);
+   } else
+   r = -EINVAL;
+   }
break;
default:
r = -EINVAL;
@@ -867,10 +874,16 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, 
struct kvm_irqchip *chip)
 
r = 0;
switch (chip-chip_id) {
-   case KVM_IRQCHIP_IOAPIC:
-   memcpy(ioapic_irqchip(kvm),
-   chip-chip.ioapic,
-   sizeof(struct kvm_ioapic_state));
+   case KVM_IRQCHIP_IOAPIC: {
+   struct kvm_ioapic *ioapic = ioapic_irqchip(kvm);
+   if (ioapic) {
+   spin_lock(ioapic-lock);
+   memcpy(ioapic, chip-chip.ioapic,
+  sizeof(struct kvm_ioapic_state));
+   spin_unlock(ioapic-lock);
+   } else
+   r = -EINVAL;
+   }
break;
default:
r = -EINVAL;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index e2e2849..61ffcfc 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -471,11 +471,8 @@ static void apic_set_eoi(struct kvm_lapic *apic)
trigger_mode = IOAPIC_LEVEL_TRIG;
else
trigger_mode = IOAPIC_EDGE_TRIG;
-   if (!(apic_get_reg(apic, APIC_SPIV)  APIC_SPIV_DIRECTED_EOI)) {
-   mutex_lock(apic-vcpu-kvm-irq_lock);
+   if (!(apic_get_reg(apic, APIC_SPIV)  APIC_SPIV_DIRECTED_EOI))
kvm_ioapic_update_eoi(apic-vcpu-kvm, vector, trigger_mode);
-   mutex_unlock(apic-vcpu-kvm-irq_lock);
-   }
 }
 
 static void apic_send_ipi(struct kvm_lapic *apic)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 48567fa..de99b84 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2010,10 +2010,16 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, 
struct kvm_irqchip *chip)
pic_irqchip(kvm)-pics[1],
sizeof(struct kvm_pic_state));
break;
-   case KVM_IRQCHIP_IOAPIC:
-   memcpy(chip-chip.ioapic,
-   ioapic_irqchip(kvm),
-   sizeof(struct kvm_ioapic_state));
+   case KVM_IRQCHIP_IOAPIC: {
+   struct kvm_ioapic *ioapic = ioapic_irqchip(kvm);
+   if (ioapic) {
+   spin_lock(ioapic-lock);
+   memcpy(chip-chip.ioapic, ioapic,
+  sizeof(struct kvm_ioapic_state));
+   spin_unlock(ioapic-lock);
+   } else
+   r = -EINVAL;
+   }
break;
default:
r = -EINVAL;
@@ -2042,12 +2048,16 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, 
struct kvm_irqchip *chip)
sizeof(struct kvm_pic_state));
spin_unlock(pic_irqchip(kvm)-lock);
break;
-   case KVM_IRQCHIP_IOAPIC:
-   mutex_lock(kvm-irq_lock);
-   memcpy(ioapic_irqchip(kvm),
-   chip-chip.ioapic,
-   sizeof(struct kvm_ioapic_state));
-   mutex_unlock(kvm-irq_lock);
+   case KVM_IRQCHIP_IOAPIC: {
+   struct kvm_ioapic *ioapic = ioapic_irqchip(kvm);
+   if (ioapic) {
+   spin_lock(ioapic-lock);
+   memcpy(ioapic, chip-chip.ioapic,
+  sizeof(struct kvm_ioapic_state));
+   spin_unlock(ioapic-lock);
+   } else
+   r = -EINVAL;
+   }
break;
default:
r = -EINVAL;
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index fa05f67..300ee3b 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ 

[PATCH 10/10] Change irq routing table to use gsi indexed array.

2009-07-14 Thread Gleb Natapov
Use gsi indexed array instead of scanning all entries on each interrupt
injection. Also maintain back mapping from irqchip/pin to gsi to speedup
interrupt acknowledgment notifications.

Signed-off-by: Gleb Natapov g...@redhat.com
---
 include/linux/kvm_host.h |   11 ++-
 virt/kvm/irq_comm.c  |   62 -
 2 files changed, 47 insertions(+), 26 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index aa64d0d..ae6cbf1 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -128,7 +128,14 @@ struct kvm_kernel_irq_routing_entry {
} irqchip;
struct msi_msg msi;
};
-   struct list_head link;
+   struct hlist_node link;
+};
+
+struct kvm_irq_routing_table {
+   int chip[3][KVM_IOAPIC_NUM_PINS];
+   struct kvm_kernel_irq_routing_entry *rt_entries;
+   u32 max_gsi;
+   struct hlist_head map[0];
 };
 
 struct kvm {
@@ -165,7 +172,7 @@ struct kvm {
 #endif
 
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
-   struct kvm_kernel_irq_routing_entry *irq_routing;
+   struct kvm_irq_routing_table *irq_routing;
spinlock_t irq_routing_lock;
struct hlist_head mask_notifier_list;
struct hlist_head irq_ack_notifier_list;
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index c54a28b..da643d4 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -125,6 +125,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int 
irq, int level)
struct kvm_kernel_irq_routing_entry *e;
unsigned long *irq_state, sig_level;
int ret = -1;
+   struct kvm_irq_routing_table *irq_rt;
+   struct hlist_node *n;
 
trace_kvm_set_irq(irq, level, irq_source_id);
 
@@ -147,14 +149,13 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int 
irq, int level)
 * writes to the unused one.
 */
rcu_read_lock();
-   for (e = rcu_dereference(kvm-irq_routing); e  e-set; e++) {
-   if (e-gsi == irq) {
-   int r = e-set(e, kvm, sig_level);
-   if (r  0)
-   continue;
+   irq_rt = rcu_dereference(kvm-irq_routing);
+   hlist_for_each_entry(e, n, irq_rt-map[irq], link) {
+   int r = e-set(e, kvm, sig_level);
+   if (r  0)
+   continue;
 
-   ret = r + ((ret  0) ? 0 : ret);
-   }
+   ret = r + ((ret  0) ? 0 : ret);
}
rcu_read_unlock();
return ret;
@@ -162,21 +163,16 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int 
irq, int level)
 
 void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
 {
-   struct kvm_kernel_irq_routing_entry *e;
struct kvm_irq_ack_notifier *kian;
struct hlist_node *n;
-   unsigned gsi = pin;
+   unsigned gsi;
 
trace_kvm_ack_irq(irqchip, pin);
 
rcu_read_lock();
-   for (e = rcu_dereference(kvm-irq_routing); e  e-set; e++) {
-   if (e-irqchip.irqchip == irqchip 
-   e-irqchip.pin == pin) {
-   gsi = e-gsi;
-   break;
-   }
-   }
+   gsi = rcu_dereference(kvm-irq_routing)-chip[irqchip][pin];
+   if (gsi == -1)
+   gsi = pin;
 
hlist_for_each_entry_rcu(kian, n, kvm-irq_ack_notifier_list, link)
if (kian-gsi == gsi)
@@ -277,7 +273,8 @@ void kvm_free_irq_routing(struct kvm *kvm)
kfree(kvm-irq_routing);
 }
 
-static int setup_routing_entry(struct kvm_kernel_irq_routing_entry *e,
+static int setup_routing_entry(struct kvm_irq_routing_table *rt,
+  struct kvm_kernel_irq_routing_entry *e,
   const struct kvm_irq_routing_entry *ue)
 {
int r = -EINVAL;
@@ -303,6 +300,7 @@ static int setup_routing_entry(struct 
kvm_kernel_irq_routing_entry *e,
}
e-irqchip.irqchip = ue-u.irqchip.irqchip;
e-irqchip.pin = ue-u.irqchip.pin + delta;
+   rt-chip[ue-u.irqchip.irqchip][e-irqchip.pin] = ue-gsi;
break;
case KVM_IRQ_ROUTING_MSI:
e-set = kvm_set_msi;
@@ -313,6 +311,8 @@ static int setup_routing_entry(struct 
kvm_kernel_irq_routing_entry *e,
default:
goto out;
}
+
+   hlist_add_head(e-link, rt-map[e-gsi]);
r = 0;
 out:
return r;
@@ -324,23 +324,37 @@ int kvm_set_irq_routing(struct kvm *kvm,
unsigned nr,
unsigned flags)
 {
-   struct kvm_kernel_irq_routing_entry *new, *old;
-   unsigned i;
+   struct kvm_irq_routing_table *new, *old;
+   u32 i, j, max_gsi = 0;
int r;
 
-   /* last elemet is left zeored and indicates the end of the array */
-   new = kzalloc(sizeof(*new) * (nr + 1), GFP_KERNEL);
+   for (i = 0; i  nr; ++i) 

[PATCH 04/10] Convert irq notifiers lists to RCU locking.

2009-07-14 Thread Gleb Natapov
Use RCU locking for mask/ack notifiers lists.

Signed-off-by: Gleb Natapov g...@redhat.com
---
 virt/kvm/irq_comm.c |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index cce32de..6c57e46 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -181,18 +181,18 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned 
irqchip, unsigned pin)
break;
}
}
-   rcu_read_unlock();
 
-   hlist_for_each_entry(kian, n, kvm-irq_ack_notifier_list, link)
+   hlist_for_each_entry_rcu(kian, n, kvm-irq_ack_notifier_list, link)
if (kian-gsi == gsi)
kian-irq_acked(kian);
+   rcu_read_unlock();
 }
 
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
   struct kvm_irq_ack_notifier *kian)
 {
mutex_lock(kvm-irq_lock);
-   hlist_add_head(kian-link, kvm-irq_ack_notifier_list);
+   hlist_add_head_rcu(kian-link, kvm-irq_ack_notifier_list);
mutex_unlock(kvm-irq_lock);
 }
 
@@ -200,8 +200,9 @@ void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
struct kvm_irq_ack_notifier *kian)
 {
mutex_lock(kvm-irq_lock);
-   hlist_del_init(kian-link);
+   hlist_del_init_rcu(kian-link);
mutex_unlock(kvm-irq_lock);
+   synchronize_rcu();
 }
 
 int kvm_request_irq_source_id(struct kvm *kvm)
@@ -248,7 +249,7 @@ void kvm_register_irq_mask_notifier(struct kvm *kvm, int 
irq,
 {
mutex_lock(kvm-irq_lock);
kimn-irq = irq;
-   hlist_add_head(kimn-link, kvm-mask_notifier_list);
+   hlist_add_head_rcu(kimn-link, kvm-mask_notifier_list);
mutex_unlock(kvm-irq_lock);
 }
 
@@ -256,8 +257,9 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int 
irq,
  struct kvm_irq_mask_notifier *kimn)
 {
mutex_lock(kvm-irq_lock);
-   hlist_del(kimn-link);
+   hlist_del_rcu(kimn-link);
mutex_unlock(kvm-irq_lock);
+   synchronize_rcu();
 }
 
 void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask)
@@ -265,11 +267,11 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, 
bool mask)
struct kvm_irq_mask_notifier *kimn;
struct hlist_node *n;
 
-   WARN_ON(!mutex_is_locked(kvm-irq_lock));
-
-   hlist_for_each_entry(kimn, n, kvm-mask_notifier_list, link)
+   rcu_read_lock();
+   hlist_for_each_entry_rcu(kimn, n, kvm-mask_notifier_list, link)
if (kimn-irq == irq)
kimn-func(kimn, mask);
+   rcu_read_unlock();
 }
 
 void kvm_free_irq_routing(struct kvm *kvm)
-- 
1.6.2.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/10] Drop kvm-irq_lock lock.

2009-07-14 Thread Gleb Natapov
The only thing it protects now is interrupt injection into lapic and
this can work lockless. Even now with kvm-irq_lock in place access
to lapic is not entirely serialized since vcpu access doesn't take
kvm-irq_lock.

Signed-off-by: Gleb Natapov g...@redhat.com
---
 arch/ia64/kvm/kvm-ia64.c |2 --
 arch/x86/kvm/i8254.c |2 --
 arch/x86/kvm/lapic.c |2 --
 arch/x86/kvm/x86.c   |2 --
 include/linux/kvm_host.h |1 -
 virt/kvm/eventfd.c   |2 --
 virt/kvm/irq_comm.c  |6 +-
 virt/kvm/kvm_main.c  |5 +
 8 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index dd7ef2d..8f1fc3a 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -998,10 +998,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
goto out;
if (irqchip_in_kernel(kvm)) {
__s32 status;
-   mutex_lock(kvm-irq_lock);
status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID,
irq_event.irq, irq_event.level);
-   mutex_unlock(kvm-irq_lock);
if (ioctl == KVM_IRQ_LINE_STATUS) {
irq_event.status = status;
if (copy_to_user(argp, irq_event,
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 59021da..211f524 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -690,10 +690,8 @@ static void __inject_pit_timer_intr(struct kvm *kvm)
struct kvm_vcpu *vcpu;
int i;
 
-   mutex_lock(kvm-irq_lock);
kvm_set_irq(kvm, kvm-arch.vpit-irq_source_id, 0, 1);
kvm_set_irq(kvm, kvm-arch.vpit-irq_source_id, 0, 0);
-   mutex_unlock(kvm-irq_lock);
 
/*
 * Provides NMI watchdog support via Virtual Wire mode.
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 61ffcfc..0380107 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -501,9 +501,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
   irq.trig_mode, irq.level, irq.dest_mode, irq.delivery_mode,
   irq.vector);
 
-   mutex_lock(apic-vcpu-kvm-irq_lock);
kvm_irq_delivery_to_apic(apic-vcpu-kvm, apic, irq);
-   mutex_unlock(apic-vcpu-kvm-irq_lock);
 }
 
 static u32 apic_get_tmcct(struct kvm_lapic *apic)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index de99b84..40adac5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2261,10 +2261,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
goto out;
if (irqchip_in_kernel(kvm)) {
__s32 status;
-   mutex_lock(kvm-irq_lock);
status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID,
irq_event.irq, irq_event.level);
-   mutex_unlock(kvm-irq_lock);
if (ioctl == KVM_IRQ_LINE_STATUS) {
irq_event.status = status;
if (copy_to_user(argp, irq_event,
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 4eb5c85..aa64d0d 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -164,7 +164,6 @@ struct kvm {
struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
 #endif
 
-   struct mutex irq_lock;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
struct kvm_kernel_irq_routing_entry *irq_routing;
spinlock_t irq_routing_lock;
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 99017e8..95954ad 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -61,10 +61,8 @@ irqfd_inject(struct work_struct *work)
struct _irqfd *irqfd = container_of(work, struct _irqfd, inject);
struct kvm *kvm = irqfd-kvm;
 
-   mutex_lock(kvm-irq_lock);
kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd-gsi, 1);
kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd-gsi, 0);
-   mutex_unlock(kvm-irq_lock);
 }
 
 /*
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 59c1cde..c54a28b 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -63,8 +63,6 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct 
kvm_lapic *src,
int i, r = -1;
struct kvm_vcpu *vcpu, *lowest = NULL;
 
-   WARN_ON(!mutex_is_locked(kvm-irq_lock));
-
if (irq-dest_mode == 0  irq-dest_id == 0xff 
kvm_is_dm_lowest_prio(irq))
printk(KERN_INFO kvm: apic: phys broadcast and lowest prio\n);
@@ -116,7 +114,7 @@ static int kvm_set_msi(struct kvm_kernel_irq_routing_entry 
*e,
return kvm_irq_delivery_to_apic(kvm, NULL, irq);
 }
 
-/* This should be called with the kvm-irq_lock mutex held
+/*
  * Return value:
  *   0   Interrupt was ignored (masked or not delivered for other reasons)
  *  = 0   Interrupt 

[PATCH 05/10] Protect irq_sources_bitmap by kvm-lock instead of kvm-irq_lock

2009-07-14 Thread Gleb Natapov
It is already protected by kvm-lock on device assignment path. Just
take the same lock in the PIT code.

Signed-off-by: Gleb Natapov g...@redhat.com
---
 arch/x86/kvm/i8254.c |2 ++
 virt/kvm/irq_comm.c  |8 
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 472653c..59021da 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -611,7 +611,9 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
if (!pit)
return NULL;
 
+   mutex_lock(kvm-lock);
pit-irq_source_id = kvm_request_irq_source_id(kvm);
+   mutex_unlock(kvm-lock);
if (pit-irq_source_id  0) {
kfree(pit);
return NULL;
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 6c57e46..ce8fcd3 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -210,7 +210,8 @@ int kvm_request_irq_source_id(struct kvm *kvm)
unsigned long *bitmap = kvm-arch.irq_sources_bitmap;
int irq_source_id;
 
-   mutex_lock(kvm-irq_lock);
+   WARN_ON(!mutex_is_locked(kvm-lock));
+
irq_source_id = find_first_zero_bit(bitmap,
sizeof(kvm-arch.irq_sources_bitmap));
 
@@ -221,7 +222,6 @@ int kvm_request_irq_source_id(struct kvm *kvm)
 
ASSERT(irq_source_id != KVM_USERSPACE_IRQ_SOURCE_ID);
set_bit(irq_source_id, bitmap);
-   mutex_unlock(kvm-irq_lock);
 
return irq_source_id;
 }
@@ -230,9 +230,10 @@ void kvm_free_irq_source_id(struct kvm *kvm, int 
irq_source_id)
 {
int i;
 
+   /* during vm destruction this function is called without locking */
+   WARN_ON(!mutex_is_locked(kvm-lock)  atomic_read(kvm-users_count));
ASSERT(irq_source_id != KVM_USERSPACE_IRQ_SOURCE_ID);
 
-   mutex_lock(kvm-irq_lock);
if (irq_source_id  0 ||
irq_source_id = sizeof(kvm-arch.irq_sources_bitmap)) {
printk(KERN_ERR kvm: IRQ source ID out of range!\n);
@@ -241,7 +242,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int 
irq_source_id)
for (i = 0; i  KVM_IOAPIC_NUM_PINS; i++)
clear_bit(irq_source_id, kvm-arch.irq_states[i]);
clear_bit(irq_source_id, kvm-arch.irq_sources_bitmap);
-   mutex_unlock(kvm-irq_lock);
 }
 
 void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq,
-- 
1.6.2.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [autotest] [PATCH 6/6] add-disktest-stress-ebizzy-entry-in-kvm-sample-config

2009-07-14 Thread Lucas Meneghel Rodrigues
On Wed, Jul 8, 2009 at 5:36 AM, sudhir kumarsmalik...@gmail.com wrote:
 This patch adds the test entries in the sample config file for kvm
 test execution.

Looks good. Applied.

 Signed-off-by: Sudhir Kumar sku...@linux.vnet.ibm.com

 Index: autotest/client/tests/kvm/kvm_tests.cfg.sample
 ===
 --- autotest.orig/client/tests/kvm/kvm_tests.cfg.sample
 +++ autotest/client/tests/kvm/kvm_tests.cfg.sample
 @@ -79,6 +79,15 @@ variants:
             - bonnie:
                 test_name = bonnie
                 test_control_file = bonnie.control
 +            - ebizzy:
 +                test_name = ebizzy
 +                test_control_file = ebizzy.control
 +            - stress:
 +                test_name = stress
 +                test_control_file = stress.control
 +            - disktest:
 +                test_name = disktest
 +                test_control_file = disktest.control

     - linux_s3:      install setup
         type = linux_s3


 --
 Sudhir Kumar
 ___
 Autotest mailing list
 autot...@test.kernel.org
 http://test.kernel.org/cgi-bin/mailman/listinfo/autotest




-- 
Lucas Meneghel
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/8] Do not compile qemu-kvm.c and qemu-kvm-x86.c

2009-07-14 Thread Glauber Costa
Instead, include them from upstream files

Signed-off-by: Glauber Costa glom...@redhat.com
---
 Makefile.target   |5 ++---
 kvm-all.c |2 ++
 target-i386/kvm.c |2 ++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index e0edd27..df1f32b 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -160,7 +160,6 @@ ifeq ($(ARCH),sparc64)
 CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
 endif
 
-libobj-$(CONFIG_KVM) += qemu-kvm.o
 ifdef CONFIG_SOFTFLOAT
 libobj-y += fpu/softfloat.o
 else
@@ -171,13 +170,13 @@ libobj-y += op_helper.o helper.o
 
 ifeq ($(TARGET_ARCH), i386)
 libobj-y += helper.o
-libobj-$(CONFIG_KVM) += qemu-kvm-x86.o kvm-tpr-opt.o
+libobj-$(CONFIG_KVM) += kvm-tpr-opt.o
 libobj-$(CONFIG_KVM) += qemu-kvm-helper.o
 endif
 
 ifeq ($(TARGET_ARCH), x86_64)
 libobj-y += helper.o
-libobj-$(CONFIG_KVM) += qemu-kvm-x86.o kvm-tpr-opt.o
+libobj-$(CONFIG_KVM) += kvm-tpr-opt.o
 libobj-$(CONFIG_KVM) += qemu-kvm-helper.o
 endif
 
diff --git a/kvm-all.c b/kvm-all.c
index 4c2fdf5..e42b1f6 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1029,3 +1029,5 @@ void kvm_remove_all_breakpoints(CPUState *current_env)
 }
 #endif /* !KVM_CAP_SET_GUEST_DEBUG */
 #endif
+
+#include qemu-kvm.c
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index b7eb096..cfa5b80 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -964,3 +964,5 @@ void kvm_arch_update_guest_debug(CPUState *env, struct 
kvm_guest_debug *dbg)
 }
 #endif /* KVM_CAP_SET_GUEST_DEBUG */
 #endif
+
+#include qemu-kvm-x86.c
-- 
1.6.2.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/8] Move closer to upstream

2009-07-14 Thread Glauber Costa
Same thing that was already sent, but rebased for today's tree.
Avi suggested me to just keep the include for libkvm-all.h and he
would fold it manually.

Note that I'm _not_ doing this here, because marcelo, who is less
bright than avi, seem to prefer me to do this way.

If applied on top of today's tree with no modifications, it should
have no conflicts.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 6/8] provide env-kvm_fd

2009-07-14 Thread Glauber Costa
qemu upstream puts kvm information on env. Do that too, since it will
allow us to use CPUState in cpu-specific functions, instead of kvm-specific
types.

Signed-off-by: Glauber Costa glom...@redhat.com
---
 qemu-kvm.c |9 +++--
 qemu-kvm.h |2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 45f5abe..6897e3c 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -503,11 +503,12 @@ void kvm_disable_pit_creation(kvm_context_t kvm)
kvm-no_pit_creation = 1;
 }
 
-kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int id)
+kvm_vcpu_context_t kvm_create_vcpu(CPUState *env, int id)
 {
long mmap_size;
int r;
kvm_vcpu_context_t vcpu_ctx = qemu_malloc(sizeof(struct 
kvm_vcpu_context));
+kvm_context_t kvm = kvm_context;
 
vcpu_ctx-kvm = kvm;
vcpu_ctx-id = id;
@@ -518,6 +519,10 @@ kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int 
id)
goto err;
}
vcpu_ctx-fd = r;
+
+env-kvm_fd = r;
+env-kvm_state = kvm_state;
+
mmap_size = ioctl(kvm-fd, KVM_GET_VCPU_MMAP_SIZE, 0);
if (mmap_size == -1) {
fprintf(stderr, get vcpu mmap size: %m\n);
@@ -2013,7 +2018,7 @@ static void *ap_main_loop(void *_env)
 env-thread_id = kvm_get_thread_id();
 sigfillset(signals);
 sigprocmask(SIG_BLOCK, signals, NULL);
-env-kvm_cpu_state.vcpu_ctx = kvm_create_vcpu(kvm_context, env-cpu_index);
+env-kvm_cpu_state.vcpu_ctx = kvm_create_vcpu(env, env-cpu_index);
 
 #ifdef USE_KVM_DEVICE_ASSIGNMENT
 /* do ioperm for io ports of assigned devices */
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 5d2d54c..f43 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -181,7 +181,7 @@ void kvm_create_irqchip(kvm_context_t kvm);
  * \param slot vcpu number ( 0)
  * \return 0 on success, -errno on failure
  */
-kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int id);
+kvm_vcpu_context_t kvm_create_vcpu(CPUState *env, int id);
 
 /*!
  * \brief Start the VCPU
-- 
1.6.2.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 5/8] duplicate KVMState

2009-07-14 Thread Glauber Costa
In this patch, we duplicate most of KVMState in our files. This should be
removed later, when they are 100 % equal. Meanwhile, we fold our kvm_context_t
structure inside it.

To make transition smooth, we still keep a global variable kvm_context
pointing to its position inside the global KVMState. This way we don't
need to hurry about changing all callers.

kvm_init() and kvm_finalize are changed, though, since they have now to
deal with the creation/destruction of a global KVMState

Signed-off-by: Glauber Costa glom...@redhat.com
---
 qemu-kvm.c |   61 +++
 qemu-kvm.h |   36 +++---
 vl.c   |2 +-
 3 files changed, 53 insertions(+), 46 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 43e7b4c..45f5abe 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -42,6 +42,9 @@ int kvm_irqchip = 1;
 int kvm_pit = 1;
 int kvm_pit_reinject = 1;
 int kvm_nested = 0;
+
+
+static KVMState *kvm_state;
 kvm_context_t kvm_context;
 
 pthread_mutex_t qemu_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -416,16 +419,16 @@ int kvm_dirty_pages_log_reset(kvm_context_t kvm)
 }
 
 
-kvm_context_t kvm_init(void *opaque)
+int kvm_init(int smp_cpus)
 {
int fd;
-   kvm_context_t kvm;
int r, gsi_count;
 
+
fd = open(/dev/kvm, O_RDWR);
if (fd == -1) {
perror(open /dev/kvm);
-   return NULL;
+   return -1;
}
r = ioctl(fd, KVM_GET_API_VERSION, 0);
if (r == -1) {
@@ -446,35 +449,39 @@ kvm_context_t kvm_init(void *opaque)
}
kvm_abi = r;
kvm_page_size = getpagesize();
-   kvm = qemu_mallocz(sizeof(*kvm));
-   kvm-fd = fd;
-   kvm-vm_fd = -1;
-   kvm-opaque = opaque;
-   kvm-dirty_pages_log_all = 0;
-   kvm-no_irqchip_creation = 0;
-   kvm-no_pit_creation = 0;
+   kvm_state = qemu_mallocz(sizeof(*kvm_state));
+kvm_context = kvm_state-kvm_context;
 
-   gsi_count = kvm_get_gsi_count(kvm);
+   kvm_context-fd = fd;
+   kvm_context-vm_fd = -1;
+   kvm_context-opaque = cpu_single_env;
+   kvm_context-dirty_pages_log_all = 0;
+   kvm_context-no_irqchip_creation = 0;
+   kvm_context-no_pit_creation = 0;
+
+   gsi_count = kvm_get_gsi_count(kvm_context);
if (gsi_count  0) {
int gsi_bits, i;
 
/* Round up so we can search ints using ffs */
gsi_bits = ALIGN(gsi_count, 32);
-   kvm-used_gsi_bitmap = qemu_mallocz(gsi_bits / 8);
-   kvm-max_gsi = gsi_bits;
+   kvm_context-used_gsi_bitmap = qemu_mallocz(gsi_bits / 8);
+   kvm_context-max_gsi = gsi_bits;
 
/* Mark any over-allocated bits as already in use */
for (i = gsi_count; i  gsi_bits; i++)
-   set_gsi(kvm, i);
+   set_gsi(kvm_context, i);
}
 
-   return kvm;
+pthread_mutex_lock(qemu_mutex);
+   return 0;
+
  out_close:
close(fd);
-   return NULL;
+   return -1;
 }
 
-void kvm_finalize(kvm_context_t kvm)
+static void kvm_finalize(KVMState *s)
 {
/* FIXME
if (kvm-vcpu_fd[0] != -1)
@@ -482,8 +489,8 @@ void kvm_finalize(kvm_context_t kvm)
if (kvm-vm_fd != -1)
close(kvm-vm_fd);
*/
-   close(kvm-fd);
-   free(kvm);
+   close(s-kvm_context.fd);
+   free(s);
 }
 
 void kvm_disable_irqchip_creation(kvm_context_t kvm)
@@ -2217,18 +2224,6 @@ int kvm_main_loop(void)
 return 0;
 }
 
-int kvm_qemu_init()
-{
-/* Try to initialize kvm */
-kvm_context = kvm_init(cpu_single_env);
-if (!kvm_context) {
-   return -1;
-}
-pthread_mutex_lock(qemu_mutex);
-
-return 0;
-}
-
 #ifdef TARGET_I386
 static int destroy_region_works = 0;
 #endif
@@ -2252,12 +2247,12 @@ int kvm_qemu_create_context(void)
 kvm_disable_pit_creation(kvm_context);
 }
 if (kvm_create(kvm_context, 0, NULL)  0) {
-   kvm_finalize(kvm_context);
+   kvm_finalize(kvm_state);
return -1;
 }
 r = kvm_arch_qemu_create_context();
 if(r 0)
-   kvm_finalize(kvm_context);
+   kvm_finalize(kvm_state);
 if (kvm_pit  !kvm_pit_reinject) {
 if (kvm_reinject_control(kvm_context, 0)) {
 fprintf(stderr, failure to disable in-kernel PIT reinjection\n);
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 20993f6..5d2d54c 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -128,18 +128,7 @@ int kvm_set_msrs(kvm_vcpu_context_t, struct kvm_msr_entry 
*msrs, int n);
  * \param opaque Not used
  * \return NULL on failure
  */
-kvm_context_t kvm_init(void *opaque);
-
-/*!
- * \brief Cleanup the KVM context
- *
- * Should always be called when closing down KVM.\n
- * Exception: If kvm_init() fails, this function should not be called, as the
- * context would be invalid
- *
- * \param kvm Pointer to the kvm_context that is to be freed
- */
-void 

[PATCH v3 7/8] use kvm_upstream sw_breakpoints structure

2009-07-14 Thread Glauber Costa
Signed-off-by: Glauber Costa glom...@redhat.com
---
 qemu-kvm-x86.c |4 ++--
 qemu-kvm.c |   27 ++-
 qemu-kvm.h |9 ++---
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index b531ca4..3bbb9d2 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1519,7 +1519,7 @@ int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info)
break;
}
}
-} else if (kvm_find_sw_breakpoint(arch_info-pc))
+} else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info-pc))
handle = 1;
 
 if (!handle)
@@ -1542,7 +1542,7 @@ void kvm_arch_update_guest_debug(CPUState *env, struct 
kvm_guest_debug *dbg)
 };
 int n;
 
-if (!TAILQ_EMPTY(kvm_sw_breakpoints))
+if (kvm_sw_breakpoints_active(env))
dbg-control |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP;
 
 if (nb_hw_breakpoint  0) {
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 6897e3c..b0661b6 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -459,6 +459,10 @@ int kvm_init(int smp_cpus)
kvm_context-no_irqchip_creation = 0;
kvm_context-no_pit_creation = 0;
 
+#ifdef KVM_CAP_SET_GUEST_DEBUG
+TAILQ_INIT(kvm_state-kvm_sw_breakpoints);
+#endif
+
gsi_count = kvm_get_gsi_count(kvm_context);
if (gsi_count  0) {
int gsi_bits, i;
@@ -2439,14 +2443,13 @@ int kvm_qemu_init_env(CPUState *cenv)
 }
 
 #ifdef KVM_CAP_SET_GUEST_DEBUG
-struct kvm_sw_breakpoint_head kvm_sw_breakpoints =
-TAILQ_HEAD_INITIALIZER(kvm_sw_breakpoints);
 
-struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(target_ulong pc)
+struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
+ target_ulong pc)
 {
 struct kvm_sw_breakpoint *bp;
 
-TAILQ_FOREACH(bp, kvm_sw_breakpoints, entry) {
+TAILQ_FOREACH(bp, env-kvm_state-kvm_sw_breakpoints, entry) {
if (bp-pc == pc)
return bp;
 }
@@ -2481,6 +2484,11 @@ int kvm_update_guest_debug(CPUState *env, unsigned long 
reinject_trap)
 return data.err;
 }
 
+int kvm_sw_breakpoints_active(CPUState *env)
+{
+return !TAILQ_EMPTY(env-kvm_state-kvm_sw_breakpoints);
+}
+
 int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
   target_ulong len, int type)
 {
@@ -2489,7 +2497,7 @@ int kvm_insert_breakpoint(CPUState *current_env, 
target_ulong addr,
 int err;
 
 if (type == GDB_BREAKPOINT_SW) {
-   bp = kvm_find_sw_breakpoint(addr);
+   bp = kvm_find_sw_breakpoint(current_env, addr);
if (bp) {
bp-use_count++;
return 0;
@@ -2507,7 +2515,8 @@ int kvm_insert_breakpoint(CPUState *current_env, 
target_ulong addr,
return err;
}
 
-   TAILQ_INSERT_HEAD(kvm_sw_breakpoints, bp, entry);
+TAILQ_INSERT_HEAD(current_env-kvm_state-kvm_sw_breakpoints,
+  bp, entry);
 } else {
err = kvm_arch_insert_hw_breakpoint(addr, len, type);
if (err)
@@ -2530,7 +2539,7 @@ int kvm_remove_breakpoint(CPUState *current_env, 
target_ulong addr,
 int err;
 
 if (type == GDB_BREAKPOINT_SW) {
-   bp = kvm_find_sw_breakpoint(addr);
+   bp = kvm_find_sw_breakpoint(current_env, addr);
if (!bp)
return -ENOENT;
 
@@ -2543,7 +2552,7 @@ int kvm_remove_breakpoint(CPUState *current_env, 
target_ulong addr,
if (err)
return err;
 
-   TAILQ_REMOVE(kvm_sw_breakpoints, bp, entry);
+   TAILQ_REMOVE(current_env-kvm_state-kvm_sw_breakpoints, bp, entry);
qemu_free(bp);
 } else {
err = kvm_arch_remove_hw_breakpoint(addr, len, type);
@@ -2564,7 +2573,7 @@ void kvm_remove_all_breakpoints(CPUState *current_env)
 struct kvm_sw_breakpoint *bp, *next;
 CPUState *env;
 
-TAILQ_FOREACH_SAFE(bp, kvm_sw_breakpoints, entry, next) {
+TAILQ_FOREACH_SAFE(bp, current_env-kvm_state-kvm_sw_breakpoints, entry, 
next) {
 if (kvm_arch_remove_sw_breakpoint(current_env, bp) != 0) {
 /* Try harder to find a CPU that currently sees the breakpoint. */
 for (env = first_cpu; env != NULL; env = env-next_cpu) {
diff --git a/qemu-kvm.h b/qemu-kvm.h
index f43..d5291a3 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -1004,12 +1004,12 @@ struct kvm_sw_breakpoint {
 int use_count;
 TAILQ_ENTRY(kvm_sw_breakpoint) entry;
 };
-TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint);
 
-extern struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
+TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint);
 
 int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info);
-struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(target_ulong pc);
+int kvm_sw_breakpoints_active(CPUState *env);
+struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env, target_ulong 
pc);
 int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
   struct kvm_sw_breakpoint *bp);
 int 

[PATCH v3 8/8] reuse upstream breakpoint code

2009-07-14 Thread Glauber Costa
Drop KVM_UPSTREAM around functions we intend to reuse.
This allow us to share code in kvm-all.c, that is equal in qemu-kvm.c

Signed-off-by: Glauber Costa glom...@redhat.com
CC: Jan Kiszka jan.kis...@siemens.com
---
 kvm-all.c  |5 ++-
 kvm.h  |1 +
 qemu-kvm.c |  140 +---
 3 files changed, 6 insertions(+), 140 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index e42b1f6..67908a7 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -873,6 +873,8 @@ void kvm_setup_guest_memory(void *start, size_t size)
 }
 }
 
+#endif /* KVM_UPSTREAM */
+
 #ifdef KVM_CAP_SET_GUEST_DEBUG
 struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
  target_ulong pc)
@@ -891,6 +893,7 @@ int kvm_sw_breakpoints_active(CPUState *env)
 return !TAILQ_EMPTY(env-kvm_state-kvm_sw_breakpoints);
 }
 
+#ifdef KVM_UPSTREAM
 int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap)
 {
 struct kvm_guest_debug dbg;
@@ -904,6 +907,7 @@ int kvm_update_guest_debug(CPUState *env, unsigned long 
reinject_trap)
 
 return kvm_vcpu_ioctl(env, KVM_SET_GUEST_DEBUG, dbg);
 }
+#endif
 
 int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
   target_ulong len, int type)
@@ -1028,6 +1032,5 @@ void kvm_remove_all_breakpoints(CPUState *current_env)
 {
 }
 #endif /* !KVM_CAP_SET_GUEST_DEBUG */
-#endif
 
 #include qemu-kvm.c
diff --git a/kvm.h b/kvm.h
index e9a43e2..0191752 100644
--- a/kvm.h
+++ b/kvm.h
@@ -16,6 +16,7 @@
 
 #include config.h
 #include sys-queue.h
+#include qemu-kvm.h
 
 #ifdef KVM_UPSTREAM
 
diff --git a/qemu-kvm.c b/qemu-kvm.c
index b0661b6..355adf4 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -2444,18 +2444,6 @@ int kvm_qemu_init_env(CPUState *cenv)
 
 #ifdef KVM_CAP_SET_GUEST_DEBUG
 
-struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
- target_ulong pc)
-{
-struct kvm_sw_breakpoint *bp;
-
-TAILQ_FOREACH(bp, env-kvm_state-kvm_sw_breakpoints, entry) {
-   if (bp-pc == pc)
-   return bp;
-}
-return NULL;
-}
-
 struct kvm_set_guest_debug_data {
 struct kvm_guest_debug dbg;
 int err;
@@ -2484,133 +2472,7 @@ int kvm_update_guest_debug(CPUState *env, unsigned long 
reinject_trap)
 return data.err;
 }
 
-int kvm_sw_breakpoints_active(CPUState *env)
-{
-return !TAILQ_EMPTY(env-kvm_state-kvm_sw_breakpoints);
-}
-
-int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
-  target_ulong len, int type)
-{
-struct kvm_sw_breakpoint *bp;
-CPUState *env;
-int err;
-
-if (type == GDB_BREAKPOINT_SW) {
-   bp = kvm_find_sw_breakpoint(current_env, addr);
-   if (bp) {
-   bp-use_count++;
-   return 0;
-   }
-
-   bp = qemu_malloc(sizeof(struct kvm_sw_breakpoint));
-   if (!bp)
-   return -ENOMEM;
-
-   bp-pc = addr;
-   bp-use_count = 1;
-   err = kvm_arch_insert_sw_breakpoint(current_env, bp);
-   if (err) {
-   free(bp);
-   return err;
-   }
-
-TAILQ_INSERT_HEAD(current_env-kvm_state-kvm_sw_breakpoints,
-  bp, entry);
-} else {
-   err = kvm_arch_insert_hw_breakpoint(addr, len, type);
-   if (err)
-   return err;
-}
-
-for (env = first_cpu; env != NULL; env = env-next_cpu) {
-   err = kvm_update_guest_debug(env, 0);
-   if (err)
-   return err;
-}
-return 0;
-}
-
-int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
-  target_ulong len, int type)
-{
-struct kvm_sw_breakpoint *bp;
-CPUState *env;
-int err;
-
-if (type == GDB_BREAKPOINT_SW) {
-   bp = kvm_find_sw_breakpoint(current_env, addr);
-   if (!bp)
-   return -ENOENT;
-
-   if (bp-use_count  1) {
-   bp-use_count--;
-   return 0;
-   }
-
-   err = kvm_arch_remove_sw_breakpoint(current_env, bp);
-   if (err)
-   return err;
-
-   TAILQ_REMOVE(current_env-kvm_state-kvm_sw_breakpoints, bp, entry);
-   qemu_free(bp);
-} else {
-   err = kvm_arch_remove_hw_breakpoint(addr, len, type);
-   if (err)
-   return err;
-}
-
-for (env = first_cpu; env != NULL; env = env-next_cpu) {
-   err = kvm_update_guest_debug(env, 0);
-   if (err)
-   return err;
-}
-return 0;
-}
-
-void kvm_remove_all_breakpoints(CPUState *current_env)
-{
-struct kvm_sw_breakpoint *bp, *next;
-CPUState *env;
-
-TAILQ_FOREACH_SAFE(bp, current_env-kvm_state-kvm_sw_breakpoints, entry, 
next) {
-if (kvm_arch_remove_sw_breakpoint(current_env, bp) != 0) {
-/* Try harder to find a CPU that currently sees the breakpoint. */
-for (env = first_cpu; env != NULL; env = env-next_cpu) {
-if (kvm_arch_remove_sw_breakpoint(env, bp) == 0)
-

Re: [PATCHv3 RFC] uio: add generic driver for PCI 2.3 devices

2009-07-14 Thread Chris Wright
* Michael S. Tsirkin (m...@redhat.com) wrote:
 - remove irqcontrol: user can enable interrupts by
   writing command register directly

Sorry if I gave you the impression that removing was needed.
I actually think the irqcontrol was useful since it's atomic.

 + gdev-info.name = uio_pci_generic;
 + gdev-info.version = 0.01;

Minor nit: DRIVER_VERSION

Otherwise, it looks good.

thanks,

-chris
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 RFC] uio: add generic driver for PCI 2.3 devices

2009-07-14 Thread Michael S. Tsirkin
On Tue, Jul 14, 2009 at 11:03:38AM -0700, Chris Wright wrote:
 * Michael S. Tsirkin (m...@redhat.com) wrote:
  - remove irqcontrol: user can enable interrupts by
writing command register directly
 
 Sorry if I gave you the impression that removing was needed.
 I actually think the irqcontrol was useful since it's atomic.

What I'm saying, it is not strictly needed (user can safely write 0 in
that register and worst case you just get an extra interrupt).  So let's
make the decision on what does irqcontrol do when we have a pressing
need for an extra kernel/user interface.

  +   gdev-info.name = uio_pci_generic;
  +   gdev-info.version = 0.01;
 
 Minor nit: DRIVER_VERSION

Ack.

 Otherwise, it looks good.
 
 thanks,
 
 -chris

Thanks!
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 8/8] reuse upstream breakpoint code

2009-07-14 Thread Jan Kiszka
Glauber Costa wrote:
 Drop KVM_UPSTREAM around functions we intend to reuse.
 This allow us to share code in kvm-all.c, that is equal in qemu-kvm.c
 
 Signed-off-by: Glauber Costa glom...@redhat.com
 CC: Jan Kiszka jan.kis...@siemens.com

Looks good (and demonstrates nicely how we can merge things in the ideal
case).

Jan



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3 8/8] reuse upstream breakpoint code

2009-07-14 Thread Glauber Costa
On Tue, Jul 14, 2009 at 10:45:22PM +0200, Jan Kiszka wrote:
 Glauber Costa wrote:
  Drop KVM_UPSTREAM around functions we intend to reuse.
  This allow us to share code in kvm-all.c, that is equal in qemu-kvm.c
  
  Signed-off-by: Glauber Costa glom...@redhat.com
  CC: Jan Kiszka jan.kis...@siemens.com
 
 Looks good (and demonstrates nicely how we can merge things in the ideal
 case).
neat.
As per gleb suggestion, I also posted to qemu a patch that gives us on_vcpu().
We can share more code, once it is there.

Marcelo, can you please merge it?

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 8/8] reuse upstream breakpoint code

2009-07-14 Thread Marcelo Tosatti
On Tue, Jul 14, 2009 at 06:01:48PM -0300, Glauber Costa wrote:
 On Tue, Jul 14, 2009 at 10:45:22PM +0200, Jan Kiszka wrote:
  Glauber Costa wrote:
   Drop KVM_UPSTREAM around functions we intend to reuse.
   This allow us to share code in kvm-all.c, that is equal in qemu-kvm.c
   
   Signed-off-by: Glauber Costa glom...@redhat.com
   CC: Jan Kiszka jan.kis...@siemens.com
  
  Looks good (and demonstrates nicely how we can merge things in the ideal
  case).
 neat.
 As per gleb suggestion, I also posted to qemu a patch that gives us on_vcpu().
 We can share more code, once it is there.
 
 Marcelo, can you please merge it?

Patches 6 and 7 contain some tab breakage, is that intentional? 
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Support shared memory device PCI device

2009-07-14 Thread Cam Macdonell
This patch is an updated version of a previous one 
(http://patchwork.kernel.org/patch/22363/) that supports adding a shared memory 
PCI device.  To be clear, there is no new functionality in this patch, just a 
fix for changes to the master branch.

The device's memory is mappable into user-level to provide zero-copy messaging 
between guest and between guest and host.  Please see previous patch for a more 
detailed description.

---
 Makefile.target |3 +
 hw/ivshmem.c|  421 +++
 hw/pc.c |6 +
 hw/pc.h |3 +
 qemu-options.hx |   14 ++
 sysemu.h|8 +
 vl.c|   14 ++
 7 files changed, 469 insertions(+), 0 deletions(-)
 create mode 100644 hw/ivshmem.c

diff --git a/Makefile.target b/Makefile.target
index 660a855..323a935 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -611,6 +611,9 @@ obj-y += pcnet.o
 obj-y += rtl8139.o
 obj-y += e1000.o
 
+# Inter-VM PCI shared memory
+obj-y += ivshmem.o
+
 # Generic watchdog support and some watchdog devices
 obj-y += wdt_ib700.o wdt_i6300esb.o
 
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
new file mode 100644
index 000..8b66d0f
--- /dev/null
+++ b/hw/ivshmem.c
@@ -0,0 +1,421 @@
+/*
+ * Inter-VM Shared Memory PCI device.
+ *
+ * Author:
+ *  Cam Macdonell c...@cs.ualberta.ca
+ *
+ * Based On: cirrus_vga.c and rtl8139.c
+ *
+ * This code is licensed under the GNU GPL v2.
+ */
+
+#include hw.h
+#include console.h
+#include pc.h
+#include pci.h
+#include sysemu.h
+
+#include qemu-common.h
+#include sys/mman.h
+
+#define PCI_COMMAND_IOACCESS0x0001
+#define PCI_COMMAND_MEMACCESS   0x0002
+#define PCI_COMMAND_BUSMASTER   0x0004
+
+//#define DEBUG_IVSHMEM
+
+#ifdef DEBUG_IVSHMEM
+#define IVSHMEM_DPRINTF(fmt, args...)\
+do {printf(IVSHMEM:  fmt, ##args); } while (0)
+#else
+#define IVSHMEM_DPRINTF(fmt, args...)
+#endif
+
+typedef struct IVShmemState {
+uint16_t intrmask;
+uint16_t intrstatus;
+uint16_t doorbell;
+uint8_t *ivshmem_ptr;
+unsigned long ivshmem_offset;
+unsigned int ivshmem_size;
+unsigned long bios_offset;
+unsigned int bios_size;
+target_phys_addr_t base_ctrl;
+int it_shift;
+PCIDevice *pci_dev;
+CharDriverState * chr;
+unsigned long map_addr;
+unsigned long map_end;
+int ivshmem_mmio_io_addr;
+} IVShmemState;
+
+typedef struct PCI_IVShmemState {
+PCIDevice dev;
+IVShmemState ivshmem_state;
+} PCI_IVShmemState;
+
+typedef struct IVShmemDesc {
+char name[1024];
+char * chrdev;
+int size;
+} IVShmemDesc;
+
+
+/* registers for the Inter-VM shared memory device */
+enum ivshmem_registers {
+IntrMask = 0,
+IntrStatus = 16,
+Doorbell = 32
+};
+
+static int num_ivshmem_devices = 0;
+static IVShmemDesc ivshmem_desc;
+
+static void ivshmem_map(PCIDevice *pci_dev, int region_num,
+uint32_t addr, uint32_t size, int type)
+{
+PCI_IVShmemState *d = (PCI_IVShmemState *)pci_dev;
+IVShmemState *s = d-ivshmem_state;
+
+IVSHMEM_DPRINTF(addr = %u size = %u\n, addr, size);
+cpu_register_physical_memory(addr, s-ivshmem_size, s-ivshmem_offset);
+
+}
+
+void ivshmem_init(const char * optarg) {
+
+char * temp;
+char * ivshmem_sz;
+int size;
+
+num_ivshmem_devices++;
+
+/* currently we only support 1 device */
+if (num_ivshmem_devices  MAX_IVSHMEM_DEVICES) {
+return;
+}
+
+temp = strdup(optarg);
+snprintf(ivshmem_desc.name, 1024, /%s, strsep(temp,,));
+ivshmem_sz=strsep(temp,,);
+if (ivshmem_sz != NULL){
+size = atol(ivshmem_sz);
+} else {
+size = -1;
+}
+
+ivshmem_desc.chrdev = strsep(temp,\0);
+
+if ( size == -1) {
+ivshmem_desc.size = TARGET_PAGE_SIZE;
+} else {
+ivshmem_desc.size = size*1024*1024;
+}
+IVSHMEM_DPRINTF(optarg is %s, name is %s, size is %d, chrdev is %s\n,
+optarg, ivshmem_desc.name,
+ivshmem_desc.size, 
ivshmem_desc.chrdev);
+}
+
+int ivshmem_get_size(void) {
+return ivshmem_desc.size;
+}
+
+/* accessing registers - based on rtl8139 */
+static void ivshmem_update_irq(IVShmemState *s)
+{
+int isr;
+isr = (s-intrstatus  s-intrmask)  0x;
+
+/* don't print ISR resets */
+if (isr) {
+IVSHMEM_DPRINTF(Set IRQ to %d (%04x %04x)\n,
+   isr ? 1 : 0, s-intrstatus, s-intrmask);
+}
+
+qemu_set_irq(s-pci_dev-irq[0], (isr != 0));
+}
+
+static void ivshmem_mmio_map(PCIDevice *pci_dev, int region_num,
+   uint32_t addr, uint32_t size, int type)
+{
+PCI_IVShmemState *d = (PCI_IVShmemState *)pci_dev;
+IVShmemState *s = d-ivshmem_state;
+
+cpu_register_physical_memory(addr + 0, 0x100, s-ivshmem_mmio_io_addr);
+}
+
+static void ivshmem_IntrMask_write(IVShmemState *s, uint32_t val)
+{
+IVSHMEM_DPRINTF(IntrMask write(w) val = 

Re: [PATCH] qemu-kvm: x86: fix memleak if ioctl fails

2009-07-14 Thread Marcelo Tosatti
On Mon, Jul 13, 2009 at 02:18:50PM +0530, Amit Shah wrote:
 Fix a memleak when the KVM_SET_CPUID2 ioctl fails. Free the
 memory that we allocate to store cpuids.
 
 Reported-by: Mark McLoughlin mar...@redhat.com
 Signed-off-by: Amit Shah amit.s...@redhat.com
 ---
  qemu-kvm-x86.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
 index daf60b6..ede9add 100644
 --- a/qemu-kvm-x86.c
 +++ b/qemu-kvm-x86.c
 @@ -551,7 +551,7 @@ int kvm_setup_cpuid2(kvm_vcpu_context_t vcpu, int nent,
   r = ioctl(vcpu-fd, KVM_SET_CPUID2, cpuid);
   if (r == -1) {
   fprintf(stderr, kvm_setup_cpuid2: %m\n);
 - return -errno;
 + r = -errno;
   }
   free(cpuid);
   return r;
 -- 
 1.6.2.5

Applied, thanks.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/8] Move closer to upstream

2009-07-14 Thread Marcelo Tosatti
On Tue, Jul 14, 2009 at 11:35:10AM -0400, Glauber Costa wrote:
 Same thing that was already sent, but rebased for today's tree.
 Avi suggested me to just keep the include for libkvm-all.h and he
 would fold it manually.
 
 Note that I'm _not_ doing this here, because marcelo, who is less
 bright than avi, seem to prefer me to do this way.
 
 If applied on top of today's tree with no modifications, it should
 have no conflicts.

Applied, thanks.

The qemu-kvm.git branch i'm applying patches to is 

git://git.kernel.org/pub/scm/linux/kernel/git/marcelo/qemu-kvm.git/ next

This is temporary, should be back to the normal URL in the next couple
of days.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] silence kernel messages that can be triggered by a guest

2009-07-14 Thread Marcelo Tosatti
On Wed, Jul 08, 2009 at 11:26:54AM +0300, Gleb Natapov wrote:
 Some Linux versions (f8) try to read EOI register that is write only.
 
 Signed-off-by: Gleb Natapov g...@redhat.com
 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
 index ccafe0d..6b5dad4 100644
 --- a/arch/x86/kvm/lapic.c
 +++ b/arch/x86/kvm/lapic.c
 @@ -590,14 +590,14 @@ static int apic_reg_read(struct kvm_lapic *apic, u32 
 offset, int len,
   static const u64 rmask = 0x43ff01ffe70cULL;
  
   if ((alignment + len)  4) {
 - printk(KERN_ERR KVM_APIC_READ: alignment error %x %d\n,
 - offset, len);
 + apic_debug(KVM_APIC_READ: alignment error %x %d\n,
 +offset, len);
   return 1;
   }
  
   if (offset  0x3f0 || !(rmask  (1ULL  (offset  4 {
 - printk(KERN_ERR KVM_APIC_READ: read reserved register %x\n,
 - offset);
 + apic_debug(KVM_APIC_READ: read reserved register %x\n,
 +offset);
   return 1;
   }
  
 --
   Gleb.

Applied, thanks.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Autotest] [PATCH] Add a subtest pci_hotplug in kvm test

2009-07-14 Thread Yolkfull Chow

On 07/08/2009 09:51 AM, Lucas Meneghel Rodrigues wrote:

I've spent some time doing a second review and test of the code.
During my tests:

  * I found some problems with PCI hotplug itself and would like help
to figure out why things are not working as expected.
  * Made suggestions regarding the phrasing of the error messages
thrown by the test. Mostly nipticking. Let me know if you think the
new messages make sense.
  * The order of the final test steps looks a bit weird to me

Comments follow.

On Fri, Jul 3, 2009 at 3:00 AM, Yolkfull Chowyz...@redhat.com  wrote:
   

On 07/03/2009 01:57 PM, Yolkfull Chow wrote:
 

Signed-off-by: Yolkfull Chowyz...@redhat.com
---
   client/tests/kvm/kvm.py   |1 +
   client/tests/kvm/kvm_tests.cfg.sample |   65 ++-
   client/tests/kvm/kvm_tests.py |   94 
+
   client/tests/kvm/kvm_vm.py|2 +
   4 files changed, 161 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index b18b643..fc92e10 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -55,6 +55,7 @@ class kvm(test.test):
   kvm_install:  test_routine(kvm_install, 
run_kvm_install),
   linux_s3: test_routine(kvm_tests, run_linux_s3),
   stress_boot:  test_routine(kvm_tests, run_stress_boot),
+pci_hotplug:  test_routine(kvm_tests, run_pci_hotplug),
   }

   # Make it possible to import modules from the test's bindir
diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
b/client/tests/kvm/kvm_tests.cfg.sample
index 2f864de..a9e16d6 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -94,6 +94,53 @@ variants:
   max_vms = 5
   alive_test_cmd = ps aux

+
+- nic_hotplug:
+type = pci_hotplug
+pci_type = nic
+modprobe_acpiphp = yes
+reference_cmd = lspci
+find_pci_cmd = 'lspci | tail -n1'
   

I tried block device hotplug, lspci doesn't show up the newly added
devices. Already tried with F8 and F9. Any idea why?
   
  It doesn't need to modprobe acpiphp on Fedora, also, both F8 and F9 
don't have virtio  virtio_ring modules.  I ran it on guest Fedora-11 
and Win2008,  both ran successfully:


# ./scan_results.py
teststatus
secondsinfo
--
---
Fedora.11.32.nic_hotplug.nic_rtl8139GOOD
68completed successfully
Fedora.11.32.nic_hotplug.nic_virtio GOOD46
completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_virtioGOOD46
completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_scsi GOOD44
completed successfully
Fedora.11.32.block_hotplug.fmt_raw.block_virtio GOOD45
completed successfully
Fedora.11.32.block_hotplug.fmt_raw.block_scsi   GOOD46
completed successfully
Win2008.32.nic_hotplug.nic_rtl8139  GOOD
66completed successfully
Win2008.32.block_hotplug.fmt_qcow2.block_scsi   GOOD186
completed successfully
Win2008.32.block_hotplug.fmt_raw.block_scsi GOOD71
completed successfully


   

+pci_test_cmd = 'nslookupwww.redhat.com'
+seconds_wait_for_device_install = 3
+variants:
+- @nic_8139:
+pci_model = rtl8139
+match_string = 8139
+- nic_virtio:
+pci_model = virtio
+match_string = Virtio network device
+- nic_e1000:
+pci_model = e1000
+match_string = Gigabit Ethernet Controller
   

Pretty much all block hotplug 'guest side check' is failing during the
stage where the output  of lspci | tail -n1 is being compared with the
match strings. Hypervisor is qemu 0.10.5 (kvm-87 upstream).

   

+- block_hotplug:
+type = pci_hotplug
+pci_type = block
+modprobe_acpiphp = yes
+reference_cmd = lspci
+find_pci_cmd = 'lspci | tail -n1'
+images +=  stg
+boot_drive_stg = no
+image_name_stg = storage
+image_size = 1G
+force_create_image_stg = yes
+pci_test_cmd = 'dir'
+seconds_wait_for_device_install = 3
+variants:
+- block_virtio:
+pci_model = virtio
+match_string = Virtio block device
+- block_scsi:
+pci_model = scsi
+match_string = SCSI storage controller
+variants:
+- fmt_qcow2:
+image_format_stg = qcow2
+- fmt_raw:
+image_format_stg = raw
+
+
   # NICs
   variants:
   - @rtl8139:
@@ -306,6 +353,22 @@ variants:
   

[PATCH] Add a kvm subtest -- pci_hotplug, which supports both Windows OS and Linux OS.

2009-07-14 Thread Yolkfull Chow
This is a subtest in kvm. It will verify newly added pci block device now. For 
Windows support,it needs to use_telnet since 'wmic' which is used to check disk 
info could only be executed in telnet session not ssh. Just ran it on guest 
Fedora-11.32 and Windows2008.32, both passed:

# ./scan_results.py
teststatus  seconds 
info
--  --- 

Fedora.11.32.nic_hotplug.nic_rtl8139GOOD68  
completed successfully
Fedora.11.32.nic_hotplug.nic_virtio GOOD46  
completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_virtio   GOOD46  
completed successfully
Fedora.11.32.block_hotplug.fmt_qcow2.block_scsi GOOD44  
completed successfully
Fedora.11.32.block_hotplug.fmt_raw.block_virtio GOOD45  
completed successfully
Fedora.11.32.block_hotplug.fmt_raw.block_scsi   GOOD46  
completed successfully
Win2008.32.nic_hotplug.nic_rtl8139  GOOD66  
completed successfully
Win2008.32.block_hotplug.fmt_qcow2.block_scsi   GOOD186 
completed successfully
Win2008.32.block_hotplug.fmt_raw.block_scsi GOOD71  
completed successfully



Signed-off-by: Yolkfull Chow yz...@redhat.com
---
 client/tests/kvm/kvm.py   |1 +
 client/tests/kvm/kvm_tests.cfg.sample |   69 +++-
 client/tests/kvm/kvm_tests.py |   98 +
 client/tests/kvm/kvm_vm.py|2 +
 4 files changed, 169 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index b18b643..fc92e10 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -55,6 +55,7 @@ class kvm(test.test):
 kvm_install:  test_routine(kvm_install, run_kvm_install),
 linux_s3: test_routine(kvm_tests, run_linux_s3),
 stress_boot:  test_routine(kvm_tests, run_stress_boot),
+pci_hotplug:  test_routine(kvm_tests, run_pci_hotplug),
 }
 
 # Make it possible to import modules from the test's bindir
diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
b/client/tests/kvm/kvm_tests.cfg.sample
index 2f864de..7ec6f72 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -91,9 +91,56 @@ variants:
 
 - stress_boot:
 type = stress_boot
-max_vms = 5
+max_vms = 5
 alive_test_cmd = ps aux
 
+
+- nic_hotplug:
+type = pci_hotplug
+pci_type = nic
+modprobe_acpiphp = yes
+reference_cmd = lspci
+find_pci_cmd = 'lspci | tail -n1'
+pci_test_cmd = 'nslookup www.redhat.com'
+seconds_wait_for_device_install = 3
+variants:
+- nic_8139:
+pci_model = rtl8139
+match_string = 8139
+- nic_virtio:
+pci_model = virtio
+match_string = Virtio network device
+- nic_e1000:
+pci_model = e1000
+match_string = Gigabit Ethernet Controller
+
+- block_hotplug:
+type = pci_hotplug
+pci_type = block
+modprobe_acpiphp = yes
+reference_cmd = lspci
+find_pci_cmd = 'lspci | tail -n1'
+images +=  stg
+boot_drive_stg = no
+image_name_stg = storage
+image_size = 1G
+force_create_image_stg = yes
+seconds_wait_for_device_install = 3
+pci_test_cmd = 'yes|mke2fs `fdisk -l 21 |grep '/dev/[sv]d[a-z] 
doesn' | awk '{print $2}'`'
+variants:
+- block_virtio:
+pci_model = virtio
+match_string = Virtio block device
+- block_scsi:
+pci_model = scsi
+match_string = SCSI
+variants:
+- fmt_qcow2:
+image_format_stg = qcow2
+- fmt_raw:
+image_format_stg = raw
+
+
 # NICs
 variants:
 - @rtl8139:
@@ -119,6 +166,10 @@ variants:
 - Fedora:
 no setup
 ssh_prompt = \[r...@.{0,50}][\#\$] 
+nic_hotplug:
+modprobe_acpiphp = no
+block_hotplug:
+modprobe_acpiphp = no
 
 variants:
 - 8.32:
@@ -306,6 +357,22 @@ variants:
 migration_test_command = ver  vol
 stress_boot:
 alive_test_cmd = systeminfo
+nic_hotplug:
+modprobe_acpiphp = no
+reference_cmd = systeminfo
+seconds_wait_for_device_install = 10
+find_pci_cmd = ipconfig /all | find Description
+nic_e1000:
+match_string = Intel(R) 

Re: [PATCHv3 RFC] uio: add generic driver for PCI 2.3 devices

2009-07-14 Thread Michael S. Tsirkin
On Tue, Jul 14, 2009 at 04:25:07PM -0700, Chris Wright wrote:
 * Michael S. Tsirkin (m...@redhat.com) wrote:
  On Tue, Jul 14, 2009 at 11:03:38AM -0700, Chris Wright wrote:
   * Michael S. Tsirkin (m...@redhat.com) wrote:
- remove irqcontrol: user can enable interrupts by
  writing command register directly
   
   Sorry if I gave you the impression that removing was needed.
   I actually think the irqcontrol was useful since it's atomic.
  
  What I'm saying, it is not strictly needed (user can safely write 0 in
  that register and worst case you just get an extra interrupt).  So let's
  make the decision on what does irqcontrol do when we have a pressing
  need for an extra kernel/user interface.
 
 OK.  My concern is theoretical (as in the current design wouldn't
 trigger an issue):
 
 cmd = pread()
  --+
 \
 cmd = ~INTX_DISABLE ++
 / |
 ---+  |
 pwrite(cmd)   |
   -
 During this window Command Reg can change[1] and cmd is stale
 
 [1] due to irqhandler (doesn't matter in this case since it touches
 same bit).  or due to some other thread updating Command Reg (also
 doesn't matter since this does not happen right now).

Right. Note that the limitation that only a single thread should touch
config space through sysfs applies to any sub-byte field. If we wanted
to make such ops atomic, pci devices would need some kind of compare and
swap ioctl.

-- 
MST
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html