[PATCH] kvm-tool: Don't try to cleanup ioeventfd if we never initialised it

2012-02-05 Thread Michael Ellerman
Since 44287dd (Repair running on non ioeventfd-capable platforms) it's possible that ioeventfd__init() fails, but the VM still runs. This means we end up calling ioeventfd__exit(), which writes() and then reads() epoll_stop_fd. Because we failed the init, epoll_stop_fd is 0, so we end up writing/r

Re: [PATCH for 3.3] KVM: Fix write protection race during dirty logging

2012-02-05 Thread Takuya Yoshikawa
(2012/02/06 14:02), Xiao Guangrong wrote: I am worrying if other paths(such as like kvm_mmu_notifier_invalidate_page) which unmap/modify writeable ptes and flush TLBs out of mmu lock have the same problem? Yes, I think so ... (long standing bug?) Let's ask Avi if he prefers to fix it separat

Re: [PATCH for 3.3] KVM: Fix write protection race during dirty logging

2012-02-05 Thread Xiao Guangrong
On 02/06/2012 11:53 AM, Xiao Guangrong wrote: > On 02/06/2012 11:46 AM, Takuya Yoshikawa wrote: > >> (2012/02/06 12:40), Xiao Guangrong wrote: >>> On 02/05/2012 07:42 PM, Takuya Yoshikawa wrote: >>> From: Takuya Yoshikawa This patch fixes a race introduced by: commit 9

Re: [PATCH for 3.3] KVM: Fix write protection race during dirty logging

2012-02-05 Thread Xiao Guangrong
On 02/06/2012 11:46 AM, Takuya Yoshikawa wrote: > (2012/02/06 12:40), Xiao Guangrong wrote: >> On 02/05/2012 07:42 PM, Takuya Yoshikawa wrote: >> >>> From: Takuya Yoshikawa >>> >>> This patch fixes a race introduced by: >>> >>>commit 95d4c16ce78cb6b7549a09159c409d52ddd18dae >>>KVM: Optimiz

Re: [PATCH for 3.3] KVM: Fix write protection race during dirty logging

2012-02-05 Thread Takuya Yoshikawa
(2012/02/06 12:40), Xiao Guangrong wrote: On 02/05/2012 07:42 PM, Takuya Yoshikawa wrote: From: Takuya Yoshikawa This patch fixes a race introduced by: commit 95d4c16ce78cb6b7549a09159c409d52ddd18dae KVM: Optimize dirty logging by rmap_write_protect() During protecting pages for dirty

Re: [PATCH for 3.3] KVM: Fix write protection race during dirty logging

2012-02-05 Thread Xiao Guangrong
On 02/05/2012 07:42 PM, Takuya Yoshikawa wrote: > From: Takuya Yoshikawa > > This patch fixes a race introduced by: > > commit 95d4c16ce78cb6b7549a09159c409d52ddd18dae > KVM: Optimize dirty logging by rmap_write_protect() > > During protecting pages for dirty logging, other threads may als

[PATCH 2/2] kvm tool: Initialise kvm fd's to -1 in kvm__new()

2012-02-05 Thread Michael Ellerman
In kvm__new() we use calloc() to allocate the kvm structure, which initialises the memory to 0. In kvm__init() if we hit an error before sys_fd and vm_fd are opened we go to cleanup which closes sys_fd and vm_fd. Because they were initialised to zero this has the effect of closing stdin. Because w

[PATCH 1/2] kvm tool: Report error and don't segfault if kvm__init() fails

2012-02-05 Thread Michael Ellerman
Signed-off-by: Michael Ellerman --- tools/kvm/builtin-run.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index 95d35a5..569246e 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -997,6 +997,11 @@

Re: windows PIO question

2012-02-05 Thread Nikola Ciprich
> Not all PIO operations are DMA. Provide a trace and we can look. Hi, here's snippet: qemu-kvm-16441 [000] 12887154.698329: kvm_pio: pio_read at 0xc002 size 1 count 1 qemu-kvm-16441 [000] 12887154.698331: kvm_userspace_exit: reason KVM_EXIT_IO (2) qemu-k

Re: [PATCH 3/4] kvm: Add kvm_has_pit_state2 helper

2012-02-05 Thread Jan Kiszka
On 2012-02-05 21:03, Juan Quintela wrote: > Jan Kiszka wrote: >> From: Jan Kiszka >> >> To be used for in-kernel PIT emulation. > > > >> +int pit_state2; > > This is used as a bool. > >> int xsave, xcrs; >> int many_ioeventfds; >> int irqchip_inject_ioctl; >> @@ -954,6

Re: [PATCH] kvm tool: Don't close not yet opened files and SIGSEV fix

2012-02-05 Thread Cyrill Gorcunov
On Sat, Feb 04, 2012 at 10:02:19PM +0400, Cyrill Gorcunov wrote: > > Strictly speaking, kvm__init need more serious rewrite together with > kvm__arch_init/kvm_ipc__start/kvm_ipc__register_handler ret. vals tests, > i'll do this a bit late. > Sorry for delay, was busy. Anyway, here is a quickfix

Re: [PATCH 3/4] kvm: Add kvm_has_pit_state2 helper

2012-02-05 Thread Juan Quintela
Jan Kiszka wrote: > From: Jan Kiszka > > To be used for in-kernel PIT emulation. > +int pit_state2; This is used as a bool. > int xsave, xcrs; > int many_ioeventfds; > int irqchip_inject_ioctl; > @@ -954,6 +955,10 @@ int kvm_init(void) > s->xcrs = kvm_check_extens

Re: [net-next-2.6 PATCH 0/6 v4] macvlan: MAC Address filtering support for passthru mode

2012-02-05 Thread Roopa Prabhu
On 2/3/12 7:32 AM, "Roopa Prabhu" wrote: > > > > On 2/2/12 10:58 AM, "John Fastabend" wrote: .. >> Are you sure they will be good to have? I'm not so sure you want to be >> able to manipulate the uc and mc tables from user space. MACVLAN seems to >> be one type of device where it is usef

Re: [Qemu-devel] [RFC] Next gen kvm api

2012-02-05 Thread Anthony Liguori
On 02/05/2012 03:51 AM, Gleb Natapov wrote: On Sun, Feb 05, 2012 at 11:44:43AM +0200, Avi Kivity wrote: On 02/05/2012 11:37 AM, Gleb Natapov wrote: On Thu, Feb 02, 2012 at 06:09:54PM +0200, Avi Kivity wrote: Device model Currently kvm virtualizes or emulates a set of x86 cores, wi

Re: windows PIO question

2012-02-05 Thread Avi Kivity
On 02/02/2012 11:16 PM, Nikola Ciprich wrote: > Hello everybody, > > I'm a bit confused regarding windows guests and PIO.. some time ago, I was > trying > to find out, why one of my windows guests was running terribly slow. > After checking the trace-cmd output, Avi stated that windows were using

Re: [RFC] Next gen kvm api

2012-02-05 Thread Avi Kivity
On 02/05/2012 12:58 PM, Gleb Natapov wrote: > > > > > > > Reduced performance is what I mean. Obviously old guests will continue > > > working. > > > > I'm not happy about it either. > > > It is not only about old guests either. In RHEL we pretend to not > support HPET because when some guests

Re: [Qemu-devel] [RFC] Next gen kvm api

2012-02-05 Thread Avi Kivity
On 02/03/2012 12:13 AM, Rob Earhart wrote: > On Thu, Feb 2, 2012 at 8:09 AM, Avi Kivity > wrote: > > The kvm api has been accumulating cruft for several years now. > This is > due to feature creep, fixing mistakes, experience gained by the > maintainers and

[PATCH 2/6] kvmvapic: Add option ROM

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka This imports and builds the original VAPIC option ROM of qemu-kvm. Its interaction with QEMU is described in the commit that introduces the corresponding device model. Signed-off-by: Jan Kiszka --- .gitignore |1 + Makefile |2 +-

[PATCH 4/6] kvmvapic: Simplify mp/up_set_tpr

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka The CH registers is only written, never read. So we can remove these operations and, in case of up_set_tpr, also the ECX push/pop. Signed-off-by: Jan Kiszka --- pc-bios/optionrom/kvmvapic.S |6 +- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/pc-bios/o

[PATCH 3/6] kvmvapic: Introduce TPR access optimization for Windows guests

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka This enables acceleration for MMIO-based TPR registers accesses of 32-bit Windows guest systems. It is mostly useful with KVM enabled, either on older Intel CPUs (without flexpriority feature, can also be manually disabled for testing) or any current AMD processor. The approach

[PATCH 5/6] optionsrom: Reserve space for checksum

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka Always add a byte before the final 512-bytes alignment to reserve the space for the ROM checksum. Signed-off-by: Jan Kiszka --- pc-bios/optionrom/optionrom.h |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/pc-bios/optionrom/optionrom.h b/pc-bios/opti

[PATCH 6/6] kvmvapic: Use optionrom helpers

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka Use OPTION_ROM_START/END from the common header file, add comment to init code. Signed-off-by: Jan Kiszka --- pc-bios/optionrom/kvmvapic.S | 18 -- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pc-bios/optionrom/kvmvapic.S b/pc-bios/optionro

[PATCH 1/6] target-i386: Add infrastructure for reporting TPR MMIO accesses

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka This will allow the APIC core to file a TPR access report. Depending on the accelerator and kernel irqchip mode, it will either be delivered right away or queued for later reporting. In TCG mode, we can restart the triggering instruction and can therefore forward the event direc

[PATCH 0/6] uq/master: TPR access optimization for Windows guests

2012-02-05 Thread Jan Kiszka
And yet another qemu-kvm piece: Windows 32-bit guests make heavy use of the MMIO-based TPR register. On older Intel CPUs and current AMDs, this causes significant KVM vmexit rates as the register needs to be trapped by the hypervisor. This series introduces a workaround for this hardware limitatio

[PATCH 2/4 v3] i8254: Open-code timer restore

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka Same as for the APIC: To enable migration between accelerated and non-accelerated models, we need to arm the channel 0 timer only inside the emulated PIT model. The common code just saves/restores that timer to the the next_transition_time field. Signed-off-by: Jan Kiszka ---

[PATCH uq/master] apic: Fix legacy vmstate loading for KVM

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka Also in case of loading pre-vmstate machines, we also need to open-code the reading of the timer expires value and instead call the post_load callback to apply it (or not). This fixes loading of legacy states into the KVM APIC. Reported-by: Paolo Bonzini Signed-off-by: Jan Kisz

[PATCH for 3.3] KVM: Fix write protection race during dirty logging

2012-02-05 Thread Takuya Yoshikawa
From: Takuya Yoshikawa This patch fixes a race introduced by: commit 95d4c16ce78cb6b7549a09159c409d52ddd18dae KVM: Optimize dirty logging by rmap_write_protect() During protecting pages for dirty logging, other threads may also try to protect a page in mmu_sync_children() or kvm_mmu_get_pag

[PATCH] kvm tools: Enable PPC64 to build static

2012-02-05 Thread Matt Evans
By "enable", I mean "fix"; the re-jigged commit 7ef85e8b builds libfdt using OBJS rather than OTHEROBJS hence ignores the relaxed CFLAGS. This commit builds it via OTHEROBJS. Signed-off-by: Matt Evans --- Pekka, not quite sure how this slipped through as I was building static in testing

Re: [PATCH 2/4] i8254: Open-code timer restore

2012-02-05 Thread Jan Kiszka
On 2012-02-05 12:23, Paolo Bonzini wrote: > On 02/05/2012 11:46 AM, Jan Kiszka wrote: >> diff --git a/hw/i8254_common.c b/hw/i8254_common.c >> index 0601d88..b60fbda 100644 >> --- a/hw/i8254_common.c >> +++ b/hw/i8254_common.c >> @@ -234,9 +234,8 @@ static int pit_load_old(QEMUFile *f, void *opaque

Re: [PATCH 2/4] i8254: Open-code timer restore

2012-02-05 Thread Paolo Bonzini
On 02/05/2012 11:46 AM, Jan Kiszka wrote: diff --git a/hw/i8254_common.c b/hw/i8254_common.c index 0601d88..b60fbda 100644 --- a/hw/i8254_common.c +++ b/hw/i8254_common.c @@ -234,9 +234,8 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id) qemu_get_8s(f,&s->gate);

Re: [PATCH v3 3/4] KVM: SVM: Fix CPL updates

2012-02-05 Thread Gleb Natapov
On Fri, Feb 03, 2012 at 07:29:24PM +0100, Kevin Wolf wrote: > Keep CPL at 0 in real mode and at 3 in VM86. In protected/long mode, use > RPL rather than DPL of the code segment. > > Signed-off-by: Kevin Wolf > --- > arch/x86/kvm/svm.c | 19 --- > 1 files changed, 16 insertions(

[PATCH v5 2/3] virtio-scsi: add error handling

2012-02-05 Thread Paolo Bonzini
This commit adds basic error handling to the virtio-scsi HBA device. Task management functions are sent synchronously via the control virtqueue. Cc: linux-scsi Cc: Rusty Russell Cc: Michael S. Tsirkin Cc: kvm@vger.kernel.org Acked-by: Pekka Enberg Signed-off-by: Paolo Bonzini --- v3

[PATCH v5 1/3] virtio-scsi: first version

2012-02-05 Thread Paolo Bonzini
The virtio-scsi HBA is the basis of an alternative storage stack for QEMU-based virtual machines (including KVM). Compared to virtio-blk it is more scalable, because it supports many LUNs on a single PCI slot), more powerful (it more easily supports passthrough of host devices to the guest) and mo

[PATCH v5 3/3] virtio-scsi: add power management support

2012-02-05 Thread Paolo Bonzini
This patch adds freeze/restore handlers for the HBA. Block queues are managed independently by the disk devices. Cc: linux-scsi Cc: Rusty Russell Cc: Michael S. Tsirkin Cc: kvm@vger.kernel.org Acked-by: Pekka Enberg Signed-off-by: Paolo Bonzini --- The feature has been merged in the

[PATCH v5 0/3] virtio-scsi driver

2012-02-05 Thread Paolo Bonzini
This is the first implementation of the virtio-scsi driver, a virtual HBA that will be supported by KVM. It implements a subset of the spec, in particular it does not implement asynchronous notifications for either LUN reset/removal/addition or CD-ROM media events, but it is already functional and

Re: [RFC] Next gen kvm api

2012-02-05 Thread Gleb Natapov
On Sun, Feb 05, 2012 at 11:56:21AM +0200, Avi Kivity wrote: > On 02/05/2012 11:51 AM, Gleb Natapov wrote: > > On Sun, Feb 05, 2012 at 11:44:43AM +0200, Avi Kivity wrote: > > > On 02/05/2012 11:37 AM, Gleb Natapov wrote: > > > > On Thu, Feb 02, 2012 at 06:09:54PM +0200, Avi Kivity wrote: > > > > > D

[PATCH 3/4] kvm: Add kvm_has_pit_state2 helper

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka To be used for in-kernel PIT emulation. Signed-off-by: Jan Kiszka --- kvm-all.c | 10 ++ kvm-stub.c |5 + kvm.h |1 + 3 files changed, 16 insertions(+), 0 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index c4babda..bddf922 100644 --- a/kvm-all.c

[PATCH 2/4] i8254: Open-code timer restore

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka Same as for the APIC: To enable migration between accelerated and non-accelerated models, we need to arm the channel 0 timer only inside the emulated PIT model. The common code just saves/restores that timer to the the next_transition_time field. Signed-off-by: Jan Kiszka ---

[PATCH 4/4] kvm: x86: Add user space part for in-kernel i8254

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka This provides the required user space stubs to enable the in-kernel i8254 emulation of KVM. The in-kernel model supports lost tick compensation according to the "delay" policy. This is enabled by default and can be switched off via a device property. Depending on the feature se

[PATCH 1/4] i8254: Factor out base class for KVM reuse

2012-02-05 Thread Jan Kiszka
From: Jan Kiszka Applying the concept used for the *PICs once again: establish a base class for the i8254 that can be used both by the current user space emulation and the upcoming KVM in-kernel version. We share most of the public interface of the i8254, specifically to the pcspk, vmstate, reset

[PATCH 0/4] uq/master: Introduce KVM PIT support

2012-02-05 Thread Jan Kiszka
This adds another piece of qemu-kvm to upstream: The accelerated in-kernel model of the i8254. It does this in the same fashion as the interrupt controllers were already introduced. And it even has one bug less than qemu-kvm: PC speaker output still works with KVM acceleration enabled. Changes in

[GIT PULL] KVM updates for 3.3-rc2

2012-02-05 Thread Avi Kivity
Linus, please pull from: git://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-updates/3.3 Fixing a regression with the PMU MSRs when PMU virtualization is disabled, a guest-internal DoS with the SYSCALL instruction, and a dirty memory logging race that may cause live migration to fail. Gleb Natap

Re: [RFC] Next gen kvm api

2012-02-05 Thread Avi Kivity
On 02/05/2012 11:51 AM, Gleb Natapov wrote: > On Sun, Feb 05, 2012 at 11:44:43AM +0200, Avi Kivity wrote: > > On 02/05/2012 11:37 AM, Gleb Natapov wrote: > > > On Thu, Feb 02, 2012 at 06:09:54PM +0200, Avi Kivity wrote: > > > > Device model > > > > > > > > Currently kvm virtualizes or

Re: [RFC] Next gen kvm api

2012-02-05 Thread Gleb Natapov
On Sun, Feb 05, 2012 at 11:44:43AM +0200, Avi Kivity wrote: > On 02/05/2012 11:37 AM, Gleb Natapov wrote: > > On Thu, Feb 02, 2012 at 06:09:54PM +0200, Avi Kivity wrote: > > > Device model > > > > > > Currently kvm virtualizes or emulates a set of x86 cores, with or > > > without local

Re: [RFC] Next gen kvm api

2012-02-05 Thread Avi Kivity
On 02/05/2012 11:37 AM, Gleb Natapov wrote: > On Thu, Feb 02, 2012 at 06:09:54PM +0200, Avi Kivity wrote: > > Device model > > > > Currently kvm virtualizes or emulates a set of x86 cores, with or > > without local APICs, a 24-input IOAPIC, a PIC, a PIT, and a number of > > PCI devices

Re: performance trouble

2012-02-05 Thread Avi Kivity
On 02/03/2012 10:59 AM, David Cure wrote: > Hello, > > Le Thu, Feb 02, 2012 at 11:41:48AM +0100, David Cure ecrivait : > > > > For kvm_stats, I mean it's better to have only one VM with one > > user for the test so I send this evening or tomorrow morning. > > I attach snaps

Re: [RFC] Next gen kvm api

2012-02-05 Thread Gleb Natapov
On Thu, Feb 02, 2012 at 06:09:54PM +0200, Avi Kivity wrote: > Device model > > Currently kvm virtualizes or emulates a set of x86 cores, with or > without local APICs, a 24-input IOAPIC, a PIC, a PIT, and a number of > PCI devices assigned from the host. The API allows emulating the l

Re: [Qemu-devel] [RFC] Next gen kvm api

2012-02-05 Thread Avi Kivity
On 02/03/2012 04:09 AM, Anthony Liguori wrote: > >> Note: this may cause a regression for older guests >> that don't support MSI or kvmclock. Device assignment will be done >> using VFIO, that is, without direct kvm involvement. >> >> Local APICs will be mandatory, but it will be possible to hide