Re: [PATCH 2/3] KVM: improve trace events of vmexit/mmio/ioport

2012-01-17 Thread David Ahern
On 01/17/2012 07:32 PM, Xiao Guangrong wrote:
>> There is an ongoing 'discussion' about modifying existing tracepoints
>> which your proposed patch violates. This is the start of it:
>>
> 
> 
> Hmm, i think we can still add completed tracepoints in the new version kernel,
> if old version kernel is used, we can fall back to use kvm_entry instead?

Yes, new ones are ok. I was referring to the tracepoints like kvm_pio
where you added the vcpu_id. And it is not really necessary: with
kvm_entry tracepoints it is easy to correlate vcpu to tid and even
without you still get thread base samples so events happening on a
thread are all the sample vcpu (even if you don't know whether that is
vcpu 0, 1, 2, etc).

> 
> And there is a exception for mmio read, in current code, the mmio read event 
> is
> actually used to trace the time when then read emulation is completed, i think
> we can add a tracepoint like mmio_read_begin to trace the start time of mmio 
> read.
> So:
> - for the new kernel, we use mmio_read_begion and kvm_mmio(READ...) to 
> calculate
>   start time and end time.
> - for the old kernel, we use kvm_exit and kvm_mmio(READ...) to calculate 
> start time
>   and end time.
> 
> Your idea?
> 

I did play around with it a bit more today.

My concern would be adding more events may make things more precise, but
it adds more overhead and I am not sure the precision is worth it. For
example on my laptop (Penryn Core 2; a lab server with a xeon E5560
processor is much faster):

0.02 kvm_exit reason IO_INSTRUCTION rip 0x806d0e30 info 710048 0
0.03 kvm_emulate_insn 0:806d0e30: e4 71
0.01 kvm_pio pio_read at 0x71 size 1 count 1
0.01 kvm_userspace_exit reason KVM_EXIT_IO (2)
0.03 kvm_set_irq gsi 8 level 0 source 0
0.01 kvm_pic_set_irq chip 1 pin 0 (edge|masked)
0.01 kvm_ioapic_set_irq pin 8 dst 1 vec=209 (Fixed|logical|edge)
 total exit time: 0.16

The first column is the delta-time between successive events for a vcpu.
Most of those events are in the rounded up microsecond range. Moving on
to the subsequent kvm_entry shows a total VMENTRY run time of 5 usecs:
ie., 16 usecs on a VMEXIT with 7 tracepoints and 5 usecs spent in a VMENTRY.

What I am getting at is that the cost of the tracepoints becomes a
significant overhead. If it costs 500nsec or 1usec to generate an event
and the time in a VMENTRY is only 5 usecs the tracepoint is a large part
of the time.

David
--
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: [Qemu-devel] general protection fault

2012-01-17 Thread Dyweni - KVM

Hi All,

I'm getting a very similar error when running oprofile on the 
host...same version of oprofile...




general protection fault:  [#1] PREEMPT SMP
CPU 5
Modules linked in: iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi 
vboxnetadp vboxnetflt vboxdrv nvidia(P)


Pid: 1498, comm: oprofiled Tainted: P
3.1.6-gentoo-20120114-0749 #1 MSI MS-7578/NF750-G55 (MS-7578)
RIP: 0010:[]  [] 
raw_notifier_chain_register+0x18/0x40

RSP: 0018:88022ed4dbb8  EFLAGS: 00010206
RAX: 65526d6562574955 RBX: 8172b4b0 RCX: 81733ff8
RDX:  RSI: 8172b4b0 RDI: 817ae968
RBP: 88022ed4dbb8 R08: 81734ef0 R09: 
R10: 3000 R11: 1600 R12: 81734ef0
R13: e160 R14: 8172b520 R15: 0005
FS:  7f7179020700() GS:88033fd4() 
knlGS:f75a36c0

CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0062a000 CR3: 000327cd8000 CR4: 06e0
DR0: 0001 DR1: 0002 DR2: 0001
DR3: 000a DR6: 0ff0 DR7: 0400
Process oprofiled (pid: 1498, threadinfo 88022ed4c000, task 
880331635eb0)

Stack:
 88022ed4dbe8 814fa020 88022ed4dbe8 81093dc0
 e160  88022ed4dc48 81470325
 88032a5724a8 0005 88033fd4 0008810f95d0
Call Trace:
 [] register_cpu_notifier+0x20/0x40
 [] ? register_die_notifier+0x20/0x30
 [] nmi_setup+0x1d5/0x200
 [] ? event_buffer_release+0x50/0x50
 [] oprofile_setup+0x39/0xd0
 [] event_buffer_open+0x60/0xa0
 [] ? file_sb_list_add+0x50/0x60
 [] __dentry_open.clone.17+0x12e/0x330
 [] nameidata_to_filp+0x4e/0x60
 [] do_last+0x1b2/0x8f0
 [] path_openat+0xd3/0x3c0
 [] do_filp_open+0x44/0xa0
 [] ? alloc_fd+0xe4/0x130
 [] do_sys_open+0xfc/0x1d0
 [] sys_open+0x1b/0x20
 [] system_call_fastpath+0x16/0x1b
Code: 5b 41 5c 41 5d 41 5e 41 5f c9 c3 31 c0 eb ed 0f 1f 40 00 55 48 8b 
07 48 89 e5 48 85 c0 74 1e 8b 56 10 3b 50 10 7e 09 eb 14 66 90

 50 10 7c 0d 48 8d 78 08 48 8b 40 08 48 85 c0 75 ee 48 89 46
RIP  [] raw_notifier_chain_register+0x18/0x40
 RSP 
---[ end trace 8dcb6b8322e14541 ]---





---
Thanks,
Dyweni

On Tue, 17 Jan 2012 22:40:58 -0600, Dyweni - KVM wrote:


Hi All,

I'm not sure who this falls to, so I've included all all parties that 
I

thought may be relevant.

I'm getting the following error from my guest kernel when running
oprofile within qemu-kvm:

general protection fault:  [#1]
Modules linked in:

Pid: 896, comm: oprofiled Not tainted 3.2.0-rc7-20120117-0605 #1 
Bochs

Bochs
EIP: 0060:[] EFLAGS: 00010086 CPU: 0
EIP is at nmi_cpu_setup.clone.6+0x2e/0xb0
EAX:  EBX: df89894c ECX: c0010005 EDX: 
ESI: 0001 EDI: c168e5c0 EBP: df8addf4 ESP: df8adde4
DS: 007b ES: 007b FS:  GS: 0033 SS: 0068
Process oprofiled (pid: 896, ti=df8ac000 task=df82f780
task.ti=df8ac000)
Stack:
df898980 0004 fff0 d4520880 df8ade08 c1406d4b c1618dfa

 df8ade14 c140464f dc792de0 df8ade28 c1405963 d4520880
dc792de0
 df8ade4c cbfa c111c7fe df84c000 df8ade44 dc77ef80
df8adeec
Call Trace:
[] nmi_setup+0xab/0xd0
[] oprofile_setup+0x2f/0xb0
[] event_buffer_open+0x63/0x90
[] __dentry_open.clone.17+0x1aa/0x2d0
[] ? do_lookup+0x3e/0x370
[] nameidata_to_filp+0x52/0x70
[] ? event_buffer_release+0x40/0x40
[] do_last+0x1e6/0x740
[] path_openat+0x9a/0x320
[] ? page_add_new_anon_rmap+0x74/0x80
[] do_filp_open+0x30/0x80
[] ? alloc_fd+0x2c/0xd0
[] do_sys_open+0xeb/0x1c0
[] sys_open+0x29/0x40
[] sysenter_do_call+0x12/0x22
Code: 57 56 53 83 ec 04 a1 90 e5 68 c1 8b 3d 44 a5 78 c1 8b 1d 8c e5 
68

c1 89 45 f0 8b 07 85 c0 74 1d 31 f6 8d 76 00 8b 0b 85 c9 74 08 32
89 43 04 89 53 08 83 c6 01 83 c3 0c 3b 37 72 e8 8b 77 04
EIP: [] nmi_cpu_setup.clone.6+0x2e/0xb0 SS:ESP 0068:df8adde4
---[ end trace e22f1adcb9f592c1 ]---

My setup is:

QEMU-KVM = 0.14.1-r2
Host Linux Kernel = 3.1.6
Guest Linux Kernel = 3.2-rc7
OProfile = 0.9.6-r1

--
Thanks,
Dyweni

--
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


general protection fault

2012-01-17 Thread Dyweni - KVM

Hi All,

I'm not sure who this falls to, so I've included all all parties that I 
thought may be relevant.


I'm getting the following error from my guest kernel when running 
oprofile within qemu-kvm:


general protection fault:  [#1]
Modules linked in:

Pid: 896, comm: oprofiled Not tainted 3.2.0-rc7-20120117-0605 #1 Bochs 
Bochs

EIP: 0060:[] EFLAGS: 00010086 CPU: 0
EIP is at nmi_cpu_setup.clone.6+0x2e/0xb0
EAX:  EBX: df89894c ECX: c0010005 EDX: 
ESI: 0001 EDI: c168e5c0 EBP: df8addf4 ESP: df8adde4
 DS: 007b ES: 007b FS:  GS: 0033 SS: 0068
Process oprofiled (pid: 896, ti=df8ac000 task=df82f780 
task.ti=df8ac000)

Stack:
 df898980 0004 fff0 d4520880 df8ade08 c1406d4b c1618dfa 

  df8ade14 c140464f dc792de0 df8ade28 c1405963 d4520880 
dc792de0
  df8ade4c cbfa c111c7fe df84c000 df8ade44 dc77ef80 
df8adeec

Call Trace:
 [] nmi_setup+0xab/0xd0
 [] oprofile_setup+0x2f/0xb0
 [] event_buffer_open+0x63/0x90
 [] __dentry_open.clone.17+0x1aa/0x2d0
 [] ? do_lookup+0x3e/0x370
 [] nameidata_to_filp+0x52/0x70
 [] ? event_buffer_release+0x40/0x40
 [] do_last+0x1e6/0x740
 [] path_openat+0x9a/0x320
 [] ? page_add_new_anon_rmap+0x74/0x80
 [] do_filp_open+0x30/0x80
 [] ? alloc_fd+0x2c/0xd0
 [] do_sys_open+0xeb/0x1c0
 [] sys_open+0x29/0x40
 [] sysenter_do_call+0x12/0x22
Code: 57 56 53 83 ec 04 a1 90 e5 68 c1 8b 3d 44 a5 78 c1 8b 1d 8c e5 68 
c1 89 45 f0 8b 07 85 c0 74 1d 31 f6 8d 76 00 8b 0b 85 c9 74 08 <0f> 32 
89 43 04 89 53 08 83 c6 01 83 c3 0c 3b 37 72 e8 8b 77 04

EIP: [] nmi_cpu_setup.clone.6+0x2e/0xb0 SS:ESP 0068:df8adde4
---[ end trace e22f1adcb9f592c1 ]---




My setup is:

QEMU-KVM = 0.14.1-r2
Host Linux Kernel = 3.1.6
Guest Linux Kernel = 3.2-rc7
OProfile = 0.9.6-r1



--
Thanks,
Dyweni

--
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/3] KVM: improve trace events of vmexit/mmio/ioport

2012-01-17 Thread Xiao Guangrong
On 01/18/2012 01:31 AM, David Ahern wrote:



 Relying on the existing tracepoints will make the tool work on older
 kernels.

>>>
>>>
>>> We can drop all new events, but unfortunately, the information of the origin
>>> tracepoints is not enough, at least vcpu_id need be traced in theses events
>>> to match its events. Yes?
>>
>> Yes, and if you don't add completed events, you'll have to use kvm_entry 
>> whose collection adds a lot of overhead.
> 
> 
> vcpus run as threads and hence have their own tid which is available in
> the perf samples.
> 


Nice, thanks for your information, David!

> There is an ongoing 'discussion' about modifying existing tracepoints
> which your proposed patch violates. This is the start of it:
> 


Hmm, i think we can still add completed tracepoints in the new version kernel,
if old version kernel is used, we can fall back to use kvm_entry instead?

And there is a exception for mmio read, in current code, the mmio read event is
actually used to trace the time when then read emulation is completed, i think
we can add a tracepoint like mmio_read_begin to trace the start time of mmio 
read.
So:
- for the new kernel, we use mmio_read_begion and kvm_mmio(READ...) to calculate
  start time and end time.
- for the old kernel, we use kvm_exit and kvm_mmio(READ...) to calculate start 
time
  and end time.

Your idea?

--
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 4/4 V10] Add check for suspended vm in softlockup detector

2012-01-17 Thread Eric B Munson
A suspended VM can cause spurious soft lockup warnings.  To avoid these, the
watchdog now checks if the kernel knows it was stopped by the host and skips
the warning if so.  When the watchdog is reset successfully, clear the guest
paused flag.

Signed-off-by: Eric B Munson 
Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
Changes from V3:
 Clear the PAUSED flag when the watchdog is reset

 kernel/watchdog.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 1d7bca7..91485e5 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -25,6 +25,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 int watchdog_enabled = 1;
@@ -280,6 +281,9 @@ static enum hrtimer_restart watchdog_timer_fn(struct 
hrtimer *hrtimer)
__this_cpu_write(softlockup_touch_sync, false);
sched_clock_tick();
}
+
+   /* Clear the guest paused flag on watchdog reset */
+   kvm_check_and_clear_guest_paused();
__touch_watchdog();
return HRTIMER_RESTART;
}
@@ -292,6 +296,14 @@ static enum hrtimer_restart watchdog_timer_fn(struct 
hrtimer *hrtimer)
 */
duration = is_softlockup(touch_ts);
if (unlikely(duration)) {
+   /*
+* If a virtual machine is stopped by the host it can look to
+* the watchdog like a soft lockup, check to see if the host
+* stopped the vm before we issue the warning
+*/
+   if (kvm_check_and_clear_guest_paused())
+   return HRTIMER_RESTART;
+
/* only warn once */
if (__this_cpu_read(soft_watchdog_warn) == true)
return HRTIMER_RESTART;
-- 
1.7.5.4

--
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 1/4 V10] Add flag to indicate that a vm was stopped by the host

2012-01-17 Thread Eric B Munson
This flag will be used to check if the vm was stopped by the host when a soft
lockup was detected.  The host will set the flag when it stops the guest.  On
resume, the guest will check this flag if a soft lockup is detected and skip
issuing the warning.

Signed-off-by: Eric B Munson 
Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
 arch/x86/include/asm/pvclock-abi.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/pvclock-abi.h 
b/arch/x86/include/asm/pvclock-abi.h
index 35f2d19..6167fd7 100644
--- a/arch/x86/include/asm/pvclock-abi.h
+++ b/arch/x86/include/asm/pvclock-abi.h
@@ -40,5 +40,6 @@ struct pvclock_wall_clock {
 } __attribute__((__packed__));
 
 #define PVCLOCK_TSC_STABLE_BIT (1 << 0)
+#define PVCLOCK_GUEST_STOPPED  (1 << 1)
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_X86_PVCLOCK_ABI_H */
-- 
1.7.5.4

--
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 2/4 V10] Add functions to check if the host has stopped the vm

2012-01-17 Thread Eric B Munson
When a host stops or suspends a VM it will set a flag to show this.  The
watchdog will use these functions to determine if a softlockup is real, or the
result of a suspended VM.

Signed-off-by: Eric B Munson 
asm-generic changes Acked-by: Arnd Bergmann 
Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
Changes from V6:
 Use __this_cpu_and when clearing the PVCLOCK_GUEST_STOPPED flag

Changes from V5:
 Collapse generic stubs into this patch
 check_and_clear_guest_stopped() takes no args and uses __get_cpu_var()
 Include individual definitions in ia64, s390, and powerpc

 arch/ia64/include/asm/kvm_para.h|5 +
 arch/powerpc/include/asm/kvm_para.h |5 +
 arch/s390/include/asm/kvm_para.h|5 +
 arch/x86/include/asm/kvm_para.h |8 
 arch/x86/kernel/kvmclock.c  |   21 +
 include/asm-generic/kvm_para.h  |   14 ++
 6 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-generic/kvm_para.h

diff --git a/arch/ia64/include/asm/kvm_para.h b/arch/ia64/include/asm/kvm_para.h
index 1588aee..2019cb9 100644
--- a/arch/ia64/include/asm/kvm_para.h
+++ b/arch/ia64/include/asm/kvm_para.h
@@ -26,6 +26,11 @@ static inline unsigned int kvm_arch_para_features(void)
return 0;
 }
 
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
 #endif
 
 #endif
diff --git a/arch/powerpc/include/asm/kvm_para.h 
b/arch/powerpc/include/asm/kvm_para.h
index 50533f9..1f80293 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -169,6 +169,11 @@ static inline unsigned int kvm_arch_para_features(void)
return r;
 }
 
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* __POWERPC_KVM_PARA_H__ */
diff --git a/arch/s390/include/asm/kvm_para.h b/arch/s390/include/asm/kvm_para.h
index 6964db2..a988329 100644
--- a/arch/s390/include/asm/kvm_para.h
+++ b/arch/s390/include/asm/kvm_para.h
@@ -149,6 +149,11 @@ static inline unsigned int kvm_arch_para_features(void)
return 0;
 }
 
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
 #endif
 
 #endif /* __S390_KVM_PARA_H */
diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 734c376..99c4bbe 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -95,6 +95,14 @@ struct kvm_vcpu_pv_apf_data {
 extern void kvmclock_init(void);
 extern int kvm_register_clock(char *txt);
 
+#ifdef CONFIG_KVM_CLOCK
+bool kvm_check_and_clear_guest_paused(void);
+#else
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+#endif /* CONFIG_KVMCLOCK */
 
 /* This instruction is vmcall.  On non-VT architectures, it will generate a
  * trap that we will then rewrite to the appropriate instruction.
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 44842d7..bdf6423 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -114,6 +115,26 @@ static void kvm_get_preset_lpj(void)
preset_lpj = lpj;
 }
 
+bool kvm_check_and_clear_guest_paused(void)
+{
+   bool ret = false;
+   struct pvclock_vcpu_time_info *src;
+
+   /*
+* per_cpu() is safe here because this function is only called from
+* timer functions where preemption is already disabled.
+*/
+   WARN_ON(!in_atomic());
+   src = &__get_cpu_var(hv_clock);
+   if ((src->flags & PVCLOCK_GUEST_STOPPED) != 0) {
+   __this_cpu_and(hv_clock.flags, ~PVCLOCK_GUEST_STOPPED);
+   ret = true;
+   }
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(kvm_check_and_clear_guest_paused);
+
 static struct clocksource kvm_clock = {
.name = "kvm-clock",
.read = kvm_clock_get_cycles,
diff --git a/include/asm-generic/kvm_para.h b/include/asm-generic/kvm_para.h
new file mode 100644
index 000..05ef7e7
--- /dev/null
+++ b/include/asm-generic/kvm_para.h
@@ -0,0 +1,14 @@
+#ifndef _ASM_GENERIC_KVM_PARA_H
+#define _ASM_GENERIC_KVM_PARA_H
+
+
+/*
+ * This function is used by architectures that support kvm to avoid issuing
+ * false soft lockup messages.
+ */
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
+#endif
-- 
1.7.5.4

--
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 3/4 V10] Add ioctl for KVMCLOCK_GUEST_STOPPED

2012-01-17 Thread Eric B Munson
Now that we have a flag that will tell the guest it was suspended, create an
interface for that communication using a KVM ioctl.

Signed-off-by: Eric B Munson 

Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
Changes from V9:
 Use kvm_for_each_vcpu to iterate online vcpu's

Changes from V8:
 Make KVM_GUEST_PAUSED a per vm ioctl instead of per vcpu

Changes from V7:
 Define KVM_CAP_GUEST_PAUSED and support check
 Call mark_page_dirty () after setting PVCLOCK_GUEST_STOPPED

Changes from V4:
 Rename KVM_GUEST_PAUSED to KVMCLOCK_GUEST_PAUSED
 Add new ioctl description to api.txt

 Documentation/virtual/kvm/api.txt |   13 +
 arch/x86/kvm/x86.c|   25 +
 include/linux/kvm.h   |3 +++
 3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt 
b/Documentation/virtual/kvm/api.txt
index e1d94bf..1931e5c 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1491,6 +1491,19 @@ following algorithm:
 Some guests configure the LINT1 NMI input to cause a panic, aiding in
 debugging.
 
+4.65 KVMCLOCK_GUEST_PAUSED
+
+Capability: KVM_CAP_GUEST_PAUSED
+Architechtures: Any that implement pvclocks (currently x86 only)
+Type: vcpu ioctl
+Parameters: None
+Returns: 0 on success, -1 on error
+
+This signals to the host kernel that the specified guest is being paused by
+userspace.  The host will set a flag in the pvclock structure that is checked
+from the soft lockup watchdog.  This ioctl can be called during pause or
+unpause.
+
 5. The kvm_run structure
 
 Application code obtains a pointer to the kvm_run structure by
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 14d6cad..1341e3b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2056,6 +2056,7 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_X86_ROBUST_SINGLESTEP:
case KVM_CAP_XSAVE:
case KVM_CAP_ASYNC_PF:
+   case KVM_CAP_GUEST_PAUSED:
case KVM_CAP_GET_TSC_KHZ:
r = 1;
break;
@@ -3061,6 +3062,26 @@ out:
return r;
 }
 
+/*
+ * kvm_set_guest_paused() indicates to the guest kernel that it has been
+ * stopped by the hypervisor.  This function will be called from the host only.
+ */
+static int kvm_set_guest_paused(struct kvm *kvm)
+{
+   struct kvm_vcpu *vcpu;
+   struct pvclock_vcpu_time_info *src;
+   int i;
+
+   kvm_for_each_vcpu(i, vcpu, kvm) {
+   if (!vcpu->arch.time_page)
+   continue;
+   src = &vcpu->arch.hv_clock;
+   src->flags |= PVCLOCK_GUEST_STOPPED;
+   mark_page_dirty(vcpu->kvm, vcpu->arch.time >> PAGE_SHIFT);
+   }
+   return 0;
+}
+
 long kvm_arch_vm_ioctl(struct file *filp,
   unsigned int ioctl, unsigned long arg)
 {
@@ -3351,6 +3372,10 @@ long kvm_arch_vm_ioctl(struct file *filp,
r = 0;
break;
}
+   case KVMCLOCK_GUEST_PAUSED: {
+   r = kvm_set_guest_paused(kvm);
+   break;
+   }
 
default:
;
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 68e67e5..4ffe0df 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -558,6 +558,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_S390_GMAP 71
 #define KVM_CAP_TSC_DEADLINE_TIMER 72
+#define KVM_CAP_GUEST_PAUSED 73
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -763,6 +764,8 @@ struct kvm_clock_data {
 #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO,  0xa8, struct 
kvm_create_spapr_tce)
 /* Available with KVM_CAP_RMA */
 #define KVM_ALLOCATE_RMA _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
+/* VM is being stopped by host */
+#define KVMCLOCK_GUEST_PAUSED_IO(KVMIO,   0xaa)
 
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU(1 << 0)
 
-- 
1.7.5.4

--
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 V7] Guest stop notification

2012-01-17 Thread Eric B Munson
Often when a guest is stopped from the qemu console, it will report spurious
soft lockup warnings on resume.  There are kernel patches being discussed that
will give the host the ability to tell the guest that it is being stopped and
should ignore the soft lockup warning that generates.  This patch uses the qemu
Notifier system to tell the guest it is about to be stopped.

Signed-off-by: Eric B Munson 

Cc: Avi Kivity 
Cc: Marcelo Tosatti 
Cc: Jan Kiszka 
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: kvm@vger.kernel.org
---
Changes from V6:
 Remove unnecessary include

Changes from V5:
 KVM_GUEST_PAUSED is now a per vm ioctl instead of per vcpu

Changes from V4:
 Test if the guest paused capability is available before use

Changes from V3:
 Collapse new state change notification function into existsing function.
 Correct whitespace issues
 Change ioctl name to KVMCLOCK_GUEST_PAUSED
 Use for loop to iterate vpcu's

Changes from V2:
 Move ioctl into hw/kvmclock.c so as other arches can use it as it is
implemented

Changes from V1:
 Remove unnecessary encapsulating function

 hw/kvmclock.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index 3b9fb20..ad79f52 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -64,10 +64,21 @@ static int kvmclock_post_load(void *opaque, int version_id)
 static void kvmclock_vm_state_change(void *opaque, int running,
  RunState state)
 {
+int ret;
 KVMClockState *s = opaque;
+int cap_guest_paused = kvm_check_extension(kvm_state, 
KVM_CAP_GUEST_PAUSED);
 
 if (running) {
 s->clock_valid = false;
+
+if (!cap_guest_paused) {
+return;
+}
+
+ret = kvm_vm_ioctl(kvm_state, KVMCLOCK_GUEST_PAUSED, 0);
+if (ret) {
+fprintf(stderr, "kvmclock_vm_state_change: %s\n", strerror(-ret));
+}
 }
 }
 
-- 
1.7.5.4

--
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 3/4 V9] Add ioctl for KVMCLOCK_GUEST_STOPPED

2012-01-17 Thread Jan Kiszka
On 2012-01-17 19:04, Eric B Munson wrote:
> Now that we have a flag that will tell the guest it was suspended, create an
> interface for that communication using a KVM ioctl.
> 
> Signed-off-by: Eric B Munson 
> 
> Cc: mi...@redhat.com
> Cc: h...@zytor.com
> Cc: ry...@linux.vnet.ibm.com
> Cc: aligu...@us.ibm.com
> Cc: mtosa...@redhat.com
> Cc: jeremy.fitzhardi...@citrix.com
> Cc: kvm@vger.kernel.org
> Cc: linux-a...@vger.kernel.org
> Cc: x...@kernel.org
> Cc: linux-ker...@vger.kernel.org
> ---
> Changes from V8:
>  Make KVM_GUEST_PAUSED a per vm ioctl instead of per vcpu
> 
> Changes from V7:
>  Define KVM_CAP_GUEST_PAUSED and support check
>  Call mark_page_dirty () after setting PVCLOCK_GUEST_STOPPED
> 
> Changes from V4:
>  Rename KVM_GUEST_PAUSED to KVMCLOCK_GUEST_PAUSED
>  Add new ioctl description to api.txt
> 
>  Documentation/virtual/kvm/api.txt |   13 +
>  arch/x86/kvm/x86.c|   26 ++
>  include/linux/kvm.h   |3 +++
>  3 files changed, 42 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/virtual/kvm/api.txt 
> b/Documentation/virtual/kvm/api.txt
> index e1d94bf..1931e5c 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -1491,6 +1491,19 @@ following algorithm:
>  Some guests configure the LINT1 NMI input to cause a panic, aiding in
>  debugging.
>  
> +4.65 KVMCLOCK_GUEST_PAUSED
> +
> +Capability: KVM_CAP_GUEST_PAUSED
> +Architechtures: Any that implement pvclocks (currently x86 only)
> +Type: vcpu ioctl
> +Parameters: None
> +Returns: 0 on success, -1 on error
> +
> +This signals to the host kernel that the specified guest is being paused by
> +userspace.  The host will set a flag in the pvclock structure that is checked
> +from the soft lockup watchdog.  This ioctl can be called during pause or
> +unpause.
> +
>  5. The kvm_run structure
>  
>  Application code obtains a pointer to the kvm_run structure by
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 14d6cad..4661abe 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2056,6 +2056,7 @@ int kvm_dev_ioctl_check_extension(long ext)
>   case KVM_CAP_X86_ROBUST_SINGLESTEP:
>   case KVM_CAP_XSAVE:
>   case KVM_CAP_ASYNC_PF:
> + case KVM_CAP_GUEST_PAUSED:
>   case KVM_CAP_GET_TSC_KHZ:
>   r = 1;
>   break;
> @@ -3061,6 +3062,27 @@ out:
>   return r;
>  }
>  
> +/*
> + * kvm_set_guest_paused() indicates to the guest kernel that it has been
> + * stopped by the hypervisor.  This function will be called from the host 
> only.
> + */
> +static int kvm_set_guest_paused(struct kvm *kvm)
> +{
> + struct kvm_vcpu *vcpu;
> + struct pvclock_vcpu_time_info *src;
> + int i;
> +
> + for (i = 0; i < atomic_read(&kvm->online_vcpus); i++) {
> + vcpu = kvm->vcpus[i];

kvm_for_each_vcpu?

> + if (!vcpu->arch.time_page)
> + continue;
> + src = &vcpu->arch.hv_clock;
> + src->flags |= PVCLOCK_GUEST_STOPPED;
> + mark_page_dirty(vcpu->kvm, vcpu->arch.time >> PAGE_SHIFT);
> + }
> + return 0;
> +}
> +
>  long kvm_arch_vm_ioctl(struct file *filp,
>  unsigned int ioctl, unsigned long arg)
>  {
> @@ -3351,6 +3373,10 @@ long kvm_arch_vm_ioctl(struct file *filp,
>   r = 0;
>   break;
>   }
> + case KVMCLOCK_GUEST_PAUSED: {
> + r = kvm_set_guest_paused(kvm);
> + break;
> + }
>  
>   default:
>   ;
> diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> index 68e67e5..4ffe0df 100644
> --- a/include/linux/kvm.h
> +++ b/include/linux/kvm.h
> @@ -558,6 +558,7 @@ struct kvm_ppc_pvinfo {
>  #define KVM_CAP_PPC_PAPR 68
>  #define KVM_CAP_S390_GMAP 71
>  #define KVM_CAP_TSC_DEADLINE_TIMER 72
> +#define KVM_CAP_GUEST_PAUSED 73
>  
>  #ifdef KVM_CAP_IRQ_ROUTING
>  
> @@ -763,6 +764,8 @@ struct kvm_clock_data {
>  #define KVM_CREATE_SPAPR_TCE   _IOW(KVMIO,  0xa8, struct 
> kvm_create_spapr_tce)
>  /* Available with KVM_CAP_RMA */
>  #define KVM_ALLOCATE_RMA   _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
> +/* VM is being stopped by host */
> +#define KVMCLOCK_GUEST_PAUSED  _IO(KVMIO,   0xaa)
>  
>  #define KVM_DEV_ASSIGN_ENABLE_IOMMU  (1 << 0)
>  

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
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 V6] Guest stop notification

2012-01-17 Thread Jan Kiszka
On 2012-01-17 19:07, Eric B Munson wrote:
> Often when a guest is stopped from the qemu console, it will report spurious
> soft lockup warnings on resume.  There are kernel patches being discussed that
> will give the host the ability to tell the guest that it is being stopped and
> should ignore the soft lockup warning that generates.  This patch uses the 
> qemu
> Notifier system to tell the guest it is about to be stopped.
> 
> Signed-off-by: Eric B Munson 
> 
> Cc: Avi Kivity 
> Cc: Marcelo Tosatti 
> Cc: Jan Kiszka 
> Cc: ry...@linux.vnet.ibm.com
> Cc: aligu...@us.ibm.com
> Cc: kvm@vger.kernel.org
> ---
> Changes from V5:
>  KVM_GUEST_PAUSED is now a per vm ioctl instead of per vcpu
> 
> Changes from V4:
>  Test if the guest paused capability is available before use
> 
> Changes from V3:
>  Collapse new state change notification function into existsing function.
>  Correct whitespace issues
>  Change ioctl name to KVMCLOCK_GUEST_PAUSED
>  Use for loop to iterate vpcu's
> 
> Changes from V2:
>  Move ioctl into hw/kvmclock.c so as other arches can use it as it is
> implemented
> 
> Changes from V1:
>  Remove unnecessary encapsulating function
>  hw/kvmclock.c |   12 
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/kvmclock.c b/hw/kvmclock.c
> index 3b9fb20..a30504c 100644
> --- a/hw/kvmclock.c
> +++ b/hw/kvmclock.c
> @@ -18,6 +18,7 @@
>  #include "sysbus.h"
>  #include "kvm.h"
>  #include "kvmclock.h"
> +#include "cpu-all.h"

Still needed?

>  
>  #include 
>  #include 
> @@ -64,10 +65,21 @@ static int kvmclock_post_load(void *opaque, int 
> version_id)
>  static void kvmclock_vm_state_change(void *opaque, int running,
>   RunState state)
>  {
> +int ret;
>  KVMClockState *s = opaque;
> +int cap_guest_paused = kvm_check_extension(kvm_state, 
> KVM_CAP_GUEST_PAUSED);
>  
>  if (running) {
>  s->clock_valid = false;
> +
> +if (!cap_guest_paused) {
> +return;
> +}
> +
> +ret = kvm_vm_ioctl(kvm_state, KVMCLOCK_GUEST_PAUSED, 0);
> +if (ret) {
> +fprintf(stderr, "kvmclock_vm_state_change: %s\n", 
> strerror(-ret));
> +}
>  }
>  }
>  

Looks good otherwise.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
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 V6] Guest stop notification

2012-01-17 Thread Eric B Munson
Often when a guest is stopped from the qemu console, it will report spurious
soft lockup warnings on resume.  There are kernel patches being discussed that
will give the host the ability to tell the guest that it is being stopped and
should ignore the soft lockup warning that generates.  This patch uses the qemu
Notifier system to tell the guest it is about to be stopped.

Signed-off-by: Eric B Munson 

Cc: Avi Kivity 
Cc: Marcelo Tosatti 
Cc: Jan Kiszka 
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: kvm@vger.kernel.org
---
Changes from V5:
 KVM_GUEST_PAUSED is now a per vm ioctl instead of per vcpu

Changes from V4:
 Test if the guest paused capability is available before use

Changes from V3:
 Collapse new state change notification function into existsing function.
 Correct whitespace issues
 Change ioctl name to KVMCLOCK_GUEST_PAUSED
 Use for loop to iterate vpcu's

Changes from V2:
 Move ioctl into hw/kvmclock.c so as other arches can use it as it is
implemented

Changes from V1:
 Remove unnecessary encapsulating function
 hw/kvmclock.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index 3b9fb20..a30504c 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -18,6 +18,7 @@
 #include "sysbus.h"
 #include "kvm.h"
 #include "kvmclock.h"
+#include "cpu-all.h"
 
 #include 
 #include 
@@ -64,10 +65,21 @@ static int kvmclock_post_load(void *opaque, int version_id)
 static void kvmclock_vm_state_change(void *opaque, int running,
  RunState state)
 {
+int ret;
 KVMClockState *s = opaque;
+int cap_guest_paused = kvm_check_extension(kvm_state, 
KVM_CAP_GUEST_PAUSED);
 
 if (running) {
 s->clock_valid = false;
+
+if (!cap_guest_paused) {
+return;
+}
+
+ret = kvm_vm_ioctl(kvm_state, KVMCLOCK_GUEST_PAUSED, 0);
+if (ret) {
+fprintf(stderr, "kvmclock_vm_state_change: %s\n", strerror(-ret));
+}
 }
 }
 
-- 
1.7.5.4

--
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 3/4 V9] Add ioctl for KVMCLOCK_GUEST_STOPPED

2012-01-17 Thread Eric B Munson
Now that we have a flag that will tell the guest it was suspended, create an
interface for that communication using a KVM ioctl.

Signed-off-by: Eric B Munson 

Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
Changes from V8:
 Make KVM_GUEST_PAUSED a per vm ioctl instead of per vcpu

Changes from V7:
 Define KVM_CAP_GUEST_PAUSED and support check
 Call mark_page_dirty () after setting PVCLOCK_GUEST_STOPPED

Changes from V4:
 Rename KVM_GUEST_PAUSED to KVMCLOCK_GUEST_PAUSED
 Add new ioctl description to api.txt

 Documentation/virtual/kvm/api.txt |   13 +
 arch/x86/kvm/x86.c|   26 ++
 include/linux/kvm.h   |3 +++
 3 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt 
b/Documentation/virtual/kvm/api.txt
index e1d94bf..1931e5c 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1491,6 +1491,19 @@ following algorithm:
 Some guests configure the LINT1 NMI input to cause a panic, aiding in
 debugging.
 
+4.65 KVMCLOCK_GUEST_PAUSED
+
+Capability: KVM_CAP_GUEST_PAUSED
+Architechtures: Any that implement pvclocks (currently x86 only)
+Type: vcpu ioctl
+Parameters: None
+Returns: 0 on success, -1 on error
+
+This signals to the host kernel that the specified guest is being paused by
+userspace.  The host will set a flag in the pvclock structure that is checked
+from the soft lockup watchdog.  This ioctl can be called during pause or
+unpause.
+
 5. The kvm_run structure
 
 Application code obtains a pointer to the kvm_run structure by
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 14d6cad..4661abe 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2056,6 +2056,7 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_X86_ROBUST_SINGLESTEP:
case KVM_CAP_XSAVE:
case KVM_CAP_ASYNC_PF:
+   case KVM_CAP_GUEST_PAUSED:
case KVM_CAP_GET_TSC_KHZ:
r = 1;
break;
@@ -3061,6 +3062,27 @@ out:
return r;
 }
 
+/*
+ * kvm_set_guest_paused() indicates to the guest kernel that it has been
+ * stopped by the hypervisor.  This function will be called from the host only.
+ */
+static int kvm_set_guest_paused(struct kvm *kvm)
+{
+   struct kvm_vcpu *vcpu;
+   struct pvclock_vcpu_time_info *src;
+   int i;
+
+   for (i = 0; i < atomic_read(&kvm->online_vcpus); i++) {
+   vcpu = kvm->vcpus[i];
+   if (!vcpu->arch.time_page)
+   continue;
+   src = &vcpu->arch.hv_clock;
+   src->flags |= PVCLOCK_GUEST_STOPPED;
+   mark_page_dirty(vcpu->kvm, vcpu->arch.time >> PAGE_SHIFT);
+   }
+   return 0;
+}
+
 long kvm_arch_vm_ioctl(struct file *filp,
   unsigned int ioctl, unsigned long arg)
 {
@@ -3351,6 +3373,10 @@ long kvm_arch_vm_ioctl(struct file *filp,
r = 0;
break;
}
+   case KVMCLOCK_GUEST_PAUSED: {
+   r = kvm_set_guest_paused(kvm);
+   break;
+   }
 
default:
;
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 68e67e5..4ffe0df 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -558,6 +558,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_S390_GMAP 71
 #define KVM_CAP_TSC_DEADLINE_TIMER 72
+#define KVM_CAP_GUEST_PAUSED 73
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -763,6 +764,8 @@ struct kvm_clock_data {
 #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO,  0xa8, struct 
kvm_create_spapr_tce)
 /* Available with KVM_CAP_RMA */
 #define KVM_ALLOCATE_RMA _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
+/* VM is being stopped by host */
+#define KVMCLOCK_GUEST_PAUSED_IO(KVMIO,   0xaa)
 
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU(1 << 0)
 
-- 
1.7.5.4

--
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 2/4 V9] Add functions to check if the host has stopped the vm

2012-01-17 Thread Eric B Munson
When a host stops or suspends a VM it will set a flag to show this.  The
watchdog will use these functions to determine if a softlockup is real, or the
result of a suspended VM.

Signed-off-by: Eric B Munson 
asm-generic changes Acked-by: Arnd Bergmann 
Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
Changes from V6:
 Use __this_cpu_and when clearing the PVCLOCK_GUEST_STOPPED flag

Changes from V5:
 Collapse generic stubs into this patch
 check_and_clear_guest_stopped() takes no args and uses __get_cpu_var()
 Include individual definitions in ia64, s390, and powerpc

 arch/ia64/include/asm/kvm_para.h|5 +
 arch/powerpc/include/asm/kvm_para.h |5 +
 arch/s390/include/asm/kvm_para.h|5 +
 arch/x86/include/asm/kvm_para.h |8 
 arch/x86/kernel/kvmclock.c  |   21 +
 include/asm-generic/kvm_para.h  |   14 ++
 6 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-generic/kvm_para.h

diff --git a/arch/ia64/include/asm/kvm_para.h b/arch/ia64/include/asm/kvm_para.h
index 1588aee..2019cb9 100644
--- a/arch/ia64/include/asm/kvm_para.h
+++ b/arch/ia64/include/asm/kvm_para.h
@@ -26,6 +26,11 @@ static inline unsigned int kvm_arch_para_features(void)
return 0;
 }
 
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
 #endif
 
 #endif
diff --git a/arch/powerpc/include/asm/kvm_para.h 
b/arch/powerpc/include/asm/kvm_para.h
index 50533f9..1f80293 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -169,6 +169,11 @@ static inline unsigned int kvm_arch_para_features(void)
return r;
 }
 
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* __POWERPC_KVM_PARA_H__ */
diff --git a/arch/s390/include/asm/kvm_para.h b/arch/s390/include/asm/kvm_para.h
index 6964db2..a988329 100644
--- a/arch/s390/include/asm/kvm_para.h
+++ b/arch/s390/include/asm/kvm_para.h
@@ -149,6 +149,11 @@ static inline unsigned int kvm_arch_para_features(void)
return 0;
 }
 
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
 #endif
 
 #endif /* __S390_KVM_PARA_H */
diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 734c376..99c4bbe 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -95,6 +95,14 @@ struct kvm_vcpu_pv_apf_data {
 extern void kvmclock_init(void);
 extern int kvm_register_clock(char *txt);
 
+#ifdef CONFIG_KVM_CLOCK
+bool kvm_check_and_clear_guest_paused(void);
+#else
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+#endif /* CONFIG_KVMCLOCK */
 
 /* This instruction is vmcall.  On non-VT architectures, it will generate a
  * trap that we will then rewrite to the appropriate instruction.
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 44842d7..bdf6423 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -114,6 +115,26 @@ static void kvm_get_preset_lpj(void)
preset_lpj = lpj;
 }
 
+bool kvm_check_and_clear_guest_paused(void)
+{
+   bool ret = false;
+   struct pvclock_vcpu_time_info *src;
+
+   /*
+* per_cpu() is safe here because this function is only called from
+* timer functions where preemption is already disabled.
+*/
+   WARN_ON(!in_atomic());
+   src = &__get_cpu_var(hv_clock);
+   if ((src->flags & PVCLOCK_GUEST_STOPPED) != 0) {
+   __this_cpu_and(hv_clock.flags, ~PVCLOCK_GUEST_STOPPED);
+   ret = true;
+   }
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(kvm_check_and_clear_guest_paused);
+
 static struct clocksource kvm_clock = {
.name = "kvm-clock",
.read = kvm_clock_get_cycles,
diff --git a/include/asm-generic/kvm_para.h b/include/asm-generic/kvm_para.h
new file mode 100644
index 000..05ef7e7
--- /dev/null
+++ b/include/asm-generic/kvm_para.h
@@ -0,0 +1,14 @@
+#ifndef _ASM_GENERIC_KVM_PARA_H
+#define _ASM_GENERIC_KVM_PARA_H
+
+
+/*
+ * This function is used by architectures that support kvm to avoid issuing
+ * false soft lockup messages.
+ */
+static inline bool kvm_check_and_clear_guest_paused(void)
+{
+   return false;
+}
+
+#endif
-- 
1.7.5.4

--
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 4/4 V9] Add check for suspended vm in softlockup detector

2012-01-17 Thread Eric B Munson
A suspended VM can cause spurious soft lockup warnings.  To avoid these, the
watchdog now checks if the kernel knows it was stopped by the host and skips
the warning if so.  When the watchdog is reset successfully, clear the guest
paused flag.

Signed-off-by: Eric B Munson 
Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
Changes from V3:
 Clear the PAUSED flag when the watchdog is reset

 kernel/watchdog.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 1d7bca7..91485e5 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -25,6 +25,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 int watchdog_enabled = 1;
@@ -280,6 +281,9 @@ static enum hrtimer_restart watchdog_timer_fn(struct 
hrtimer *hrtimer)
__this_cpu_write(softlockup_touch_sync, false);
sched_clock_tick();
}
+
+   /* Clear the guest paused flag on watchdog reset */
+   kvm_check_and_clear_guest_paused();
__touch_watchdog();
return HRTIMER_RESTART;
}
@@ -292,6 +296,14 @@ static enum hrtimer_restart watchdog_timer_fn(struct 
hrtimer *hrtimer)
 */
duration = is_softlockup(touch_ts);
if (unlikely(duration)) {
+   /*
+* If a virtual machine is stopped by the host it can look to
+* the watchdog like a soft lockup, check to see if the host
+* stopped the vm before we issue the warning
+*/
+   if (kvm_check_and_clear_guest_paused())
+   return HRTIMER_RESTART;
+
/* only warn once */
if (__this_cpu_read(soft_watchdog_warn) == true)
return HRTIMER_RESTART;
-- 
1.7.5.4

--
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 0/4 V9] Avoid soft lockup message when KVM is stopped by host

2012-01-17 Thread Eric B Munson
Changes from V8:
Make KVM_GUEST_PAUSED a per vm ioctl instead of per vcpu

Changes from V7:
Define KVM_CAP_GUEST_PAUSED and support check
Call mark_page_dirty () after setting PVCLOCK_GUEST_STOPPED

Changes from V6:
Use __this_cpu_and when clearing the PVCLOCK_GUEST_STOPPED flag

Changes from V5:
Collapse generic check_and_clear_guest_stopped into patch 2
Include check_and_clear_guest_stopped defintion to ia64, s390, and powerpc
Change check_and_clear_guest_stopped to use __get_cpu_var instead of taking the
 cpuid arg.
Protect check_and_clear_guest_stopped declaration with CONFIG_KVM_CLOCK check

Changes from V4:
Rename KVM_GUEST_PAUSED to KVMCLOCK_GUEST_PAUSED
Add description of KVMCLOCK_GUEST_PAUSED ioctl to api.txt

Changes from V3:
Include CC's on patch 3
Drop clear flag ioctl and have the watchdog clear the flag when it is reset

Changes from V2:
A new kvm functions defined in kvm_para.h, the only change to pvclock is the
initial flag definition

Changes from V1:
(Thanks Marcelo)
Host code has all been moved to arch/x86/kvm/x86.c
KVM_PAUSE_GUEST was renamed to KVM_GUEST_PAUSED

When a guest kernel is stopped by the host hypervisor it can look like a soft
lockup to the guest kernel.  This false warning can mask later soft lockup
warnings which may be real.  This patch series adds a method for a host
hypervisor to communicate to a guest kernel that it is being stopped.  The
final patch in the series has the watchdog check this flag when it goes to
issue a soft lockup warning and skip the warning if the guest knows it was
stopped.

It was attempted to solve this in Qemu, but the side effects of saving and
restoring the clock and tsc for each vcpu put the wall clock of the guest behind
by the amount of time of the pause.  This forces a guest to have ntp running
in order to keep the wall clock accurate.

Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: levinsasha...@gmail.com
Cc: Jan Kiszka 
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org

Eric B Munson (4):
  Add flag to indicate that a vm was stopped by the host
  Add functions to check if the host has stopped the vm
  Add ioctl for KVMCLOCK_GUEST_STOPPED
  Add check for suspended vm in softlockup detector

 Documentation/virtual/kvm/api.txt   |   13 +
 arch/ia64/include/asm/kvm_para.h|5 +
 arch/powerpc/include/asm/kvm_para.h |5 +
 arch/s390/include/asm/kvm_para.h|5 +
 arch/x86/include/asm/kvm_para.h |8 
 arch/x86/include/asm/pvclock-abi.h  |1 +
 arch/x86/kernel/kvmclock.c  |   21 +
 arch/x86/kvm/x86.c  |   26 ++
 include/asm-generic/kvm_para.h  |   14 ++
 include/linux/kvm.h |3 +++
 kernel/watchdog.c   |   12 
 11 files changed, 113 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-generic/kvm_para.h

-- 
1.7.5.4

--
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 1/4 V9] Add flag to indicate that a vm was stopped by the host

2012-01-17 Thread Eric B Munson
This flag will be used to check if the vm was stopped by the host when a soft
lockup was detected.  The host will set the flag when it stops the guest.  On
resume, the guest will check this flag if a soft lockup is detected and skip
issuing the warning.

Signed-off-by: Eric B Munson 
Cc: mi...@redhat.com
Cc: h...@zytor.com
Cc: ry...@linux.vnet.ibm.com
Cc: aligu...@us.ibm.com
Cc: mtosa...@redhat.com
Cc: jeremy.fitzhardi...@citrix.com
Cc: kvm@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-ker...@vger.kernel.org
---
 arch/x86/include/asm/pvclock-abi.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/pvclock-abi.h 
b/arch/x86/include/asm/pvclock-abi.h
index 35f2d19..6167fd7 100644
--- a/arch/x86/include/asm/pvclock-abi.h
+++ b/arch/x86/include/asm/pvclock-abi.h
@@ -40,5 +40,6 @@ struct pvclock_wall_clock {
 } __attribute__((__packed__));
 
 #define PVCLOCK_TSC_STABLE_BIT (1 << 0)
+#define PVCLOCK_GUEST_STOPPED  (1 << 1)
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_X86_PVCLOCK_ABI_H */
-- 
1.7.5.4

--
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/3] KVM: improve trace events of vmexit/mmio/ioport

2012-01-17 Thread David Ahern
On 01/17/2012 04:55 AM, Marcelo Tosatti wrote:
> On Tue, Jan 17, 2012 at 10:28:11AM +0800, Xiao Guangrong wrote:
>> On 01/16/2012 05:38 PM, Avi Kivity wrote:
>>
>>> On 01/16/2012 11:32 AM, Xiao Guangrong wrote:
 - trace vcpu_id for these events
>>>
>>> We can infer the vcpu id from the kvm_entry tracepoints, no?
>>>
>>
>>
>> Thanks for your review, Avi!
>>
>> Hmm. i think it is hard to do since the vcpu thread can be scheduled
>> anytime, one example is as follow:
>>
>> CPU 0
>>
>> kvm_entry vcpu 0
>> ..
>> kvm_entry vcpu 1
>> ..
>> event1 occurs
>> ..
>> event2 occurs
>>
>> It is hard to know the event belong to which kvm_entry?
>>
 - add kvm_mmio_done to trace the time when mmio/ioport emulation is 
 completed
>>>
>>> ditto?
>>>
>>
>>
>> I think is ok to get the event end time by using kvm_entry.
>>
>>>
>>> Relying on the existing tracepoints will make the tool work on older
>>> kernels.
>>>
>>
>>
>> We can drop all new events, but unfortunately, the information of the origin
>> tracepoints is not enough, at least vcpu_id need be traced in theses events
>> to match its events. Yes?
> 
> Yes, and if you don't add completed events, you'll have to use kvm_entry 
> whose collection adds a lot of overhead.


vcpus run as threads and hence have their own tid which is available in
the perf samples.

There is an ongoing 'discussion' about modifying existing tracepoints
which your proposed patch violates. This is the start of it:

https://lkml.org/lkml/2012/1/16/41

David
--
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


[KVM-autotest][PATCH 4/4] kvm test: Add multihost migration support to cpuflag test

2012-01-17 Thread Jiří Župka
And additional reduce memory usage of cpu flags test stress
because there is problem with link bandwith during migration.

Signed-off-by: Jiří Župka 
---
 client/tests/kvm/tests.cfg.sample|   43 +-
 client/tests/kvm/tests/cpuflags.py   |  292 ++
 client/virt/deps/test_cpu_flags/stress.c |2 +-
 client/virt/subtests.cfg.sample  |   17 ++-
 4 files changed, 273 insertions(+), 81 deletions(-)

diff --git a/client/tests/kvm/tests.cfg.sample 
b/client/tests/kvm/tests.cfg.sample
index 1d0cec5..6aca6d3 100644
--- a/client/tests/kvm/tests.cfg.sample
+++ b/client/tests/kvm/tests.cfg.sample
@@ -3,17 +3,7 @@
 # This file contains the test set definitions. Define your test sets here.
 
 # Include the base config files.
-include base.cfg
-include subtests.cfg
-include guest-os.cfg
-include guest-hw.cfg
-include cdkeys.cfg
-include virtio-win.cfg
-
-# Virtualization type (kvm or libvirt)
-# TODO: Update code to use vm_library + vm_type + vm_subtype
-#   i.e.(libvirt/none) + (qemu/kvm/xen) + (hvm/paravirt)
-vm_type = kvm
+include tests-config.cfg
 
 # Here you can override the image name for our custom linux and windows guests
 #
@@ -36,24 +26,6 @@ CustomGuestWindows:
 #image_name = /dev/mapper/vg_windows_guest
 #image_raw_device = yes
 
-# Modify/comment the following lines if you wish to modify the paths of the
-# image files, ISO files or qemu binaries.
-#
-# As for the defaults:
-# * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm and
-#   /usr/bin/qemu-img respectively.
-# * All image files are expected under /tmp/kvm_autotest_root/images/
-# * All install iso files are expected under /tmp/kvm_autotest_root/isos/
-# * The parameters cdrom_unattended, floppy, kernel and initrd are generated
-#   by KVM autotest, so remember to put them under a writable location
-#   (for example, the cdrom share can be read only)
-image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/
-cdrom(_.*)? ?<= /tmp/kvm_autotest_root/
-floppy ?<= /tmp/kvm_autotest_root/
-Linux..unattended_install:
-kernel ?<= /tmp/kvm_autotest_root/
-initrd ?<= /tmp/kvm_autotest_root/
-
 # Here are the test sets variants. The variant 'qemu_kvm_windows_quick' is
 # fully commented, the following ones have comments only on noteworthy points
 variants:
@@ -157,18 +129,5 @@ variants:
 only CustomGuestLinux
 only migrate
 
-# You may provide information about the DTM server for WHQL tests here:
-#whql:
-#server_address = 10.20.30.40
-#server_shell_port = 10022
-#server_file_transfer_port = 10023
-# Note that the DTM server must run rss.exe (available under deps/),
-# preferably with administrator privileges.
-
-# Uncomment the following lines to enable abort-on-error mode:
-#abort_on_error = yes
-#kill_vm.* ?= no
-#kill_unresponsive_vms.* ?= no
-
 # Choose your test list from the testsets defined
 only qemu_kvm_f16_quick
diff --git a/client/tests/kvm/tests/cpuflags.py 
b/client/tests/kvm/tests/cpuflags.py
index 6f281d0..b6db381 100644
--- a/client/tests/kvm/tests/cpuflags.py
+++ b/client/tests/kvm/tests/cpuflags.py
@@ -1,4 +1,4 @@
-import logging, re, random, os, time
+import logging, re, random, os, time, socket, pickle
 from autotest_lib.client.common_lib import error, utils
 from autotest_lib.client.virt import kvm_vm
 from autotest_lib.client.virt import virt_utils, aexpect
@@ -14,10 +14,9 @@ def run_cpuflags(test, params, env):
 @param params: Dictionary with the test parameters.
 @param env: Dictionary with test environment.
 """
+virt_utils.Flag.aliases = virt_utils.kvm_map_flags_aliases
 qemu_binary = virt_utils.get_path('.', params.get("qemu_binary", "qemu"))
 
-cpuflags_path = os.path.join(test.virtdir, "deps")
-cpuflags_tar = "cpuflags-test.tar.bz2"
 cpuflags_src = os.path.join(test.virtdir, "deps", "test_cpu_flags")
 smp = int(params.get("smp", 1))
 
@@ -25,8 +24,9 @@ def run_cpuflags(test, params, env):
 
 mig_timeout = float(params.get("mig_timeout", "3600"))
 mig_protocol = params.get("migration_protocol", "tcp")
-mig_speed = params.get("mig_speed", "1G")
+mig_speed = params.get("mig_speed", "100M")
 
+multi_host_migration = params.get("multi_host_migration", "no")
 
 class HgFlags(object):
 def __init__(self, cpu_model, extra_flags=set([])):
@@ -62,7 +62,8 @@ def run_cpuflags(test, params, env):
 virtual_flags)
 
 
-def start_guest_with_cpuflags(cpuflags, smp=None):
+def start_guest_with_cpuflags(cpuflags, smp=None, migration=None,
+  wait=True):
 """
 Try to boot guest with special cpu flags and try login in to them.
 """
@@ -74,10 +75,15 @@ def run_cpuflags(test, params, env):
 vm_name = "vm1-cpuflags"
 vm = kvm_vm.VM(vm_name, params_b, test.bindir, env['address_cache'])
 env.register_vm(vm_name, vm)
-vm.create

[KVM-autotest][PATCH 3/4] kvm migration: Repair migration_control.srv to new interface of kvm configs.

2012-01-17 Thread Jiří Župka
There is migration_control.srv which work with old version of kvm config
files (tests.cfg, subtest.cfg, etc..). Because config files was changed
this control code stopped working. This patch repairs this problem and
add new configuration file tests-config.cfg which separate autotest's
configuration and tests configuration. The changes is usefull for
multihost migration tests. Because there is possible to use lot of
configuration from normal tests.

Signed-off-by: Jiří Župka 
---
 client/tests/kvm/migration_control.srv   |   35 +
 client/tests/kvm/tests-config.cfg.sample |   47 ++
 2 files changed, 62 insertions(+), 20 deletions(-)
 create mode 100644 client/tests/kvm/tests-config.cfg.sample

diff --git a/client/tests/kvm/migration_control.srv 
b/client/tests/kvm/migration_control.srv
index c669ccd..11c08d5 100644
--- a/client/tests/kvm/migration_control.srv
+++ b/client/tests/kvm/migration_control.srv
@@ -12,15 +12,12 @@ so there's a distinction between the migration roles 
('dest' or 'source').
 
 import sys, os, commands, glob, shutil, logging, random
 from autotest_lib.server import utils
-from autotest_lib.client.common_lib import cartesian_config
+from autotest_lib.client.common_lib import cartesian_config, error
 
 # Specify the directory of autotest before you start this test
-AUTOTEST_DIR = '/usr/local/autotest'
+AUTOTEST_DIR = job.clientdir
 
-# Specify the root directory that on client machines
-rootdir = '/tmp/kvm_autotest_root'
-
-KVM_DIR = os.path.join(AUTOTEST_DIR, 'client/tests/kvm')
+KVM_DIR = os.path.join(AUTOTEST_DIR, 'tests', 'kvm')
 
 
 def generate_mac_address():
@@ -42,7 +39,7 @@ def run(pair):
 source_at = autotest.Autotest(source)
 dest_at = autotest.Autotest(dest)
 
-cfg_file = os.path.join(KVM_DIR, "tests_base.cfg")
+cfg_file = os.path.join(KVM_DIR, "tests-config.cfg")
 
 if not os.path.exists(cfg_file):
 raise error.JobError("Config file %s was not found", cfg_file)
@@ -50,23 +47,18 @@ def run(pair):
 # Get test set (dictionary list) from the configuration file
 parser = cartesian_config.Parser()
 test_variants = """
-image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/
-cdrom(_.*)? ?<= /tmp/kvm_autotest_root/
-floppy ?<= /tmp/kvm_autotest_root/
-Linux:
-unattended_install:
-kernel ?<= /tmp/kvm_autotest_root/
-initrd ?<= /tmp/kvm_autotest_root/
-qemu_binary = /usr/libexec/qemu-kvm
+qemu_binary = /usr/bin/qemu-kvm
 qemu_img_binary = /usr/bin/qemu-img
+qemu_io_binary = /usr/bin/qemu-io
 only qcow2
 only virtio_net
 only virtio_blk
 only smp2
 only no_pci_assignable
+only no_9p_export
 only smallpages
-only Fedora.14.64
-only migrate_multi_host
+only Fedora.15.64
+only cpuflags_multi_host
 nic_mode = tap
 nic_mac_nic1 = %s
 """ % (generate_mac_address())
@@ -75,13 +67,16 @@ nic_mac_nic1 = %s
 test_dicts = parser.get_dicts()
 
 source_control_file = dest_control_file = """
-kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm')
-sys.path.append(kvm_test_dir)\n
+testname = "kvm"
+bindir = os.path.join(job.testdir, testname)
+job.install_pkg(testname, 'test', bindir)
+
+kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests', 'kvm')
+sys.path.append(kvm_test_dir)
 """
 for params in test_dicts:
 params['srchost'] = source.ip
 params['dsthost'] = dest.ip
-params['rootdir'] = rootdir
 
 source_params = params.copy()
 source_params['role'] = "source"
diff --git a/client/tests/kvm/tests-config.cfg.sample 
b/client/tests/kvm/tests-config.cfg.sample
new file mode 100644
index 000..ec4ae35
--- /dev/null
+++ b/client/tests/kvm/tests-config.cfg.sample
@@ -0,0 +1,47 @@
+# Copy this file to tests.cfg and edit it.
+#
+# This file contains the test set definitions. Define your test sets here.
+
+# Include the base config files.
+include base.cfg
+include subtests.cfg
+include guest-os.cfg
+include guest-hw.cfg
+include cdkeys.cfg
+include virtio-win.cfg
+
+# Virtualization type (kvm or libvirt)
+# TODO: Update code to use vm_library + vm_type + vm_subtype
+#   i.e.(libvirt/none) + (qemu/kvm/xen) + (hvm/paravirt)
+vm_type = kvm
+
+# Modify/comment the following lines if you wish to modify the paths of the
+# image files, ISO files or qemu binaries.
+#
+# As for the defaults:
+# * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm and
+#   /usr/bin/qemu-img respectively.
+# * All image files are expected under /tmp/kvm_autotest_root/images/
+# * All install iso files are expected under /tmp/kvm_autotest_root/isos/
+# * The parameters cdrom_unattended, floppy, kernel and initrd are generated
+#   by KVM autotest, so remember to put them under a writable location
+#   (for example, the cdrom share can be read only)
+image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/
+cdrom(_.*)? ?<= /tmp/kvm_autotest_root/
+floppy ?<= /tmp/kvm_autotest_root/
+Linux..unattended_install:
+kernel ?<= /tmp/kvm_autote

[KVM-autotest][PATCH 2/4] virt: Add aliases to class Flag.

2012-01-17 Thread Jiří Župka
The patch solve problem with doubled  name of cpuflags
sse4_1, sse4.1 etc. in cpuflag test.

Signed-off-by: Jiří Župka 
---
 client/virt/virt_utils.py |   14 --
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/client/virt/virt_utils.py b/client/virt/virt_utils.py
index a367ffe..20ed4ba 100644
--- a/client/virt/virt_utils.py
+++ b/client/virt/virt_utils.py
@@ -1294,8 +1294,12 @@ class Flag(str):
 """
 Class for easy merge cpuflags.
 """
-def __init__(self,  *args, **kwargs):
-super(Flag, self).__init__( *args, **kwargs)
+aliases = {}
+
+def __new__(cls, flag):
+if flag in Flag.aliases:
+flag = Flag.aliases[flag]
+return str.__new__(cls, flag)
 
 def __eq__(self, other):
 s = set(self.split("|"))
@@ -1324,6 +1328,12 @@ kvm_map_flags_to_test = {
 }
 
 
+kvm_map_flags_aliases = {
+'sse4.1'  :'sse4_1',
+'sse4.2'  :'sse4_2',
+}
+
+
 def kvm_flags_to_stresstests(flags):
 """
 Covert [cpu flags] to [tests]
-- 
1.7.7.5

--
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


[KVM-autotest][PATCH 1/4] virt: Check ilegal instruction code

2012-01-17 Thread Jiří Župka
Signed-off-by: Jiří Župka 
---
 client/virt/virt_vm.py |   27 +++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/client/virt/virt_vm.py b/client/virt/virt_vm.py
index 32593c1..c2b6586 100644
--- a/client/virt/virt_vm.py
+++ b/client/virt/virt_vm.py
@@ -133,6 +133,18 @@ class VMDeadKernelCrashError(VMError):
 return ("VM is dead due to a kernel crash:\n%s" % self.kernel_crash)
 
 
+class VMInvalidInstructionCode(VMError):
+def __init__(self, invalid_code):
+VMError.__init__(self, invalid_code)
+self.invalid_code = invalid_code
+
+def __str__(self):
+error = ""
+for invalid_code in self.invalid_code:
+error += "%s" % (invalid_code)
+return ("Invalid instruction is started on VM:\n%s" % error)
+
+
 class VMAddressError(VMError):
 pass
 
@@ -656,6 +668,21 @@ class BaseVM(object):
 raise VMDeadKernelCrashError(match.group(0))
 
 
+def verify_ilegal_instructon(self):
+"""
+Find kernel crash message on the VM serial console.
+
+@raise: VMInvalidInstructionCode, in case a wrong instruction code.
+"""
+if self.serial_console is not None:
+data = self.serial_console.get_output()
+match = re.findall(r".*trap invalid opcode.*\n", data,
+   re.MULTILINE)
+
+if match:
+raise VMInvalidInstructionCode(match)
+
+
 def get_params(self):
 """
 Return the VM's params dict. Most modified params take effect only
-- 
1.7.7.5

--
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


[KVM-autotest] Add multihost migration support to cpuflag

2012-01-17 Thread Jiří Župka
Repairs multihost migration control script in kvm test.
Adds tests-config.cfg.sample to config scripts.
Adds multihost-migration test to cpuflag test.
Repairs some minor bug.

https://github.com/autotest/autotest/pull/144

--
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 call agenda for Tuesday 17

2012-01-17 Thread Juan Quintela
Juan Quintela  wrote:
> Hi
>
> Please send in any agenda items you are interested in covering.

Hi

THere is nothing for the agenda today (I asked really late for it
though, so apologies for that).

Today call gets cancelled.

Happy hacking, Juan.

> Later, Juan.
--
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] pci-assign: Fix multifunction support

2012-01-17 Thread Jan Kiszka
On 2012-01-17 14:23, Alex Williamson wrote:
> 
> 
> - Original Message -
>> On 2012-01-16 18:11, Alex Williamson wrote:
>>> The core PCI code sets the multifunction bit in the header before
>>> calling the device initfn.  For device assignment, we're blasting
>>> that value with the actual hardware value, so nobody sees the
>>> additional functions if the devices isn't physically multifunction.
>>> Switch the HEADER_TYPE to a fully emulated field (all read-only
>>> anyway) and add setting and clearing of the multifunction bit to
>>> match qemu directive.
>>>
>>> Signed-off-by: Alex Williamson 
>>> ---
>>>
>>>  hw/device-assignment.c |8 +++-
>>>  1 files changed, 7 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
>>> index 2a9e66d..7f4a5ec 100644
>>> --- a/hw/device-assignment.c
>>> +++ b/hw/device-assignment.c
>>> @@ -540,6 +540,13 @@ again:
>>>  fprintf(stderr, "%s: read failed, errno = %d\n", __func__,
>>>  errno);
>>>  }
>>>  
>>> +/* Restore or clear multifunction, this is always controlled
>>> by qemu */
>>> +if (pci_dev->dev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
>>> +pci_dev->dev.config[PCI_HEADER_TYPE] |=
>>> PCI_HEADER_TYPE_MULTI_FUNCTION;
>>> +} else {
>>> +pci_dev->dev.config[PCI_HEADER_TYPE] &=
>>> ~PCI_HEADER_TYPE_MULTI_FUNCTION;
>>> +}
>>> +
>>
>> Why have this in get_*real*_device? Why not fix this up at the caller
>> site, i.e. in assigned_initfn? Just for consistency, not a functional
>> issue.
> 
> I chose here because we've just overwritten the emulated config space and we 
> then proceed to clean out the BAR registers.  As this is close to the point 
> where it gets trashed and we're doing other fixup, it seems appropriate.

OK.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
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] pci-assign: Fix multifunction support

2012-01-17 Thread Alex Williamson


- Original Message -
> On 2012-01-16 18:11, Alex Williamson wrote:
> > The core PCI code sets the multifunction bit in the header before
> > calling the device initfn.  For device assignment, we're blasting
> > that value with the actual hardware value, so nobody sees the
> > additional functions if the devices isn't physically multifunction.
> > Switch the HEADER_TYPE to a fully emulated field (all read-only
> > anyway) and add setting and clearing of the multifunction bit to
> > match qemu directive.
> > 
> > Signed-off-by: Alex Williamson 
> > ---
> > 
> >  hw/device-assignment.c |8 +++-
> >  1 files changed, 7 insertions(+), 1 deletions(-)
> > 
> > diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> > index 2a9e66d..7f4a5ec 100644
> > --- a/hw/device-assignment.c
> > +++ b/hw/device-assignment.c
> > @@ -540,6 +540,13 @@ again:
> >  fprintf(stderr, "%s: read failed, errno = %d\n", __func__,
> >  errno);
> >  }
> >  
> > +/* Restore or clear multifunction, this is always controlled
> > by qemu */
> > +if (pci_dev->dev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
> > +pci_dev->dev.config[PCI_HEADER_TYPE] |=
> > PCI_HEADER_TYPE_MULTI_FUNCTION;
> > +} else {
> > +pci_dev->dev.config[PCI_HEADER_TYPE] &=
> > ~PCI_HEADER_TYPE_MULTI_FUNCTION;
> > +}
> > +
> 
> Why have this in get_*real*_device? Why not fix this up at the caller
> site, i.e. in assigned_initfn? Just for consistency, not a functional
> issue.

I chose here because we've just overwritten the emulated config space and we 
then proceed to clean out the BAR registers.  As this is close to the point 
where it gets trashed and we're doing other fixup, it seems appropriate.

> >  /* Clear host resource mapping info.  If we choose not to
> >  register a
> >   * BAR, such as might be the case with the option ROM, we can
> >   get
> >   * confusing, unwritable, residual addresses from the host
> >   here. */
> > @@ -1575,7 +1582,6 @@ static int assigned_initfn(struct PCIDevice
> > *pci_dev)
> >  assigned_dev_direct_config_read(dev, PCI_CLASS_PROG, 3);
> >  assigned_dev_direct_config_read(dev, PCI_CACHE_LINE_SIZE, 1);
> >  assigned_dev_direct_config_read(dev, PCI_LATENCY_TIMER, 1);
> > -assigned_dev_direct_config_read(dev, PCI_HEADER_TYPE, 1);
> >  assigned_dev_direct_config_read(dev, PCI_BIST, 1);
> >  assigned_dev_direct_config_read(dev, PCI_CARDBUS_CIS, 4);
> >  assigned_dev_direct_config_read(dev, PCI_SUBSYSTEM_VENDOR_ID,
> >  2);
> > 
> 
> Looks good otherwise. Is it a regression of the access control
> refactoring?

I believe it's been a latent issue since before the refactoring.  Thanks,

Alex
--
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 v2] KVM: SVM: comment nested paging and virtualization module parameters

2012-01-17 Thread Davidlohr Bueso
From: Davidlohr Bueso 

Also use true instead of 1 for enabling by default.

Signed-off-by: Davidlohr Bueso 
---
 arch/x86/kvm/svm.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index fce3ba0..7bbd17c 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -182,11 +182,13 @@ static bool npt_enabled = true;
 #else
 static bool npt_enabled;
 #endif
-static int npt = 1;
 
+/* allow nested paging (virtualized MMU) for all guests */
+static int npt = true;
 module_param(npt, int, S_IRUGO);
 
-static int nested = 1;
+/* allow nested virtualization in KVM/SVM */
+static int nested = true;
 module_param(nested, int, S_IRUGO);
 
 static void svm_flush_tlb(struct kvm_vcpu *vcpu);
-- 
1.7.4.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: [PATCH] pci-assign: Fix multifunction support

2012-01-17 Thread Jan Kiszka
On 2012-01-16 18:11, Alex Williamson wrote:
> The core PCI code sets the multifunction bit in the header before
> calling the device initfn.  For device assignment, we're blasting
> that value with the actual hardware value, so nobody sees the
> additional functions if the devices isn't physically multifunction.
> Switch the HEADER_TYPE to a fully emulated field (all read-only
> anyway) and add setting and clearing of the multifunction bit to
> match qemu directive.
> 
> Signed-off-by: Alex Williamson 
> ---
> 
>  hw/device-assignment.c |8 +++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 2a9e66d..7f4a5ec 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -540,6 +540,13 @@ again:
>  fprintf(stderr, "%s: read failed, errno = %d\n", __func__, errno);
>  }
>  
> +/* Restore or clear multifunction, this is always controlled by qemu */
> +if (pci_dev->dev.cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
> +pci_dev->dev.config[PCI_HEADER_TYPE] |= 
> PCI_HEADER_TYPE_MULTI_FUNCTION;
> +} else {
> +pci_dev->dev.config[PCI_HEADER_TYPE] &= 
> ~PCI_HEADER_TYPE_MULTI_FUNCTION;
> +}
> +

Why have this in get_*real*_device? Why not fix this up at the caller
site, i.e. in assigned_initfn? Just for consistency, not a functional issue.

>  /* Clear host resource mapping info.  If we choose not to register a
>   * BAR, such as might be the case with the option ROM, we can get
>   * confusing, unwritable, residual addresses from the host here. */
> @@ -1575,7 +1582,6 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
>  assigned_dev_direct_config_read(dev, PCI_CLASS_PROG, 3);
>  assigned_dev_direct_config_read(dev, PCI_CACHE_LINE_SIZE, 1);
>  assigned_dev_direct_config_read(dev, PCI_LATENCY_TIMER, 1);
> -assigned_dev_direct_config_read(dev, PCI_HEADER_TYPE, 1);
>  assigned_dev_direct_config_read(dev, PCI_BIST, 1);
>  assigned_dev_direct_config_read(dev, PCI_CARDBUS_CIS, 4);
>  assigned_dev_direct_config_read(dev, PCI_SUBSYSTEM_VENDOR_ID, 2);
> 

Looks good otherwise. Is it a regression of the access control refactoring?

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
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] kvm: flush the dirty log when unregistering a slot

2012-01-17 Thread Jan Kiszka
On 2012-01-17 12:25, Marcelo Tosatti wrote:
> On Sun, Jan 15, 2012 at 04:17:31PM +0200, Avi Kivity wrote:
>> Otherwise, the dirty log information is lost in the kernel forever.
>>
>> Fixes opensuse-12.1 boot screen, which changes the vga windows rapidly.
>>
>> Signed-off-by: Avi Kivity 
>> ---
>>
>> This patch gives me a deja vu - I'm sure I've fixed exactly the same issue
>> before.
>>
>> Please test.
>>
>>  kvm-all.c |4 
>>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> Applied to uq/master, thanks.

It's already in qemu/master. Maybe you want to rebase uq/master at this
chance.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
--
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 0/2] Remove hack from movsx/movzx decoding

2012-01-17 Thread Marcelo Tosatti
On Mon, Jan 16, 2012 at 03:08:43PM +0200, Avi Kivity wrote:
> movsx/movzx destination operands currently have a hack for the operand size.
> Add OpMem8 and use it to remove the hack.
> 
> I'll wait with this until Nadav's more direct fix is in.
> 
> Avi Kivity (2):
>   KVM: x86 emulator: add 8-bit memory operands
>   KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack
> 
>  arch/x86/kvm/emulate.c |   18 ++
>  1 files changed, 10 insertions(+), 8 deletions(-)

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 3/3] KVM: perf: kvm events analysis tool

2012-01-17 Thread Marcelo Tosatti
On Mon, Jan 16, 2012 at 10:08:40AM +, Stefan Hajnoczi wrote:
> On Mon, Jan 16, 2012 at 9:32 AM, Xiao Guangrong
>  wrote:
> > +DESCRIPTION
> > +---
> > +You can analyze some crucial events and statistics with this
> > +'perf kvm-events' command.
> 
> This line is very general and does not explain which events/statistics
> can be collected or how you can use that information.  I suggest
> making this description more specific.  Explain that this subcommand
> observers kvm.ko tracepoints and annotates/decodes them with
> additional information (this is why I would use this command and not
> raw perf record -e kvm:\*).
> 
> > +       { SVM_EXIT_MONITOR,                     "monitor" }, \
> > +       { SVM_EXIT_MWAIT,                       "mwait" }, \
> > +       { SVM_EXIT_XSETBV,                      "xsetbv" }, \
> > +       { SVM_EXIT_NPF,                         "npf" }
> 
> All this copy-paste could be avoided by sharing this stuff with the
> arch/x86/kvm/ code.

Yes, same for KVM_MAX_VCPUS.

--
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/3] KVM: improve trace events of vmexit/mmio/ioport

2012-01-17 Thread Marcelo Tosatti
On Tue, Jan 17, 2012 at 10:28:11AM +0800, Xiao Guangrong wrote:
> On 01/16/2012 05:38 PM, Avi Kivity wrote:
> 
> > On 01/16/2012 11:32 AM, Xiao Guangrong wrote:
> >> - trace vcpu_id for these events
> > 
> > We can infer the vcpu id from the kvm_entry tracepoints, no?
> > 
> 
> 
> Thanks for your review, Avi!
> 
> Hmm. i think it is hard to do since the vcpu thread can be scheduled
> anytime, one example is as follow:
> 
> CPU 0
> 
> kvm_entry vcpu 0
> ..
> kvm_entry vcpu 1
> ..
> event1 occurs
> ..
> event2 occurs
> 
> It is hard to know the event belong to which kvm_entry?
> 
> >> - add kvm_mmio_done to trace the time when mmio/ioport emulation is 
> >> completed
> > 
> > ditto?
> > 
> 
> 
> I think is ok to get the event end time by using kvm_entry.
> 
> > 
> > Relying on the existing tracepoints will make the tool work on older
> > kernels.
> > 
> 
> 
> We can drop all new events, but unfortunately, the information of the origin
> tracepoints is not enough, at least vcpu_id need be traced in theses events
> to match its events. Yes?

Yes, and if you don't add completed events, you'll have to use kvm_entry 
whose collection adds a lot of overhead.

--
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] kvm: flush the dirty log when unregistering a slot

2012-01-17 Thread Marcelo Tosatti
On Sun, Jan 15, 2012 at 04:17:31PM +0200, Avi Kivity wrote:
> Otherwise, the dirty log information is lost in the kernel forever.
> 
> Fixes opensuse-12.1 boot screen, which changes the vga windows rapidly.
> 
> Signed-off-by: Avi Kivity 
> ---
> 
> This patch gives me a deja vu - I'm sure I've fixed exactly the same issue
> before.
> 
> Please test.
> 
>  kvm-all.c |4 
>  1 files changed, 4 insertions(+), 0 deletions(-)

Applied to uq/master, 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] qemu-kvm: Deprecate time drift fix

2012-01-17 Thread Marcelo Tosatti
On Sun, Jan 15, 2012 at 12:06:12PM +0100, Jan Kiszka wrote:
> From: Jan Kiszka 
> 
> Remove this divergence from upstream. It is practically unused today as
> the default mode is in-kernel irqchip. We keep the command line switch
> for now, adding a warning that there is no effect anymore.
> 
> The feature can be reintroduced to upstream once we have IRQ paths with
> feedback support.
> 
> Signed-off-by: Jan Kiszka 

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] qemu-kvm: Remove kvm subdirectory

2012-01-17 Thread Marcelo Tosatti
On Sun, Jan 15, 2012 at 03:18:14PM +0100, Jan Kiszka wrote:
> Nothing useful remaining there.
> 
> Signed-off-by: Jan Kiszka 

Done, 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] KVM: do not #GP on perf MSR writes when vPMU is disabled

2012-01-17 Thread Marcelo Tosatti
On Sun, Jan 15, 2012 at 02:17:22PM +0200, Gleb Natapov wrote:
> Return to behaviour perf MSR had before introducing vPMU in case vPMU
> is disabled. Some guests access those registers unconditionally and do
> not expect it to fail.
> 
> Signed-off-by: Gleb Natapov 

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


[PATCH 3/3] KVM: MMU: Remove unused kvm parameter from rmap_next()

2012-01-17 Thread Takuya Yoshikawa
Signed-off-by: Takuya Yoshikawa 
---
 arch/x86/kvm/mmu.c   |   26 +-
 arch/x86/kvm/mmu_audit.c |4 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 7570992..844fcce 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -988,7 +988,7 @@ static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t 
gfn)
return pte_list_add(vcpu, spte, rmapp);
 }
 
-static u64 *rmap_next(struct kvm *kvm, unsigned long *rmapp, u64 *spte)
+static u64 *rmap_next(unsigned long *rmapp, u64 *spte)
 {
return pte_list_next(rmapp, spte);
 }
@@ -1019,7 +1019,7 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
int i, write_protected = 0;
 
rmapp = __gfn_to_rmap(gfn, PT_PAGE_TABLE_LEVEL, slot);
-   spte = rmap_next(kvm, rmapp, NULL);
+   spte = rmap_next(rmapp, NULL);
while (spte) {
BUG_ON(!(*spte & PT_PRESENT_MASK));
rmap_printk("rmap_write_protect: spte %p %llx\n", spte, *spte);
@@ -1027,14 +1027,14 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
mmu_spte_update(spte, *spte & ~PT_WRITABLE_MASK);
write_protected = 1;
}
-   spte = rmap_next(kvm, rmapp, spte);
+   spte = rmap_next(rmapp, spte);
}
 
/* check for huge page mappings */
for (i = PT_DIRECTORY_LEVEL;
 i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) {
rmapp = __gfn_to_rmap(gfn, i, slot);
-   spte = rmap_next(kvm, rmapp, NULL);
+   spte = rmap_next(rmapp, NULL);
while (spte) {
BUG_ON(!(*spte & PT_PRESENT_MASK));
BUG_ON(!is_large_pte(*spte));
@@ -1045,7 +1045,7 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
spte = NULL;
write_protected = 1;
}
-   spte = rmap_next(kvm, rmapp, spte);
+   spte = rmap_next(rmapp, spte);
}
}
 
@@ -1066,7 +1066,7 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long 
*rmapp,
u64 *spte;
int need_tlb_flush = 0;
 
-   while ((spte = rmap_next(kvm, rmapp, NULL))) {
+   while ((spte = rmap_next(rmapp, NULL))) {
BUG_ON(!(*spte & PT_PRESENT_MASK));
rmap_printk("kvm_rmap_unmap_hva: spte %p %llx\n", spte, *spte);
drop_spte(kvm, spte);
@@ -1085,14 +1085,14 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned 
long *rmapp,
 
WARN_ON(pte_huge(*ptep));
new_pfn = pte_pfn(*ptep);
-   spte = rmap_next(kvm, rmapp, NULL);
+   spte = rmap_next(rmapp, NULL);
while (spte) {
BUG_ON(!is_shadow_present_pte(*spte));
rmap_printk("kvm_set_pte_rmapp: spte %p %llx\n", spte, *spte);
need_flush = 1;
if (pte_write(*ptep)) {
drop_spte(kvm, spte);
-   spte = rmap_next(kvm, rmapp, NULL);
+   spte = rmap_next(rmapp, NULL);
} else {
new_spte = *spte &~ (PT64_BASE_ADDR_MASK);
new_spte |= (u64)new_pfn << PAGE_SHIFT;
@@ -1102,7 +1102,7 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned 
long *rmapp,
new_spte &= ~shadow_accessed_mask;
mmu_spte_clear_track_bits(spte);
mmu_spte_set(spte, new_spte);
-   spte = rmap_next(kvm, rmapp, spte);
+   spte = rmap_next(rmapp, spte);
}
}
if (need_flush)
@@ -1176,7 +1176,7 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long 
*rmapp,
if (!shadow_accessed_mask)
return kvm_unmap_rmapp(kvm, rmapp, data);
 
-   spte = rmap_next(kvm, rmapp, NULL);
+   spte = rmap_next(rmapp, NULL);
while (spte) {
int _young;
u64 _spte = *spte;
@@ -1186,7 +1186,7 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long 
*rmapp,
young = 1;
clear_bit(PT_ACCESSED_SHIFT, (unsigned long *)spte);
}
-   spte = rmap_next(kvm, rmapp, spte);
+   spte = rmap_next(rmapp, spte);
}
return young;
 }
@@ -1205,7 +1205,7 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned 
long *rmapp,
if (!shadow_accessed_mask)
goto out;
 
-   spte = rmap_next(kvm, rmapp, NULL);
+   spte = rmap_next(rmapp, NULL);
while (spte) {
u64 _spte = *spte;
BUG_ON(!(_spte & PT_PRESENT_MASK));
@@ -1214,7 +1214,7 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned 
long *rmapp,
young = 1;
  

[PATCH 2/3] KVM: MMU: Remove unused kvm parameter from __gfn_to_rmap()

2012-01-17 Thread Takuya Yoshikawa
Signed-off-by: Takuya Yoshikawa 
---
 arch/x86/kvm/mmu.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 71819c0..7570992 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -946,7 +946,7 @@ static void pte_list_walk(unsigned long *pte_list, 
pte_list_walk_fn fn)
}
 }
 
-static unsigned long *__gfn_to_rmap(struct kvm *kvm, gfn_t gfn, int level,
+static unsigned long *__gfn_to_rmap(gfn_t gfn, int level,
struct kvm_memory_slot *slot)
 {
struct kvm_lpage_info *linfo;
@@ -966,7 +966,7 @@ static unsigned long *gfn_to_rmap(struct kvm *kvm, gfn_t 
gfn, int level)
struct kvm_memory_slot *slot;
 
slot = gfn_to_memslot(kvm, gfn);
-   return __gfn_to_rmap(kvm, gfn, level, slot);
+   return __gfn_to_rmap(gfn, level, slot);
 }
 
 static bool rmap_can_add(struct kvm_vcpu *vcpu)
@@ -1018,7 +1018,7 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
u64 *spte;
int i, write_protected = 0;
 
-   rmapp = __gfn_to_rmap(kvm, gfn, PT_PAGE_TABLE_LEVEL, slot);
+   rmapp = __gfn_to_rmap(gfn, PT_PAGE_TABLE_LEVEL, slot);
spte = rmap_next(kvm, rmapp, NULL);
while (spte) {
BUG_ON(!(*spte & PT_PRESENT_MASK));
@@ -1033,7 +1033,7 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
/* check for huge page mappings */
for (i = PT_DIRECTORY_LEVEL;
 i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) {
-   rmapp = __gfn_to_rmap(kvm, gfn, i, slot);
+   rmapp = __gfn_to_rmap(gfn, i, slot);
spte = rmap_next(kvm, rmapp, NULL);
while (spte) {
BUG_ON(!(*spte & PT_PRESENT_MASK));
-- 
1.7.5.4

--
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 1/3] KVM: MMU: Remove unused kvm_pte_chain

2012-01-17 Thread Takuya Yoshikawa
Signed-off-by: Takuya Yoshikawa 
---
 arch/x86/include/asm/kvm_host.h |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index bd69c93..4610166 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -181,13 +181,6 @@ struct kvm_mmu_memory_cache {
void *objects[KVM_NR_MEM_OBJS];
 };
 
-#define NR_PTE_CHAIN_ENTRIES 5
-
-struct kvm_pte_chain {
-   u64 *parent_ptes[NR_PTE_CHAIN_ENTRIES];
-   struct hlist_node link;
-};
-
 /*
  * kvm_mmu_page_role, below, is defined as:
  *
-- 
1.7.5.4

--
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


KVM call agenda for Tuesday 17

2012-01-17 Thread Juan Quintela

Hi

Please send in any agenda items you are interested in covering.

Later, Juan.
--
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