[PATCH v5] kvm: notify host when the guest is panicked

2012-06-27 Thread Wen Congyang
We can know the guest is panicked when the guest runs on xen. But we do not have such feature on kvm. Another purpose of this feature is: management app(for example: libvirt) can do auto dump when the guest is panicked. If management app does not do auto dump, the guest's user can do dump by hand

[PATCH 1/6 v5] start vm after reseting it

2012-06-27 Thread Wen Congyang
The guest should run after reseting it, but it does not run if its old state is RUN_STATE_INTERNAL_ERROR or RUN_STATE_PAUSED. Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- block.h |2 ++ qmp.c |2 +- vl.c|3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff

[PATCH 2/6 v5] update linux headers

2012-06-27 Thread Wen Congyang
Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- linux-headers/asm-x86/kvm_para.h |2 ++ linux-headers/linux/kvm_para.h |6 ++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/linux-headers/asm-x86/kvm_para.h b/linux-headers/asm-x86/kvm_para.h index

[PATCH 3/6 v5] add a new runstate: RUN_STATE_GUEST_PANICKED

2012-06-27 Thread Wen Congyang
Add a new runstate RUN_STATE_GUEST_PANICKED. The guest can be in this state if it is paused due to panicked event. Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- qapi-schema.json |6 +- qmp.c|3 ++- vl.c |7 ++- 3 files changed, 13 insertions(+),

[PATCH 4/6 v5] add a new qevent: QEVENT_GUEST_PANICKED

2012-06-27 Thread Wen Congyang
Add a new qevent QEVENT_GUEST_PANICKED. QEMU will emit this event if the guest is panicked. Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- monitor.c |1 + monitor.h |1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index f6107ba..28f7482

[PATCH 5/6 v5] deal with guest panicked event accoring to -onpanic parameter

2012-06-27 Thread Wen Congyang
When the guest is panicked, it will write 0x1 to the port KVM_PV_PORT. So if qemu reads 0x1 from this port, we can do the folloing three things according to the parameter -onpanic: 1. emit QEVENT_GUEST_PANICKED only 2. emit QEVENT_GUEST_PANICKED and pause the guest 3. emit QEVENT_GUEST_PANICKED

Re: [Qemu-devel] [PATCH] kvm: First step to push iothread lock out of inner run loop

2012-06-27 Thread Stefan Hajnoczi
On Tue, Jun 26, 2012 at 8:34 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Sat, Jun 23, 2012 at 12:55:49AM +0200, Jan Kiszka wrote: net.txt iothread flow = 1) Skip-work-if-device-locked select(tap fd ready) tap_send    if (trylock(TAPState-NetClientState-dev))

[PATCH 6/6 v5] deal with panicked event accoring to '-machine panic_action=action'

2012-06-27 Thread Wen Congyang
The action is the same as -onpanic parameter. Signed-off-by: Wen Congyang we...@cn.fujitsu.com --- qemu-config.c |4 qemu-options.hx |4 +++- vl.c|7 +++ 3 files changed, 14 insertions(+), 1 deletions(-) diff --git a/qemu-config.c b/qemu-config.c index

Re: [Qemu-devel] [PATCH] kvm: First step to push iothread lock out of inner run loop

2012-06-27 Thread Stefan Hajnoczi
On Wed, Jun 27, 2012 at 8:39 AM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Jun 26, 2012 at 8:34 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Sat, Jun 23, 2012 at 12:55:49AM +0200, Jan Kiszka wrote: net.txt iothread flow = 1) Skip-work-if-device-locked

Re: [PATCH] kvm: First step to push iothread lock out of inner run loop

2012-06-27 Thread Avi Kivity
On 06/26/2012 10:34 PM, Marcelo Tosatti wrote: 1. read_lock(memmap_lock) 2. MemoryRegionSection mrs = lookup(addr) 3. qom_ref(mrs.mr-dev) 4. read_unlock(memmap_lock) 5. mutex_lock(dev-lock) 6. dispatch(mrs, addr, data, size) 7. mutex_unlock(dev-lock) 8.

[PATCH kvm-unit-tests 01/12] realmode: test cpuid

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/realmode.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/x86/realmode.c b/x86/realmode.c index d171a56..a083c7a 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1287,6 +1287,20 @@ void test_jcxz(void)

[PATCH kvm-unit-tests 00/12] Unit tests for big real mode patchset

2012-06-27 Thread Avi Kivity
This series adds unit tests for the big real mode kernel patchset. Avi Kivity (12): realmode: test cpuid emulator: test leave emulator: test long-mode lidt/lgdt emulator: check for mov null, %ss realmode: test for ss base used with esp/ebp base register realmode: test sigt/sgdt

[PATCH kvm-unit-tests 02/12] emulator: test leave

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/emulator.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x86/emulator.c b/x86/emulator.c index 969944a..4867f58 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -213,7 +213,7 @@ void test_push(void *mem)

[PATCH kvm-unit-tests 05/12] realmode: test for ss base used with esp/ebp base register

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/realmode.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/x86/realmode.c b/x86/realmode.c index a083c7a..b1d089a 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1301,6 +1301,23 @@ static void test_cpuid(void)

[PATCH kvm-unit-tests 06/12] realmode: test sigt/sgdt

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/realmode.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/x86/realmode.c b/x86/realmode.c index b1d089a..98a25c2 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1318,6 +1318,23 @@ static void

[PATCH kvm-unit-tests 10/12] realmode: test bswap

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/realmode.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/x86/realmode.c b/x86/realmode.c index 29f3461..710a06b 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1356,6 +1356,15 @@ static void test_movzx_movsx(void)

[PATCH kvm-unit-tests 09/12] emulator: test enter

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/emulator.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/x86/emulator.c b/x86/emulator.c index a18ba27..9e76de8 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -213,7 +213,7 @@ void test_push(void *mem)

[PATCH kvm-unit-tests 08/12] realmode: test movsx/movzx

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/realmode.c | 13 + 1 file changed, 13 insertions(+) diff --git a/x86/realmode.c b/x86/realmode.c index a2cc8a9..29f3461 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1344,6 +1344,18 @@ static void test_lahf(void)

[PATCH kvm-unit-tests 11/12] emulator: test lldt

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/emulator.c | 17 + 1 file changed, 17 insertions(+) diff --git a/x86/emulator.c b/x86/emulator.c index 9e76de8..e251933 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -787,6 +787,22 @@ static void test_sreg(volatile uint16_t

[PATCH kvm-unit-tests 12/12] emulator: test ltr

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/emulator.c | 17 + 1 file changed, 17 insertions(+) diff --git a/x86/emulator.c b/x86/emulator.c index e251933..24b33d1 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -803,6 +803,22 @@ static void test_lldt(volatile uint16_t

[PATCH kvm-unit-tests 07/12] realmode: test lahf

2012-06-27 Thread Avi Kivity
Signed-off-by: Avi Kivity a...@redhat.com --- x86/realmode.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/x86/realmode.c b/x86/realmode.c index 98a25c2..a2cc8a9 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1335,6 +1335,15 @@ static void test_sgdt_sidt(void)

[PATCH kvm-unit-tests 04/12] emulator: check for mov null, %ss

2012-06-27 Thread Avi Kivity
But check that rpl matches cpl. Signed-off-by: Avi Kivity a...@redhat.com --- x86/emulator.c | 28 1 file changed, 28 insertions(+) diff --git a/x86/emulator.c b/x86/emulator.c index 337429c..a18ba27 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -747,6 +747,33

[PATCH kvm-unit-tests 03/12] emulator: test long-mode lidt/lgdt

2012-06-27 Thread Avi Kivity
A bug in kvm caused it to fail on long-mode lidt/lgdt. This patch tests for the failure. However, kvm doesn't allow lidt/lgdt from mmio, so the test is disabled. Signed-off-by: Avi Kivity a...@redhat.com --- x86/emulator.c | 30 ++ 1 file changed, 30 insertions(+)

[PATCH v3 0/5] Export offsets of VMCS fields as note information for kdump

2012-06-27 Thread Yanfei Zhang
This patch set exports offsets of VMCS fields as note information for kdump. We call it VMCSINFO. The purpose of VMCSINFO is to retrieve runtime state of guest machine image, such as registers, in host machine's crash dump as VMCS format. The problem is that VMCS internal is hidden by Intel in its

[PATCH v3 1/5] x86: Add helper variables and functions to hold VMCSINFO

2012-06-27 Thread Yanfei Zhang
This patch provides a set of variables to hold the VMCSINFO and also some helper functions to help fill the VMCSINFO. Signed-off-by: zhangyanfei zhangyan...@cn.fujitsu.com --- arch/x86/include/asm/vmcsinfo.h | 219 ++ arch/x86/include/asm/vmx.h | 158 +

[PATCH v3 2/5] KVM: Export symbols for module vmcsinfo-intel

2012-06-27 Thread Yanfei Zhang
A new module named vmcsinfo-intel is used to fill VMCSINFO. And this module depends on kvm-intel and kvm module. So we should export some symbols of kvm-intel and kvm module that are needed by vmcsinfo-intel. Signed-off-by: zhangyanfei zhangyan...@cn.fujitsu.com --- arch/x86/include/asm/vmx.h |

[PATCH v3 3/5] KVM-INTEL: Add new module vmcsinfo-intel to fill VMCSINFO

2012-06-27 Thread Yanfei Zhang
This patch implements a new module named vmcsinfo-intel. The module fills VMCSINFO with the VMCS revision identifier, and offsets of VMCS fields. Note, offsets of fields below will not be filled into VMCSINFO: 1. fields defined in Intel specification (Intel® 64 and IA-32 Architectures Software

[PATCH v3 4/5] Sysfs: Export VMCSINFO via sysfs

2012-06-27 Thread Yanfei Zhang
This patch export offsets of fields via /sys/devices/cpu/vmcs/. Individual offsets are contained in subfiles named by the filed's encoding, e.g.: /sys/devices/cpu/vmcs/0800 Signed-off-by: zhangyanfei zhangyan...@cn.fujitsu.com --- drivers/base/core.c | 13 + 1 files changed, 13

[PATCH v3 5/5] Documentation: Add ABI entry for vmcs sysfs interface

2012-06-27 Thread Yanfei Zhang
Signed-off-by: zhangyanfei zhangyan...@cn.fujitsu.com --- Documentation/ABI/testing/sysfs-devices-cpu-vmcs | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-devices-cpu-vmcs diff --git

Re: [PATCH] Add a page cache-backed balloon device driver.

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 04:21:58PM -0700, Frank Swiderski wrote: On Tue, Jun 26, 2012 at 2:47 PM, Michael S. Tsirkin m...@redhat.com wrote: On Tue, Jun 26, 2012 at 02:31:26PM -0700, Frank Swiderski wrote: On Tue, Jun 26, 2012 at 1:40 PM, Rik van Riel r...@redhat.com wrote: On 06/26/2012

Re: [PATCH] Add a page cache-backed balloon device driver.

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 04:45:36PM -0700, Frank Swiderski wrote: On Tue, Jun 26, 2012 at 2:45 PM, Rik van Riel r...@redhat.com wrote: On 06/26/2012 05:31 PM, Frank Swiderski wrote: On Tue, Jun 26, 2012 at 1:40 PM, Rik van Rielr...@redhat.com  wrote: The code looks good to me, my only

[PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Michael S. Tsirkin
irqfd sets and clears the level immediately. This used to be necessary for MSI interrupts but isn't anymore. Note! We never officially supported irqfd for level interrupts but it usually seemed to kind of work, and this change will break it. There are no known real users of that feature though -

Re: [PATCH v2 0/6] kvm: level triggered irqfd support

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:08:52PM -0600, Alex Williamson wrote: I don't address whether injecting an edge irqfd really needs an assert followed by de-assert (I don't know). So I just sent a patch removing that (works fine for me), and we'll see what others say. If it gets applied your patch

Re: [PATCH v2 3/6] kvm: Sanitize KVM_IRQFD flags

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:09:32PM -0600, Alex Williamson wrote: We only know of one so far. Signed-off-by: Alex Williamson alex.william...@redhat.com Ugh. So we have a bug: we should have sanitized the fields. If there's buggy userspace that only set the low bit it will break with this

Re: [PATCH v2 4/6] kvm: Extend irqfd to support level interrupts

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:09:46PM -0600, Alex Williamson wrote: In order to inject an interrupt from an external source using an irqfd, we need to allocate a new irq_source_id. This allows us to assert and (later) de-assert an interrupt line independently from users of KVM_IRQ_LINE and avoid

Re: [PATCH v2 1/6] kvm: Pass kvm_irqfd to functions

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:09:04PM -0600, Alex Williamson wrote: Prune this down to just the struct kvm_irqfd so we can avoid changing function definition for every flag or field we use. Signed-off-by: Alex Williamson alex.william...@redhat.com This is not needed anymore, right? We are not

Re: [PATCH] Add a page cache-backed balloon device driver.

2012-06-27 Thread Amit Shah
On (Tue) 26 Jun 2012 [13:32:58], Frank Swiderski wrote: This implementation of a virtio balloon driver uses the page cache to store pages that have been released to the host. The communication (outside of target counts) is one way--the guest notifies the host when it adds a page to the page

Re: [PATCH v2 5/6] kvm: KVM_EOIFD, an eventfd for EOIs

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:10:08PM -0600, Alex Williamson wrote: This new ioctl enables an eventfd to be triggered when an EOI is written for a specified irqchip pin. By default this is a simple notification, but we can also tie the eoifd to a level irqfd, which enables the irqchip pin to be

Re: [PATCH] Add a page cache-backed balloon device driver.

2012-06-27 Thread Rusty Russell
On Wed, 27 Jun 2012 00:41:06 +0300, Michael S. Tsirkin m...@redhat.com wrote: On Tue, Jun 26, 2012 at 01:32:58PM -0700, Frank Swiderski wrote: This implementation of a virtio balloon driver uses the page cache to store pages that have been released to the host. The communication (outside

Re: [PATCH v2 4/6] kvm: Extend irqfd to support level interrupts

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:09:46PM -0600, Alex Williamson wrote: In order to inject an interrupt from an external source using an irqfd, we need to allocate a new irq_source_id. This allows us to assert and (later) de-assert an interrupt line independently from users of KVM_IRQ_LINE and avoid

Re: [PATCH v2 2/6] kvm: Add missing KVM_IRQFD API documentation

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:09:17PM -0600, Alex Williamson wrote: Signed-off-by: Alex Williamson alex.william...@redhat.com Acked-by: Michael S. Tsirkin m...@redhat.com --- Documentation/virtual/kvm/api.txt | 16 1 file changed, 16 insertions(+) diff --git

Re: [PATCH v2 0/6] kvm: level triggered irqfd support

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:08:52PM -0600, Alex Williamson wrote: Ok, let's see how this flies. I actually quite like this, so be gentle tearing it apart ;) I just couldn't bring myself to contort KVM_IRQFD into something that either sets up an irqfd or specifies a nearly unrelated EOI

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Gleb Natapov
On Wed, Jun 27, 2012 at 12:13:43PM +0300, Michael S. Tsirkin wrote: irqfd sets and clears the level immediately. This used to be necessary for MSI interrupts but isn't anymore. Note! We never officially supported irqfd for level interrupts but it usually seemed to kind of work, and this

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Michael S. Tsirkin
On Wed, Jun 27, 2012 at 01:03:46PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 12:13:43PM +0300, Michael S. Tsirkin wrote: irqfd sets and clears the level immediately. This used to be necessary for MSI interrupts but isn't anymore. Note! We never officially supported irqfd for

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Gleb Natapov
On Wed, Jun 27, 2012 at 01:20:24PM +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:03:46PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 12:13:43PM +0300, Michael S. Tsirkin wrote: irqfd sets and clears the level immediately. This used to be necessary for MSI interrupts

race condition in qemu-kvm-1.0.1

2012-06-27 Thread Peter Lieven
Hi, we recently came across multiple VMs racing and stopping working. It seems to happen when the system is at 100% cpu. One way to reproduce this is: qemu-kvm-1.0.1 with vnc-thread enabled cmdline (or similar): /usr/bin/qemu-kvm-1.0.1 -net

Re: [Qemu-devel] [PATCH] kvm: First step to push iothread lock out of inner run loop

2012-06-27 Thread Marcelo Tosatti
On Wed, Jun 27, 2012 at 08:41:49AM +0100, Stefan Hajnoczi wrote: On Wed, Jun 27, 2012 at 8:39 AM, Stefan Hajnoczi stefa...@gmail.com wrote: On Tue, Jun 26, 2012 at 8:34 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Sat, Jun 23, 2012 at 12:55:49AM +0200, Jan Kiszka wrote: net.txt

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Michael S. Tsirkin
On Wed, Jun 27, 2012 at 01:22:54PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 01:20:24PM +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:03:46PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 12:13:43PM +0300, Michael S. Tsirkin wrote: irqfd sets and clears the

RE: [RFC PATCH 03/17] KVM: PPC64: booke: Add EPCR support in sregs

2012-06-27 Thread Caraman Mihai Claudiu-B02008
-Original Message- From: Wood Scott-B07421 Sent: Wednesday, June 27, 2012 1:35 AM To: Caraman Mihai Claudiu-B02008 Cc: kvm-...@vger.kernel.org; kvm@vger.kernel.org; linuxppc- d...@lists.ozlabs.org; qemu-...@nongnu.org Subject: Re: [RFC PATCH 03/17] KVM: PPC64: booke: Add EPCR

RE: [RFC PATCH 10/17] PowerPC: booke64: Refactor exception prolog for save/restore regs

2012-06-27 Thread Caraman Mihai Claudiu-B02008
-Original Message- From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org] Sent: Wednesday, June 27, 2012 1:13 AM To: Caraman Mihai Claudiu-B02008 Cc: kvm-...@vger.kernel.org; kvm@vger.kernel.org; linuxppc- d...@lists.ozlabs.org; qemu-...@nongnu.org Subject: Re: [RFC PATCH

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Gleb Natapov
On Wed, Jun 27, 2012 at 02:38:43PM +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:22:54PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 01:20:24PM +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:03:46PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at

[PATCH] pseries: Add support for new KVM hash table control call

2012-06-27 Thread Benjamin Herrenschmidt
From: David Gibson da...@gibson.dropbear.id.au This adds support for then new reset htab ioctl which allows qemu to properly cleanup the MMU hash table when the guest is reset. With the corresponding kernel support, reset of a guest now works properly. This also paves the way for indicating a

Re: [PATCH] pseries: Add support for new KVM hash table control call

2012-06-27 Thread Benjamin Herrenschmidt
On Wed, 2012-06-27 at 22:10 +1000, Benjamin Herrenschmidt wrote: From: David Gibson da...@gibson.dropbear.id.au This adds support for then new reset htab ioctl which allows qemu to properly cleanup the MMU hash table when the guest is reset. With the corresponding kernel support, reset of a

Re: [PATCH] pseries: Add support for new KVM hash table control call

2012-06-27 Thread Alexander Graf
On 27.06.2012, at 14:10, Benjamin Herrenschmidt wrote: From: David Gibson da...@gibson.dropbear.id.au This adds support for then new reset htab ioctl which allows qemu to properly cleanup the MMU hash table when the guest is reset. With the corresponding kernel support, reset of a guest

Re: Request VFIO inclusion in linux-next

2012-06-27 Thread Dan Carpenter
On Mon, Jun 25, 2012 at 10:55:52PM -0600, Alex Williamson wrote: Hi, VFIO has been kicking around for well over a year now and has been posted numerous times for review. The pre-requirements are finally available in linux-next (or will be in the 20120626 build) so I'd like to request a new

Re: [PATCH 2/4] KVM: Use __print_hex() for kvm_emulate_insn tracepoint

2012-06-27 Thread Steven Rostedt
[ Added Avi] On Wed, 2012-06-27 at 09:41 +0900, Namhyung Kim wrote: From: Namhyung Kim namhyung@lge.com The kvm_emulate_insn tracepoint used __print_insn() for printing its instructions. However it makes the format of the event hard to parse as it reveals TP internals. Fortunately,

Re: [PATCH 2/4] KVM: Use __print_hex() for kvm_emulate_insn tracepoint

2012-06-27 Thread Avi Kivity
On 06/27/2012 03:49 PM, Steven Rostedt wrote: [ Added Avi] On Wed, 2012-06-27 at 09:41 +0900, Namhyung Kim wrote: From: Namhyung Kim namhyung@lge.com The kvm_emulate_insn tracepoint used __print_insn() for printing its instructions. However it makes the format of the event hard to

Re: [PATCH 2/4] KVM: Use __print_hex() for kvm_emulate_insn tracepoint

2012-06-27 Thread Steven Rostedt
On Wed, 2012-06-27 at 15:54 +0300, Avi Kivity wrote: Acked-by: Avi Kivity a...@redhat.com Thanks Avi! Some time ago we discussed moving the trace-cmd plugins to /lib/modules, which would make this trace display as mov %edx,(%eax) instead of 89 10, even for non-trace-cmd users. Was there

Re: [PATCH v2 5/6] kvm: KVM_EOIFD, an eventfd for EOIs

2012-06-27 Thread Gleb Natapov
On Tue, Jun 26, 2012 at 11:10:08PM -0600, Alex Williamson wrote: This new ioctl enables an eventfd to be triggered when an EOI is written for a specified irqchip pin. By default this is a simple notification, but we can also tie the eoifd to a level irqfd, which enables the irqchip pin to be

Re: [PATCH v2 1/6] kvm: Pass kvm_irqfd to functions

2012-06-27 Thread Cornelia Huck
On Tue, 26 Jun 2012 23:09:04 -0600 Alex Williamson alex.william...@redhat.com wrote: Prune this down to just the struct kvm_irqfd so we can avoid changing function definition for every flag or field we use. Signed-off-by: Alex Williamson alex.william...@redhat.com I'm currently trying to

Re: [PATCH v2 5/6] kvm: KVM_EOIFD, an eventfd for EOIs

2012-06-27 Thread Alex Williamson
On Wed, 2012-06-27 at 16:58 +0300, Gleb Natapov wrote: On Tue, Jun 26, 2012 at 11:10:08PM -0600, Alex Williamson wrote: This new ioctl enables an eventfd to be triggered when an EOI is written for a specified irqchip pin. By default this is a simple notification, but we can also tie the

Re: [PATCH v2 1/6] kvm: Pass kvm_irqfd to functions

2012-06-27 Thread Alex Williamson
On Wed, 2012-06-27 at 12:35 +0300, Michael S. Tsirkin wrote: On Tue, Jun 26, 2012 at 11:09:04PM -0600, Alex Williamson wrote: Prune this down to just the struct kvm_irqfd so we can avoid changing function definition for every flag or field we use. Signed-off-by: Alex Williamson

Re: [PATCH v2 0/6] kvm: level triggered irqfd support

2012-06-27 Thread Alex Williamson
On Wed, 2012-06-27 at 12:58 +0300, Michael S. Tsirkin wrote: On Tue, Jun 26, 2012 at 11:08:52PM -0600, Alex Williamson wrote: Ok, let's see how this flies. I actually quite like this, so be gentle tearing it apart ;) I just couldn't bring myself to contort KVM_IRQFD into something

Re: [PATCH] kvm: First step to push iothread lock out of inner run loop

2012-06-27 Thread Jan Kiszka
On 2012-06-26 21:34, Marcelo Tosatti wrote: The following plan would allow progressive convertion to parallel operation. Jan mentioned the MMIO handler-MMIO handler deadlock in a private message. Jan: if there is recursive MMIO accesses, you can detect that and skip such MMIO handlers in

Re: [PATCH 5/6 v5] deal with guest panicked event accoring to -onpanic parameter

2012-06-27 Thread Jan Kiszka
On 2012-06-27 09:02, Wen Congyang wrote: When the guest is panicked, it will write 0x1 to the port KVM_PV_PORT. So if qemu reads 0x1 from this port, we can do the folloing three things according to the parameter -onpanic: 1. emit QEVENT_GUEST_PANICKED only 2. emit QEVENT_GUEST_PANICKED and

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Alex Williamson
On Wed, 2012-06-27 at 14:38 +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:22:54PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 01:20:24PM +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:03:46PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 12:13:43PM

Re: [PATCH v2 5/6] kvm: KVM_EOIFD, an eventfd for EOIs

2012-06-27 Thread Gleb Natapov
On Wed, Jun 27, 2012 at 08:29:04AM -0600, Alex Williamson wrote: On Wed, 2012-06-27 at 16:58 +0300, Gleb Natapov wrote: On Tue, Jun 26, 2012 at 11:10:08PM -0600, Alex Williamson wrote: This new ioctl enables an eventfd to be triggered when an EOI is written for a specified irqchip pin.

Re: [Qemu-devel] [PATCH 5/6 v5] deal with guest panicked event accoring to -onpanic parameter

2012-06-27 Thread Cornelia Huck
On Wed, 27 Jun 2012 15:02:23 +0800 Wen Congyang we...@cn.fujitsu.com wrote: When the guest is panicked, it will write 0x1 to the port KVM_PV_PORT. So if qemu reads 0x1 from this port, we can do the folloing three things according to the parameter -onpanic: 1. emit QEVENT_GUEST_PANICKED only

Re: [Qemu-devel] [PATCH 5/6 v5] deal with guest panicked event accoring to -onpanic parameter

2012-06-27 Thread Daniel P. Berrange
On Wed, Jun 27, 2012 at 04:52:32PM +0200, Cornelia Huck wrote: On Wed, 27 Jun 2012 15:02:23 +0800 Wen Congyang we...@cn.fujitsu.com wrote: When the guest is panicked, it will write 0x1 to the port KVM_PV_PORT. So if qemu reads 0x1 from this port, we can do the folloing three things

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Michael S. Tsirkin
On Wed, Jun 27, 2012 at 08:41:57AM -0600, Alex Williamson wrote: On Wed, 2012-06-27 at 14:38 +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:22:54PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at 01:20:24PM +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at

Re: [PATCH] kvm: don't clear level from irqfd

2012-06-27 Thread Gleb Natapov
On Wed, Jun 27, 2012 at 06:00:57PM +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 08:41:57AM -0600, Alex Williamson wrote: On Wed, 2012-06-27 at 14:38 +0300, Michael S. Tsirkin wrote: On Wed, Jun 27, 2012 at 01:22:54PM +0300, Gleb Natapov wrote: On Wed, Jun 27, 2012 at

[PATCH v2 00/26] Big big real mode improvements

2012-06-27 Thread Avi Kivity
This patchset fixes several bugs in the emulator and in vmx invalid guest state emulation. They are sufficient to boot several Linux and Windows guests, so the last patch turns vmx invalid guest state emulation on by default. The first patch is a little hacky; we should try to emulate svm here

[PATCH v2 01/26] KVM: VMX: Return correct CPL during transition to protected mode

2012-06-27 Thread Avi Kivity
In protected mode, the CPL is defined as the lower two bits of CS, as set by the last far jump. But during the transition to protected mode, there is no last far jump, so we need to return zero (the inherited real mode CPL). Fix by reading CPL from the cache during the transition. This isn't

[PATCH v2 02/26] KVM: Split cpuid register access from computation

2012-06-27 Thread Avi Kivity
Introduce kvm_cpuid() to perform the leaf limit check and calculate register values, and let kvm_emulate_cpuid() just handle reading and writing the registers from/to the vcpu. This allows us to reuse kvm_cpuid() in a context where directly reading and writing registers is not desired.

[PATCH v2 03/26] KVM: x86 emulator: change -get_cpuid() accessor to use the x86 semantics

2012-06-27 Thread Avi Kivity
Instead of getting an exact leaf, follow the spec and fall back to the last main leaf instead. This lets us easily emulate the cpuid instruction in the emulator. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/include/asm/kvm_emulate.h | 4 +-- arch/x86/kvm/emulate.c | 53

[PATCH v2 04/26] KVM: x86 emulator: emulate cpuid

2012-06-27 Thread Avi Kivity
Opcode 0F A2. Used by Linux during the mode change trampoline while in a state that is not virtualizable on vmx without unrestricted_guest, so we need to emulate it is emulate_invalid_guest_state=1. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 16 +++- 1

[PATCH v2 05/26] KVM: x86 emulator: allow loading null SS in long mode

2012-06-27 Thread Avi Kivity
Null SS is valid in long mode; allow loading it. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index db95a55..fe4340f 100644 ---

[PATCH 5/5] KVM: x86 emulator: implement LTR

2012-06-27 Thread Avi Kivity
Opcode 0F 00 /3. Encountered during Windows XP secondary processor bringup. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index

[PATCH 3/5] KVM: x86 emulator: make read_segment_descriptor() return the address

2012-06-27 Thread Avi Kivity
Some operations want to modify the descriptor later on, so save the address for future use. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c

[PATCH v2 09/26] KVM: x86 emulator: emulate LEAVE

2012-06-27 Thread Avi Kivity
Opcode c9; used by some variants of Windows during boot, in big real mode. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index

[PATCH v2 10/26] KVM: x86 emulator: initialize memop

2012-06-27 Thread Avi Kivity
memop is not initialized; this can lead to a two-byte operation following a 4-byte operation to see garbage values. Usually truncation fixes things fot us later on, but at least in one case (call abs) it doesn't. Fix by moving memop to the auto-initialized field area. Signed-off-by: Avi Kivity

[PATCH v2 07/26] KVM: VMX: Relax check on unusable segment

2012-06-27 Thread Avi Kivity
Some userspace (e.g. QEMU 1.1) munge the d and g bits of segment descriptors, causing us not to recognize them as unusable segments with emulate_invalid_guest_state=1. Relax the check by testing for segment not present (a non-present segment cannot be usable). Signed-off-by: Avi Kivity

[PATCH v2 11/26] KVM: Fix SS default ESP/EBP based addressing

2012-06-27 Thread Avi Kivity
We correctly default to SS when BP is used as a base in 16-bit address mode, but we don't do that for 32-bit mode. Fix by adjusting the default to SS when either ESP or EBP is used as the base register. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 17 ++---

[PATCH v2 13/26] KVM: VMX: Fix interrupt exit condition during emulation

2012-06-27 Thread Avi Kivity
Checking EFLAGS.IF is incorrect as we might be in interrupt shadow. If that is the case, the main loop will notice that and not inject the interrupt, causing an endless loop. Fix by using vmx_interrupt_allowed() to check if we can inject an interrupt instead. Signed-off-by: Avi Kivity

[PATCH v2 14/26] KVM: VMX: Continue emulating after batch exhausted

2012-06-27 Thread Avi Kivity
If we return early from an invalid guest state emulation loop, make sure we return to it later if the guest state is still invalid. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c

[PATCH v2 15/26] KVM: x86 emulator: emulate LAHF

2012-06-27 Thread Avi Kivity
Opcode 9F. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 5053e9e..90b549e 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@

[PATCH v2 16/26] KVM: x86 emulator: fix byte-sized MOVZX/MOVSX

2012-06-27 Thread Avi Kivity
Commit 2adb5ad9fe1 removed ByteOp from MOVZX/MOVSX, replacing them by SrcMem8, but neglected to fix the dependency in the emulation code on ByteOp. This caused the instruction not to have any effect in some circumstances. Fix by replacing the check for ByteOp with the equivalent src.op_bytes ==

[PATCH v2 17/26] KVM: x86 emulator: split push logic from push opcode emulation

2012-06-27 Thread Avi Kivity
This allows us to reuse the code without populating ctxt-src and overriding ctxt-op_bytes. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index

[PATCH v2 18/26] KVM: x86 emulator: implement ENTER

2012-06-27 Thread Avi Kivity
Opcode C8. Only ENTER with lexical nesting depth 0 is implemented, since others are very rare. We'll fail emulation if nonzero lexical depth is used so data is not corrupted. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 28 +++- 1 file changed,

[PATCH v2 19/26] KVM: VMX: Stop invalid guest state emulation on pending event

2012-06-27 Thread Avi Kivity
Process the event, possibly injecting an interrupt, before continuing. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/vmx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 26e6bdf..661df185 100644 --- a/arch/x86/kvm/vmx.c +++

[PATCH v2 20/26] KVM: VMX: Improve error reporting during invalid guest state emulation

2012-06-27 Thread Avi Kivity
If instruction emulation fails, report it properly to userspace. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/vmx.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 661df185..591dcea 100644 ---

[PATCH v2 24/26] KVM: x86 emulator: make loading TR set the busy bit

2012-06-27 Thread Avi Kivity
Guest software doesn't actually depend on it, but vmx will refuse us entry if we don't. Set the bit in both the cached segment and memory, just to be nice. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff

[PATCH 1/5] KVM: x86 emulator: emulate BSWAP

2012-06-27 Thread Avi Kivity
Opcodes 0F C8 - 0F CF. Used by the SeaBIOS cdrom code (though not in big real mode). Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c

[PATCH v2 06/26] KVM: x86 emulator: fix LIDT/LGDT in long mode

2012-06-27 Thread Avi Kivity
The operand size for these instructions is 8 bytes in long mode, even without a REX prefix. Set it explicitly. Triggered while booting Linux with emulate_invalid_guest_state=1. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 4 1 file changed, 4 insertions(+) diff

[PATCH v2 21/26] KVM: x86 emulator: emulate BSWAP

2012-06-27 Thread Avi Kivity
Opcodes 0F C8 - 0F CF. Used by the SeaBIOS cdrom code (though not in big real mode). Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c

[PATCH v2 25/26] KVM: x86 emulator: implement LTR

2012-06-27 Thread Avi Kivity
Opcode 0F 00 /3. Encountered during Windows XP secondary processor bringup. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 92a1add..97d9a99

Re: [PATCH v2 5/6] kvm: KVM_EOIFD, an eventfd for EOIs

2012-06-27 Thread Michael S. Tsirkin
On Tue, Jun 26, 2012 at 11:10:08PM -0600, Alex Williamson wrote: +static void eoifd_event(struct kvm_irq_ack_notifier *notifier) +{ + struct _eoifd *eoifd; + + eoifd = container_of(notifier, struct _eoifd, notifier); + + if (eoifd-source) + kvm_set_irq(eoifd-kvm,

[PATCH v2 26/26] KVM: VMX: Emulate invalid guest state by default

2012-06-27 Thread Avi Kivity
Our emulation should be complete enough that we can emulate guests while they are in big real mode, or in a mode transition that is not virtualizable without unrestricted guest support. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v2 23/26] KVM: x86 emulator: make read_segment_descriptor() return the address

2012-06-27 Thread Avi Kivity
Some operations want to modify the descriptor later on, so save the address for future use. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index

[PATCH v2 22/26] KVM: x86 emulator: emulate LLDT

2012-06-27 Thread Avi Kivity
Opcode 0F 00 /2. Used by isolinux durign the protected mode transition. Signed-off-by: Avi Kivity a...@redhat.com --- arch/x86/kvm/emulate.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index cfa5cc3..7b575ad

  1   2   3   >