Re: Reset problem vs. MMIO emulation, hypercalls, etc...

2012-08-05 Thread David Gibson
On Sat, Aug 04, 2012 at 08:30:08AM +1000, Benjamin Herrenschmidt wrote: > On Fri, 2012-08-03 at 14:41 -0300, Marcelo Tosatti wrote: > > > > Hrm, except that doing KVM_RUN with a signal is very cumbersome to do > > > and I couldn't quite find the logic in qemu to do it ... but I might > > > just ha

Re: Reset problem vs. MMIO emulation, hypercalls, etc...

2012-08-05 Thread Benjamin Herrenschmidt
On Sun, 2012-08-05 at 11:55 +0300, Avi Kivity wrote: > > I'm afraid I no longer know the details so closely, the code has > changed > quite a lot. But the self-signal happens in kvm_cpu_exec(), see also > env->exit_request. Right, I think I eventually grasped it :-) It is fairly fragile however,

Re: [PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Eric Northup
On Sun, Aug 5, 2012 at 5:58 AM, Gleb Natapov wrote: > APIC code has a lot of checks for apic presence and apic HW/SW enable > state. Most common configuration is when each vcpu has in kernel apic > and it is fully enabled. This path series uses jump labels to turn checks > to nops in the common c

Re: KVM segfaults with 3.5 while installing ubuntu 12.04

2012-08-05 Thread Stefan Priebe
Am 05.08.2012 17:52, schrieb Stefan Priebe: Am 05.08.2012 12:29, schrieb Avi Kivity: On 08/05/2012 01:08 PM, Stefan Priebe wrote: Am 01.08.2012 11:53, schrieb Avi Kivity: On 08/01/2012 12:42 PM, Stefan Priebe - Profihost AG wrote: Am 01.08.2012 11:33, schrieb Avi Kivity: So here are 3 backtr

Re: KVM segfaults with 3.5 while installing ubuntu 12.04

2012-08-05 Thread Stefan Priebe
Am 05.08.2012 12:29, schrieb Avi Kivity: On 08/05/2012 01:08 PM, Stefan Priebe wrote: Am 01.08.2012 11:53, schrieb Avi Kivity: On 08/01/2012 12:42 PM, Stefan Priebe - Profihost AG wrote: Am 01.08.2012 11:33, schrieb Avi Kivity: So here are 3 backtraces from booting the rescue system: http://p

Re: [PATCHv5 4/4] KVM: emulator: optimize "rep ins" handling.

2012-08-05 Thread Avi Kivity
On 08/05/2012 06:18 PM, Gleb Natapov wrote: > On Sun, Aug 05, 2012 at 06:03:12PM +0300, Avi Kivity wrote: >> On 07/30/2012 05:38 PM, Gleb Natapov wrote: >> > Optimize "rep ins" by allowing emulator to write back more than one >> > datum at a time. Introduce new operand type OP_MEM_STR which tells >

Re: [PATCHv5 4/4] KVM: emulator: optimize "rep ins" handling.

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 06:03:12PM +0300, Avi Kivity wrote: > On 07/30/2012 05:38 PM, Gleb Natapov wrote: > > Optimize "rep ins" by allowing emulator to write back more than one > > datum at a time. Introduce new operand type OP_MEM_STR which tells > > writeback() that dst contains pointer to an ar

Re: [PATCHv5 4/4] KVM: emulator: optimize "rep ins" handling.

2012-08-05 Thread Avi Kivity
On 07/30/2012 05:38 PM, Gleb Natapov wrote: > Optimize "rep ins" by allowing emulator to write back more than one > datum at a time. Introduce new operand type OP_MEM_STR which tells > writeback() that dst contains pointer to an array that should be written > back as opposite to just one data eleme

Re: [PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR.

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 05:48:42PM +0300, Avi Kivity wrote: > On 08/05/2012 05:42 PM, Gleb Natapov wrote: > > On Sun, Aug 05, 2012 at 05:35:21PM +0300, Avi Kivity wrote: > >> On 08/05/2012 03:58 PM, Gleb Natapov wrote: > >> > Usually all APICs are HW enabled so the check can be optimized out. > >>

Re: [PATCHv5 1/4] Provide userspace IO exit completion callback.

2012-08-05 Thread Gleb Natapov
On Thu, Aug 02, 2012 at 04:26:29PM -0300, Marcelo Tosatti wrote: > On Mon, Jul 30, 2012 at 05:38:18PM +0300, Gleb Natapov wrote: > > int r; > > @@ -5554,9 +5568,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, > > struct kvm_run *kvm_run) > > } > > } > > > > - r = c

Re: [PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR.

2012-08-05 Thread Avi Kivity
On 08/05/2012 05:42 PM, Gleb Natapov wrote: > On Sun, Aug 05, 2012 at 05:35:21PM +0300, Avi Kivity wrote: >> On 08/05/2012 03:58 PM, Gleb Natapov wrote: >> > Usually all APICs are HW enabled so the check can be optimized out. >> > >> > Signed-off-by: Gleb Natapov >> > --- >> > arch/x86/kvm/lapic

Re: [PATCH 3/8] KVM: mark apic enabled on start up.

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 05:39:33PM +0300, Avi Kivity wrote: > On 08/05/2012 05:17 PM, Gleb Natapov wrote: > > On Sun, Aug 05, 2012 at 05:14:59PM +0300, Avi Kivity wrote: > >> On 08/05/2012 03:58 PM, Gleb Natapov wrote: > >> > According to SDM apic is enabled on start up. > >> > > >> > Signed-off-b

Re: [PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR.

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 05:35:21PM +0300, Avi Kivity wrote: > On 08/05/2012 03:58 PM, Gleb Natapov wrote: > > Usually all APICs are HW enabled so the check can be optimized out. > > > > Signed-off-by: Gleb Natapov > > --- > > arch/x86/kvm/lapic.c | 29 - > > arch/x8

Re: [PATCH 3/8] KVM: mark apic enabled on start up.

2012-08-05 Thread Avi Kivity
On 08/05/2012 05:17 PM, Gleb Natapov wrote: > On Sun, Aug 05, 2012 at 05:14:59PM +0300, Avi Kivity wrote: >> On 08/05/2012 03:58 PM, Gleb Natapov wrote: >> > According to SDM apic is enabled on start up. >> > >> > Signed-off-by: Gleb Natapov >> > --- >> > arch/x86/kvm/lapic.c |3 ++- >> > 1

Re: [PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR.

2012-08-05 Thread Avi Kivity
On 08/05/2012 03:58 PM, Gleb Natapov wrote: > Usually all APICs are HW enabled so the check can be optimized out. > > Signed-off-by: Gleb Natapov > --- > arch/x86/kvm/lapic.c | 29 - > arch/x86/kvm/lapic.h |1 + > arch/x86/kvm/x86.c |1 + > 3 files changed

Re: [PATCH 3/8] KVM: mark apic enabled on start up.

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 05:14:59PM +0300, Avi Kivity wrote: > On 08/05/2012 03:58 PM, Gleb Natapov wrote: > > According to SDM apic is enabled on start up. > > > > Signed-off-by: Gleb Natapov > > --- > > arch/x86/kvm/lapic.c |3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > >

Re: [PATCH 4/8] Export jump_label_rate_limit()

2012-08-05 Thread Avi Kivity
On 08/05/2012 03:58 PM, Gleb Natapov wrote: > CC: Jason Baron > CC: Ingo Molnar > CC: Peter Zijlstra > Signed-off-by: Gleb Natapov > --- > kernel/jump_label.c |1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/jump_label.c b/kernel/jump_label.c > index 4304919..60f48fa 100644

Re: [PATCH 3/8] KVM: mark apic enabled on start up.

2012-08-05 Thread Avi Kivity
On 08/05/2012 03:58 PM, Gleb Natapov wrote: > According to SDM apic is enabled on start up. > > Signed-off-by: Gleb Natapov > --- > arch/x86/kvm/lapic.c |3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index 49f4ac0..c3f

Re: [PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 05:00:37PM +0300, Avi Kivity wrote: > On 08/05/2012 04:48 PM, Gleb Natapov wrote: > >> > >> >> During guest boot up, some of these jump keys will change, no? Does > >> >> this mean a stop_machine() or equivalent? I'm worried about real-time > >> >> response or one guest b

Re: [PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Avi Kivity
On 08/05/2012 04:48 PM, Gleb Natapov wrote: >> >> >> During guest boot up, some of these jump keys will change, no? Does >> >> this mean a stop_machine() or equivalent? I'm worried about real-time >> >> response or one guest being affected by another. >> >> >> > Yes, SW enable bit changes durin

Re: [PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 04:42:17PM +0300, Avi Kivity wrote: > On 08/05/2012 04:35 PM, Gleb Natapov wrote: > > On Sun, Aug 05, 2012 at 04:33:02PM +0300, Avi Kivity wrote: > >> On 08/05/2012 03:58 PM, Gleb Natapov wrote: > >> > APIC code has a lot of checks for apic presence and apic HW/SW enable > >

Re: [PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Avi Kivity
On 08/05/2012 04:35 PM, Gleb Natapov wrote: > On Sun, Aug 05, 2012 at 04:33:02PM +0300, Avi Kivity wrote: >> On 08/05/2012 03:58 PM, Gleb Natapov wrote: >> > APIC code has a lot of checks for apic presence and apic HW/SW enable >> > state. Most common configuration is when each vcpu has in kernel

Re: [PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 04:33:02PM +0300, Avi Kivity wrote: > On 08/05/2012 03:58 PM, Gleb Natapov wrote: > > APIC code has a lot of checks for apic presence and apic HW/SW enable > > state. Most common configuration is when each vcpu has in kernel apic > > and it is fully enabled. This path serie

Re: [PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Avi Kivity
On 08/05/2012 03:58 PM, Gleb Natapov wrote: > APIC code has a lot of checks for apic presence and apic HW/SW enable > state. Most common configuration is when each vcpu has in kernel apic > and it is fully enabled. This path series uses jump labels to turn checks > to nops in the common case. >

[PATCH 4/8] Export jump_label_rate_limit()

2012-08-05 Thread Gleb Natapov
CC: Jason Baron CC: Ingo Molnar CC: Peter Zijlstra Signed-off-by: Gleb Natapov --- kernel/jump_label.c |1 + 1 file changed, 1 insertion(+) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index 4304919..60f48fa 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -118,6 +1

[PATCH 7/8] KVM: use jump label to optimize checking for in kernel local apic presence.

2012-08-05 Thread Gleb Natapov
Usually all vcpus have local apic pointer initialized, so the check may be completely skipped. Signed-off-by: Gleb Natapov --- arch/x86/kvm/lapic.c | 62 +++--- arch/x86/kvm/x86.c |7 +- arch/x86/kvm/x86.h |1 + 3 files changed, 41 in

[PATCH 8/8] KVM: inline kvm_apic_present() and kvm_lapic_enabled()

2012-08-05 Thread Gleb Natapov
Those functions are used during interrupt injection. When inlined they become nops on the fast path. Signed-off-by: Gleb Natapov --- arch/x86/kvm/lapic.c | 143 +++--- arch/x86/kvm/lapic.h | 45 +++- 2 files changed, 96 insertions(+), 92

[PATCH 6/8] KVM: use jump label to optimize checking for SW enabled apic in spurious interrupt register

2012-08-05 Thread Gleb Natapov
Usually all APICs are SW enabled so the check can be optimized out. Signed-off-by: Gleb Natapov --- arch/x86/kvm/lapic.c | 39 +++ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 1aa5528..95277

[PATCH 5/8] KVM: use jump label to optimize checking for HW enabled APIC in APIC_BASE MSR.

2012-08-05 Thread Gleb Natapov
Usually all APICs are HW enabled so the check can be optimized out. Signed-off-by: Gleb Natapov --- arch/x86/kvm/lapic.c | 29 - arch/x86/kvm/lapic.h |1 + arch/x86/kvm/x86.c |1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm

[PATCH 3/8] KVM: mark apic enabled on start up.

2012-08-05 Thread Gleb Natapov
According to SDM apic is enabled on start up. Signed-off-by: Gleb Natapov --- arch/x86/kvm/lapic.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 49f4ac0..c3f14fe 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapi

[PATCH 2/8] KVM: use kvm_lapic_set_base() to change apic_base

2012-08-05 Thread Gleb Natapov
Do not change apic_base directly. Use kvm_lapic_set_base() instead. Signed-off-by: Gleb Natapov --- arch/x86/kvm/lapic.c |9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 0cd431c..49f4ac0 100644 --- a/arch/x86/kvm/la

[PATCH 1/8] KVM: clean up kvm_(set|get)_apic_base

2012-08-05 Thread Gleb Natapov
kvm_get_apic_base() needlessly checks irqchip_in_kernel although it does the same no matter what result of the check is. kvm_set_apic_base() also checks for irqchip_in_kernel, but kvm_lapic_set_base() can handle this case. Signed-off-by: Gleb Natapov --- arch/x86/kvm/x86.c | 10 ++ 1 f

[PATCH 0/8] use jump labels to streamline common APIC configuration

2012-08-05 Thread Gleb Natapov
APIC code has a lot of checks for apic presence and apic HW/SW enable state. Most common configuration is when each vcpu has in kernel apic and it is fully enabled. This path series uses jump labels to turn checks to nops in the common case. Gleb Natapov (8): KVM: clean up kvm_(set|get)_apic_b

Re: KVM segfaults with 3.5 while installing ubuntu 12.04

2012-08-05 Thread Avi Kivity
On 08/05/2012 01:08 PM, Stefan Priebe wrote: > Am 01.08.2012 11:53, schrieb Avi Kivity: >> On 08/01/2012 12:42 PM, Stefan Priebe - Profihost AG wrote: >>> Am 01.08.2012 11:33, schrieb Avi Kivity: > So here are 3 backtraces from booting the rescue system: > http://pastebin.com/raw.php?i=xCy2

Re: KVM segfaults with 3.5 while installing ubuntu 12.04

2012-08-05 Thread Stefan Priebe
Am 01.08.2012 11:53, schrieb Avi Kivity: On 08/01/2012 12:42 PM, Stefan Priebe - Profihost AG wrote: Am 01.08.2012 11:33, schrieb Avi Kivity: So here are 3 backtraces from booting the rescue system: http://pastebin.com/raw.php?i=xCy2pEcP To me they all look the same. They are. What version

[PATCH 3/6] arch/powerpc/kvm/e500_tlb.c: fix error return code

2012-08-05 Thread Julia Lawall
From: Julia Lawall Convert a 0 error return code to a negative one, as returned elsewhere in the function. A new label is also added to avoid freeing things that are known to not yet be allocated. A simplified version of the semantic match that finds the first problem is as follows: (http://coc

Re: [PATCH] update KVM_SAVE_MSRS_BEGIN to correct value

2012-08-05 Thread Gleb Natapov
On Sun, Aug 05, 2012 at 12:47:42PM +0300, Avi Kivity wrote: > On 08/03/2012 09:08 PM, Marcelo Tosatti wrote: > > On Wed, Aug 01, 2012 at 05:01:42PM +0300, Gleb Natapov wrote: > >> When MSR_KVM_PV_EOI_EN was added to msrs_to_save array > >> KVM_SAVE_MSRS_BEGIN was not updated accordingly. > >> > >>

Re: [PATCH] update KVM_SAVE_MSRS_BEGIN to correct value

2012-08-05 Thread Avi Kivity
On 08/03/2012 09:08 PM, Marcelo Tosatti wrote: > On Wed, Aug 01, 2012 at 05:01:42PM +0300, Gleb Natapov wrote: >> When MSR_KVM_PV_EOI_EN was added to msrs_to_save array >> KVM_SAVE_MSRS_BEGIN was not updated accordingly. >> >> Signed-off-by: Gleb Natapov > > Applied, thanks. This should go into

Re: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

2012-08-05 Thread Pekka Enberg
On 08/05/2012 11:08 AM, Pekka Enberg wrote: >> Isn't there a capability flag that KVM sets if KVM_SIGNAL_MSI is >> supported? Just store that in 'struct kvm" and switch between >> virtio_pci__signal_msi() and kvm__irq_trigger() depending on wheter the >> flag is set. On Sun, Aug 5, 2012 at 12:14 P

Re: Nested kvm_intel broken on pre 3.3 hosts

2012-08-05 Thread Avi Kivity
On 08/03/2012 01:57 PM, Stefan Bader wrote: >> No, you're backporting the entire feature. All we need is to expose >> RDPMC intercept to the guest. > > Oh well, I thought that was the thing you asked for... Sorry for being unclear. > >> It should be sufficient to backport the bits in >> nested

Re: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

2012-08-05 Thread Sasha Levin
On 08/05/2012 11:08 AM, Pekka Enberg wrote: > On 08/04/2012 01:02 PM, Pekka Enberg wrote: >>> No, it's not running 3.5. We need to support older *host* kernels, >>> though. > > On Sun, Aug 5, 2012 at 10:02 AM, Sasha Levin wrote: >> Do we? Don't we need to support just the kernel that the tool was

Re: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

2012-08-05 Thread Pekka Enberg
On 08/04/2012 01:02 PM, Pekka Enberg wrote: >> No, it's not running 3.5. We need to support older *host* kernels, >> though. On Sun, Aug 5, 2012 at 10:02 AM, Sasha Levin wrote: > Do we? Don't we need to support just the kernel that the tool was > built with? We only do that for *guest kernels* i

Re: Reset problem vs. MMIO emulation, hypercalls, etc...

2012-08-05 Thread Avi Kivity
On 08/04/2012 01:32 AM, Benjamin Herrenschmidt wrote: > On Fri, 2012-08-03 at 15:05 -0300, Marcelo Tosatti wrote: > >> See kvm_arch_process_async_events() call to qemu_system_reset_request() >> in target-i386/kvm.c. >> >> The whole thing is fragile, though: we rely on the order events >> are proc

Re: Reset problem vs. MMIO emulation, hypercalls, etc...

2012-08-05 Thread Avi Kivity
On 08/02/2012 11:29 PM, Benjamin Herrenschmidt wrote: > On Thu, 2012-08-02 at 16:05 +0300, Avi Kivity wrote: >> > Yeah, we stumbled over this chunk as well. So you're saying we >> should delay the reset by invoking a self-signal if we're in such an >> operation? >> >> Yes. Qemu of course already

Re: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

2012-08-05 Thread Sasha Levin
On 08/04/2012 01:02 PM, Pekka Enberg wrote: > On 08/04/2012 11:14 AM, Pekka Enberg wrote: >>> This patch makes 'make check' hang for me. Full boot log below: > > On Sat, Aug 4, 2012 at 12:30 PM, Sasha Levin wrote: >> Is your host kernel running 3.5? The new MSI injection ioctl is a new 3.5 >> fe