All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue
@ 2011-04-16 22:10 ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, kvm, Marcelo Tosatti

The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:

  migration: move some declarations to migration.h (2011-04-15 20:14:54 +0000)

are available in the git repository at:
  git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master

Glauber Costa (3):
      kvm: use kernel-provided para_features instead of statically coming up with new capabilities
      kvm: add kvmclock to its second bit
      kvm: create kvmclock when one of the flags are present

Jan Kiszka (3):
      Break up user and system cpu_interrupt implementations
      Redirect cpu_interrupt to callback handler
      kvm: Install specialized interrupt handler

 cpu-all.h           |   14 ++++++++-
 exec.c              |   18 ++++++++---
 hw/kvmclock.c       |    6 +++-
 kvm-all.c           |   11 +++++++
 target-i386/cpuid.c |    3 +-
 target-i386/kvm.c   |   78 ++++++++++++++++++++++++++++++++-------------------
 6 files changed, 92 insertions(+), 38 deletions(-)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue
@ 2011-04-16 22:10 ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Marcelo Tosatti, qemu-devel, kvm

The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:

  migration: move some declarations to migration.h (2011-04-15 20:14:54 +0000)

are available in the git repository at:
  git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master

Glauber Costa (3):
      kvm: use kernel-provided para_features instead of statically coming up with new capabilities
      kvm: add kvmclock to its second bit
      kvm: create kvmclock when one of the flags are present

Jan Kiszka (3):
      Break up user and system cpu_interrupt implementations
      Redirect cpu_interrupt to callback handler
      kvm: Install specialized interrupt handler

 cpu-all.h           |   14 ++++++++-
 exec.c              |   18 ++++++++---
 hw/kvmclock.c       |    6 +++-
 kvm-all.c           |   11 +++++++
 target-i386/cpuid.c |    3 +-
 target-i386/kvm.c   |   78 ++++++++++++++++++++++++++++++++-------------------
 6 files changed, 92 insertions(+), 38 deletions(-)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/6] kvm: use kernel-provided para_features instead of statically coming up with new capabilities
  2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-16 22:10   ` Marcelo Tosatti
  -1 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, kvm, Glauber Costa, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

Use the features provided by KVM_GET_SUPPORTED_CPUID directly to
mask out features from guest-visible cpuid.

The old get_para_features() mechanism is kept for older kernels that do not implement it.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 target-i386/kvm.c |   78 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 49 insertions(+), 29 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index a13599d..485572f 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -92,6 +92,35 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
     return cpuid;
 }
 
+#ifdef CONFIG_KVM_PARA
+struct kvm_para_features {
+    int cap;
+    int feature;
+} para_features[] = {
+    { KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE },
+    { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
+    { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
+#ifdef KVM_CAP_ASYNC_PF
+    { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
+#endif
+    { -1, -1 }
+};
+
+static int get_para_features(CPUState *env)
+{
+    int i, features = 0;
+
+    for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
+        if (kvm_check_extension(env->kvm_state, para_features[i].cap)) {
+            features |= (1 << para_features[i].feature);
+        }
+    }
+
+    return features;
+}
+#endif
+
+
 uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
                                       uint32_t index, int reg)
 {
@@ -99,6 +128,9 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
     int i, max;
     uint32_t ret = 0;
     uint32_t cpuid_1_edx;
+#ifdef CONFIG_KVM_PARA
+    int has_kvm_features = 0;
+#endif
 
     max = 1;
     while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {
@@ -108,6 +140,11 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
     for (i = 0; i < cpuid->nent; ++i) {
         if (cpuid->entries[i].function == function &&
             cpuid->entries[i].index == index) {
+#ifdef CONFIG_KVM_PARA
+            if (cpuid->entries[i].function == KVM_CPUID_FEATURES) {
+                has_kvm_features = 1;
+            }
+#endif
             switch (reg) {
             case R_EAX:
                 ret = cpuid->entries[i].eax;
@@ -140,38 +177,15 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
 
     qemu_free(cpuid);
 
-    return ret;
-}
-
 #ifdef CONFIG_KVM_PARA
-struct kvm_para_features {
-    int cap;
-    int feature;
-} para_features[] = {
-    { KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE },
-    { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
-    { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
-#ifdef KVM_CAP_ASYNC_PF
-    { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
-#endif
-    { -1, -1 }
-};
-
-static int get_para_features(CPUState *env)
-{
-    int i, features = 0;
-
-    for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
-        if (kvm_check_extension(env->kvm_state, para_features[i].cap)) {
-            features |= (1 << para_features[i].feature);
-        }
+    /* fallback for older kernels */
+    if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
+        ret = get_para_features(env);
     }
-#ifdef KVM_CAP_ASYNC_PF
-    has_msr_async_pf_en = features & (1 << KVM_FEATURE_ASYNC_PF);
 #endif
-    return features;
+
+    return ret;
 }
-#endif /* CONFIG_KVM_PARA */
 
 typedef struct HWPoisonPage {
     ram_addr_t ram_addr;
@@ -397,7 +411,13 @@ int kvm_arch_init_vcpu(CPUState *env)
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_FEATURES;
-    c->eax = env->cpuid_kvm_features & get_para_features(env);
+    c->eax = env->cpuid_kvm_features & kvm_arch_get_supported_cpuid(env,
+                                                KVM_CPUID_FEATURES, 0, R_EAX);
+
+#ifdef KVM_CAP_ASYNC_PF
+    has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
+#endif
+
 #endif
 
     cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH 1/6] kvm: use kernel-provided para_features instead of statically coming up with new capabilities
@ 2011-04-16 22:10   ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Glauber Costa, qemu-devel, kvm, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

Use the features provided by KVM_GET_SUPPORTED_CPUID directly to
mask out features from guest-visible cpuid.

The old get_para_features() mechanism is kept for older kernels that do not implement it.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 target-i386/kvm.c |   78 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 49 insertions(+), 29 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index a13599d..485572f 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -92,6 +92,35 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
     return cpuid;
 }
 
+#ifdef CONFIG_KVM_PARA
+struct kvm_para_features {
+    int cap;
+    int feature;
+} para_features[] = {
+    { KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE },
+    { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
+    { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
+#ifdef KVM_CAP_ASYNC_PF
+    { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
+#endif
+    { -1, -1 }
+};
+
+static int get_para_features(CPUState *env)
+{
+    int i, features = 0;
+
+    for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
+        if (kvm_check_extension(env->kvm_state, para_features[i].cap)) {
+            features |= (1 << para_features[i].feature);
+        }
+    }
+
+    return features;
+}
+#endif
+
+
 uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
                                       uint32_t index, int reg)
 {
@@ -99,6 +128,9 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
     int i, max;
     uint32_t ret = 0;
     uint32_t cpuid_1_edx;
+#ifdef CONFIG_KVM_PARA
+    int has_kvm_features = 0;
+#endif
 
     max = 1;
     while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {
@@ -108,6 +140,11 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
     for (i = 0; i < cpuid->nent; ++i) {
         if (cpuid->entries[i].function == function &&
             cpuid->entries[i].index == index) {
+#ifdef CONFIG_KVM_PARA
+            if (cpuid->entries[i].function == KVM_CPUID_FEATURES) {
+                has_kvm_features = 1;
+            }
+#endif
             switch (reg) {
             case R_EAX:
                 ret = cpuid->entries[i].eax;
@@ -140,38 +177,15 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
 
     qemu_free(cpuid);
 
-    return ret;
-}
-
 #ifdef CONFIG_KVM_PARA
-struct kvm_para_features {
-    int cap;
-    int feature;
-} para_features[] = {
-    { KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE },
-    { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
-    { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
-#ifdef KVM_CAP_ASYNC_PF
-    { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
-#endif
-    { -1, -1 }
-};
-
-static int get_para_features(CPUState *env)
-{
-    int i, features = 0;
-
-    for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
-        if (kvm_check_extension(env->kvm_state, para_features[i].cap)) {
-            features |= (1 << para_features[i].feature);
-        }
+    /* fallback for older kernels */
+    if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
+        ret = get_para_features(env);
     }
-#ifdef KVM_CAP_ASYNC_PF
-    has_msr_async_pf_en = features & (1 << KVM_FEATURE_ASYNC_PF);
 #endif
-    return features;
+
+    return ret;
 }
-#endif /* CONFIG_KVM_PARA */
 
 typedef struct HWPoisonPage {
     ram_addr_t ram_addr;
@@ -397,7 +411,13 @@ int kvm_arch_init_vcpu(CPUState *env)
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_FEATURES;
-    c->eax = env->cpuid_kvm_features & get_para_features(env);
+    c->eax = env->cpuid_kvm_features & kvm_arch_get_supported_cpuid(env,
+                                                KVM_CPUID_FEATURES, 0, R_EAX);
+
+#ifdef KVM_CAP_ASYNC_PF
+    has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
+#endif
+
 #endif
 
     cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 2/6] kvm: add kvmclock to its second bit
  2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-16 22:10   ` Marcelo Tosatti
  -1 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Glauber Costa, qemu-devel, kvm, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

We have two bits that can represent kvmclock in cpuid.
They signal the guest which msr set to use. When we tweak flags
involving this value - specially when we use "-", we have to act on both.

Besides adding it to the kvm features list, we also have to "break" the
assumption represented by the break in lookup_feature.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 target-i386/cpuid.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 814d13e..5e48d35 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = {
 };
 
 static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, NULL,
+    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -193,7 +193,6 @@ static int lookup_feature(uint32_t *pval, const char *s, const char *e,
     for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
         if (*ppc && !altcmp(s, e, *ppc)) {
             *pval |= mask;
-            break;
         }
     return (mask ? 1 : 0);
 }
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH 2/6] kvm: add kvmclock to its second bit
@ 2011-04-16 22:10   ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Glauber Costa, qemu-devel, kvm, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

We have two bits that can represent kvmclock in cpuid.
They signal the guest which msr set to use. When we tweak flags
involving this value - specially when we use "-", we have to act on both.

Besides adding it to the kvm features list, we also have to "break" the
assumption represented by the break in lookup_feature.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 target-i386/cpuid.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 814d13e..5e48d35 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = {
 };
 
 static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, NULL,
+    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -193,7 +193,6 @@ static int lookup_feature(uint32_t *pval, const char *s, const char *e,
     for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
         if (*ppc && !altcmp(s, e, *ppc)) {
             *pval |= mask;
-            break;
         }
     return (mask ? 1 : 0);
 }
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 3/6] kvm: create kvmclock when one of the flags are present
  2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-16 22:10   ` Marcelo Tosatti
  -1 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, kvm, Glauber Costa, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

kvmclock presence can be signalled by two different flags. So for
device creation, we have to test for both.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/kvmclock.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index b6ceddf..004c4ad 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -103,7 +103,11 @@ static SysBusDeviceInfo kvmclock_info = {
 void kvmclock_create(void)
 {
     if (kvm_enabled() &&
-        first_cpu->cpuid_kvm_features & (1ULL << KVM_FEATURE_CLOCKSOURCE)) {
+        first_cpu->cpuid_kvm_features & ((1ULL << KVM_FEATURE_CLOCKSOURCE)
+#ifdef KVM_FEATURE_CLOCKSOURCE2
+        || (1ULL << KVM_FEATURE_CLOCKSOURCE2)
+#endif
+    )) {
         sysbus_create_simple("kvmclock", -1, NULL);
     }
 }
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH 3/6] kvm: create kvmclock when one of the flags are present
@ 2011-04-16 22:10   ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Glauber Costa, qemu-devel, kvm, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

kvmclock presence can be signalled by two different flags. So for
device creation, we have to test for both.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/kvmclock.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index b6ceddf..004c4ad 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -103,7 +103,11 @@ static SysBusDeviceInfo kvmclock_info = {
 void kvmclock_create(void)
 {
     if (kvm_enabled() &&
-        first_cpu->cpuid_kvm_features & (1ULL << KVM_FEATURE_CLOCKSOURCE)) {
+        first_cpu->cpuid_kvm_features & ((1ULL << KVM_FEATURE_CLOCKSOURCE)
+#ifdef KVM_FEATURE_CLOCKSOURCE2
+        || (1ULL << KVM_FEATURE_CLOCKSOURCE2)
+#endif
+    )) {
         sysbus_create_simple("kvmclock", -1, NULL);
     }
 }
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 4/6] Break up user and system cpu_interrupt implementations
  2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-16 22:10   ` Marcelo Tosatti
  -1 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, kvm, Jan Kiszka, Riku Voipio, Marcelo Tosatti

From: Jan Kiszka <jan.kiszka@siemens.com>

Both have only two lines in common, and we will convert the system
service into a callback which is of no use for user mode operation.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 exec.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/exec.c b/exec.c
index b1ee52a..cc0806e 100644
--- a/exec.c
+++ b/exec.c
@@ -1630,6 +1630,7 @@ static void cpu_unlink_tb(CPUState *env)
     spin_unlock(&interrupt_lock);
 }
 
+#ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
 void cpu_interrupt(CPUState *env, int mask)
 {
@@ -1638,7 +1639,6 @@ void cpu_interrupt(CPUState *env, int mask)
     old_mask = env->interrupt_request;
     env->interrupt_request |= mask;
 
-#ifndef CONFIG_USER_ONLY
     /*
      * If called from iothread context, wake the target cpu in
      * case its halted.
@@ -1647,21 +1647,27 @@ void cpu_interrupt(CPUState *env, int mask)
         qemu_cpu_kick(env);
         return;
     }
-#endif
 
     if (use_icount) {
         env->icount_decr.u16.high = 0xffff;
-#ifndef CONFIG_USER_ONLY
         if (!can_do_io(env)
             && (mask & ~old_mask) != 0) {
             cpu_abort(env, "Raised interrupt while not in I/O function");
         }
-#endif
     } else {
         cpu_unlink_tb(env);
     }
 }
 
+#else /* CONFIG_USER_ONLY */
+
+void cpu_interrupt(CPUState *env, int mask)
+{
+    env->interrupt_request |= mask;
+    cpu_unlink_tb(env);
+}
+#endif /* CONFIG_USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask)
 {
     env->interrupt_request &= ~mask;
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH 4/6] Break up user and system cpu_interrupt implementations
@ 2011-04-16 22:10   ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Jan Kiszka, Riku Voipio, qemu-devel, kvm, Marcelo Tosatti

From: Jan Kiszka <jan.kiszka@siemens.com>

Both have only two lines in common, and we will convert the system
service into a callback which is of no use for user mode operation.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 exec.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/exec.c b/exec.c
index b1ee52a..cc0806e 100644
--- a/exec.c
+++ b/exec.c
@@ -1630,6 +1630,7 @@ static void cpu_unlink_tb(CPUState *env)
     spin_unlock(&interrupt_lock);
 }
 
+#ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
 void cpu_interrupt(CPUState *env, int mask)
 {
@@ -1638,7 +1639,6 @@ void cpu_interrupt(CPUState *env, int mask)
     old_mask = env->interrupt_request;
     env->interrupt_request |= mask;
 
-#ifndef CONFIG_USER_ONLY
     /*
      * If called from iothread context, wake the target cpu in
      * case its halted.
@@ -1647,21 +1647,27 @@ void cpu_interrupt(CPUState *env, int mask)
         qemu_cpu_kick(env);
         return;
     }
-#endif
 
     if (use_icount) {
         env->icount_decr.u16.high = 0xffff;
-#ifndef CONFIG_USER_ONLY
         if (!can_do_io(env)
             && (mask & ~old_mask) != 0) {
             cpu_abort(env, "Raised interrupt while not in I/O function");
         }
-#endif
     } else {
         cpu_unlink_tb(env);
     }
 }
 
+#else /* CONFIG_USER_ONLY */
+
+void cpu_interrupt(CPUState *env, int mask)
+{
+    env->interrupt_request |= mask;
+    cpu_unlink_tb(env);
+}
+#endif /* CONFIG_USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask)
 {
     env->interrupt_request &= ~mask;
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 5/6] Redirect cpu_interrupt to callback handler
  2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-16 22:10   ` Marcelo Tosatti
  -1 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, kvm, Jan Kiszka, Marcelo Tosatti

From: Jan Kiszka <jan.kiszka@siemens.com>

This allows to override the interrupt handling of QEMU in system mode.
KVM will make use of it to set a specialized handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 cpu-all.h |   14 +++++++++++++-
 exec.c    |    4 +++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index dc0f2f0..628206e 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -789,7 +789,19 @@ extern CPUState *cpu_single_env;
 #define CPU_INTERRUPT_SIPI   0x800 /* SIPI pending. */
 #define CPU_INTERRUPT_MCE    0x1000 /* (x86 only) MCE pending. */
 
-void cpu_interrupt(CPUState *s, int mask);
+#ifndef CONFIG_USER_ONLY
+typedef void (*CPUInterruptHandler)(CPUState *, int);
+
+extern CPUInterruptHandler cpu_interrupt_handler;
+
+static inline void cpu_interrupt(CPUState *s, int mask)
+{
+    cpu_interrupt_handler(s, mask);
+}
+#else /* USER_ONLY */
+void cpu_interrupt(CPUState *env, int mask);
+#endif /* USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask);
 
 void cpu_exit(CPUState *s);
diff --git a/exec.c b/exec.c
index cc0806e..72f4784 100644
--- a/exec.c
+++ b/exec.c
@@ -1632,7 +1632,7 @@ static void cpu_unlink_tb(CPUState *env)
 
 #ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
-void cpu_interrupt(CPUState *env, int mask)
+static void tcg_handle_interrupt(CPUState *env, int mask)
 {
     int old_mask;
 
@@ -1659,6 +1659,8 @@ void cpu_interrupt(CPUState *env, int mask)
     }
 }
 
+CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
+
 #else /* CONFIG_USER_ONLY */
 
 void cpu_interrupt(CPUState *env, int mask)
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH 5/6] Redirect cpu_interrupt to callback handler
@ 2011-04-16 22:10   ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

This allows to override the interrupt handling of QEMU in system mode.
KVM will make use of it to set a specialized handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 cpu-all.h |   14 +++++++++++++-
 exec.c    |    4 +++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index dc0f2f0..628206e 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -789,7 +789,19 @@ extern CPUState *cpu_single_env;
 #define CPU_INTERRUPT_SIPI   0x800 /* SIPI pending. */
 #define CPU_INTERRUPT_MCE    0x1000 /* (x86 only) MCE pending. */
 
-void cpu_interrupt(CPUState *s, int mask);
+#ifndef CONFIG_USER_ONLY
+typedef void (*CPUInterruptHandler)(CPUState *, int);
+
+extern CPUInterruptHandler cpu_interrupt_handler;
+
+static inline void cpu_interrupt(CPUState *s, int mask)
+{
+    cpu_interrupt_handler(s, mask);
+}
+#else /* USER_ONLY */
+void cpu_interrupt(CPUState *env, int mask);
+#endif /* USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask);
 
 void cpu_exit(CPUState *s);
diff --git a/exec.c b/exec.c
index cc0806e..72f4784 100644
--- a/exec.c
+++ b/exec.c
@@ -1632,7 +1632,7 @@ static void cpu_unlink_tb(CPUState *env)
 
 #ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
-void cpu_interrupt(CPUState *env, int mask)
+static void tcg_handle_interrupt(CPUState *env, int mask)
 {
     int old_mask;
 
@@ -1659,6 +1659,8 @@ void cpu_interrupt(CPUState *env, int mask)
     }
 }
 
+CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
+
 #else /* CONFIG_USER_ONLY */
 
 void cpu_interrupt(CPUState *env, int mask)
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 6/6] kvm: Install specialized interrupt handler
  2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-16 22:10   ` Marcelo Tosatti
  -1 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

KVM only requires to set the raised IRQ in CPUState and to kick the
receiving vcpu if it is remote. Installing a specialized handler allows
potential future changes to the TCG code path without risking KVM side
effects.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 kvm-all.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 1d7e8ea..fd1fbfe 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -651,6 +651,15 @@ static CPUPhysMemoryClient kvm_cpu_phys_memory_client = {
     .log_stop = kvm_log_stop,
 };
 
+static void kvm_handle_interrupt(CPUState *env, int mask)
+{
+    env->interrupt_request |= mask;
+
+    if (!qemu_cpu_is_self(env)) {
+        qemu_cpu_kick(env);
+    }
+}
+
 int kvm_init(void)
 {
     static const char upgrade_note[] =
@@ -759,6 +768,8 @@ int kvm_init(void)
 
     s->many_ioeventfds = kvm_check_many_ioeventfds();
 
+    cpu_interrupt_handler = kvm_handle_interrupt;
+
     return 0;
 
 err:
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH 6/6] kvm: Install specialized interrupt handler
@ 2011-04-16 22:10   ` Marcelo Tosatti
  0 siblings, 0 replies; 24+ messages in thread
From: Marcelo Tosatti @ 2011-04-16 22:10 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

KVM only requires to set the raised IRQ in CPUState and to kick the
receiving vcpu if it is remote. Installing a specialized handler allows
potential future changes to the TCG code path without risking KVM side
effects.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 kvm-all.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 1d7e8ea..fd1fbfe 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -651,6 +651,15 @@ static CPUPhysMemoryClient kvm_cpu_phys_memory_client = {
     .log_stop = kvm_log_stop,
 };
 
+static void kvm_handle_interrupt(CPUState *env, int mask)
+{
+    env->interrupt_request |= mask;
+
+    if (!qemu_cpu_is_self(env)) {
+        qemu_cpu_kick(env);
+    }
+}
+
 int kvm_init(void)
 {
     static const char upgrade_note[] =
@@ -759,6 +768,8 @@ int kvm_init(void)
 
     s->many_ioeventfds = kvm_check_many_ioeventfds();
 
+    cpu_interrupt_handler = kvm_handle_interrupt;
+
     return 0;
 
 err:
-- 
1.7.4.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue
  2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-16 23:57   ` Anthony Liguori
  -1 siblings, 0 replies; 24+ messages in thread
From: Anthony Liguori @ 2011-04-16 23:57 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: qemu-devel, kvm, Glauber Costa, Jan Kiszka

On 04/16/2011 05:10 PM, Marcelo Tosatti wrote:
> The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:
>
>    migration: move some declarations to migration.h (2011-04-15 20:14:54 +0000)
>
> are available in the git repository at:
>    git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
>
> Glauber Costa (3):
>        kvm: use kernel-provided para_features instead of statically coming up with new capabilities

It's hard to follow this logic, but something in this series introduces 
a ton of chatter on stdout.  For instance:


anthony@titi:~/build/qemu$ x86_64-softmmu/qemu-system-x86_64 -hda 
~/images/linux.img -snapshot
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
CPU feature hypervisor not found

This is with or without KVM enabled.

Regards,

Anthony Liguori

>        kvm: add kvmclock to its second bit
>        kvm: create kvmclock when one of the flags are present
>
> Jan Kiszka (3):
>        Break up user and system cpu_interrupt implementations
>        Redirect cpu_interrupt to callback handler
>        kvm: Install specialized interrupt handler
>
>   cpu-all.h           |   14 ++++++++-
>   exec.c              |   18 ++++++++---
>   hw/kvmclock.c       |    6 +++-
>   kvm-all.c           |   11 +++++++
>   target-i386/cpuid.c |    3 +-
>   target-i386/kvm.c   |   78 ++++++++++++++++++++++++++++++++-------------------
>   6 files changed, 92 insertions(+), 38 deletions(-)


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue
@ 2011-04-16 23:57   ` Anthony Liguori
  0 siblings, 0 replies; 24+ messages in thread
From: Anthony Liguori @ 2011-04-16 23:57 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Jan Kiszka, Glauber Costa, qemu-devel, kvm

On 04/16/2011 05:10 PM, Marcelo Tosatti wrote:
> The following changes since commit adc56dda0c4eed62149d28939b7d7e329ad95ae8:
>
>    migration: move some declarations to migration.h (2011-04-15 20:14:54 +0000)
>
> are available in the git repository at:
>    git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
>
> Glauber Costa (3):
>        kvm: use kernel-provided para_features instead of statically coming up with new capabilities

It's hard to follow this logic, but something in this series introduces 
a ton of chatter on stdout.  For instance:


anthony@titi:~/build/qemu$ x86_64-softmmu/qemu-system-x86_64 -hda 
~/images/linux.img -snapshot
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
error: feature "sse2" not available in set
error: bad option value [feature_edx = sse2 sse fxsr mmx pat cmov pge 
sep apic cx8 mce pae msr tsc pse de fpu    mtrr clflush mca pse36]
CPU feature hypervisor not found

This is with or without KVM enabled.

Regards,

Anthony Liguori

>        kvm: add kvmclock to its second bit
>        kvm: create kvmclock when one of the flags are present
>
> Jan Kiszka (3):
>        Break up user and system cpu_interrupt implementations
>        Redirect cpu_interrupt to callback handler
>        kvm: Install specialized interrupt handler
>
>   cpu-all.h           |   14 ++++++++-
>   exec.c              |   18 ++++++++---
>   hw/kvmclock.c       |    6 +++-
>   kvm-all.c           |   11 +++++++
>   target-i386/cpuid.c |    3 +-
>   target-i386/kvm.c   |   78 ++++++++++++++++++++++++++++++++-------------------
>   6 files changed, 92 insertions(+), 38 deletions(-)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/6] kvm: add kvmclock to its second bit
  2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
@ 2011-04-17 11:02     ` Jan Kiszka
  -1 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-04-17 11:02 UTC (permalink / raw)
  To: Marcelo Tosatti
  Cc: Anthony Liguori, Glauber Costa, qemu-devel, kvm, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]

On 2011-04-17 00:10, Marcelo Tosatti wrote:
> From: Glauber Costa <glommer@redhat.com>
> 
> We have two bits that can represent kvmclock in cpuid.
> They signal the guest which msr set to use. When we tweak flags
> involving this value - specially when we use "-", we have to act on both.
> 
> Besides adding it to the kvm features list, we also have to "break" the
> assumption represented by the break in lookup_feature.
> 
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  target-i386/cpuid.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index 814d13e..5e48d35 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = {
>  };
>  
>  static const char *kvm_feature_name[] = {
> -    "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, NULL,
> +    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, NULL, NULL,
>      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
>      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
>      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
> @@ -193,7 +193,6 @@ static int lookup_feature(uint32_t *pval, const char *s, const char *e,
>      for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
>          if (*ppc && !altcmp(s, e, *ppc)) {
>              *pval |= mask;
> -            break;
>          }
>      return (mask ? 1 : 0);
>  }

This is required on top to fix the issues Anthony was seeing:

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 5e48d35..b7e20e8 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -189,12 +189,14 @@ static int lookup_feature(uint32_t *pval, const char *s, const char *e,
 {
     uint32_t mask;
     const char **ppc;
+    int found = 0;
 
     for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
         if (*ppc && !altcmp(s, e, *ppc)) {
             *pval |= mask;
+            found = 1;
         }
-    return (mask ? 1 : 0);
+    return found;
 }
 
 static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH 2/6] kvm: add kvmclock to its second bit
@ 2011-04-17 11:02     ` Jan Kiszka
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-04-17 11:02 UTC (permalink / raw)
  To: Marcelo Tosatti
  Cc: Avi Kivity, Anthony Liguori, Glauber Costa, kvm, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]

On 2011-04-17 00:10, Marcelo Tosatti wrote:
> From: Glauber Costa <glommer@redhat.com>
> 
> We have two bits that can represent kvmclock in cpuid.
> They signal the guest which msr set to use. When we tweak flags
> involving this value - specially when we use "-", we have to act on both.
> 
> Besides adding it to the kvm features list, we also have to "break" the
> assumption represented by the break in lookup_feature.
> 
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  target-i386/cpuid.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index 814d13e..5e48d35 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = {
>  };
>  
>  static const char *kvm_feature_name[] = {
> -    "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, NULL,
> +    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, NULL, NULL,
>      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
>      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
>      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
> @@ -193,7 +193,6 @@ static int lookup_feature(uint32_t *pval, const char *s, const char *e,
>      for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
>          if (*ppc && !altcmp(s, e, *ppc)) {
>              *pval |= mask;
> -            break;
>          }
>      return (mask ? 1 : 0);
>  }

This is required on top to fix the issues Anthony was seeing:

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 5e48d35..b7e20e8 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -189,12 +189,14 @@ static int lookup_feature(uint32_t *pval, const char *s, const char *e,
 {
     uint32_t mask;
     const char **ppc;
+    int found = 0;
 
     for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
         if (*ppc && !altcmp(s, e, *ppc)) {
             *pval |= mask;
+            found = 1;
         }
-    return (mask ? 1 : 0);
+    return found;
 }
 
 static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature
  2011-04-17 11:02     ` [Qemu-devel] " Jan Kiszka
@ 2011-04-19 11:06       ` Jan Kiszka
  -1 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-04-19 11:06 UTC (permalink / raw)
  To: Marcelo Tosatti, Glauber Costa
  Cc: Anthony Liguori, qemu-devel, kvm, Avi Kivity

kvmclock is represented by two feature bits. Therefore, lookup_feature
needs to continue its search even after the first match. Enhance it
accordingly and switch to a bool return type at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 target-i386/cpuid.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

Glauber, could you check/ack this? Marcelo, please respin the series
afterward. I'd like to see all bits upstream and merged back into
qemu-kvm to proceed with switching the latter to upstream's kvm
infrastructure.

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 814d13e..0ac592f 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -182,20 +182,22 @@ static int altcmp(const char *s, const char *e, const char *altstr)
 }
 
 /* search featureset for flag *[s..e), if found set corresponding bit in
- * *pval and return success, otherwise return zero
+ * *pval and return true, otherwise return false
  */
-static int lookup_feature(uint32_t *pval, const char *s, const char *e,
-    const char **featureset)
+static bool lookup_feature(uint32_t *pval, const char *s, const char *e,
+                           const char **featureset)
 {
     uint32_t mask;
     const char **ppc;
+    bool found = false;
 
-    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
+    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) {
         if (*ppc && !altcmp(s, e, *ppc)) {
             *pval |= mask;
-            break;
+            found = true;
         }
-    return (mask ? 1 : 0);
+    }
+    return found;
 }
 
 static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature
@ 2011-04-19 11:06       ` Jan Kiszka
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-04-19 11:06 UTC (permalink / raw)
  To: Marcelo Tosatti, Glauber Costa
  Cc: Anthony Liguori, qemu-devel, kvm, Avi Kivity

kvmclock is represented by two feature bits. Therefore, lookup_feature
needs to continue its search even after the first match. Enhance it
accordingly and switch to a bool return type at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 target-i386/cpuid.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

Glauber, could you check/ack this? Marcelo, please respin the series
afterward. I'd like to see all bits upstream and merged back into
qemu-kvm to proceed with switching the latter to upstream's kvm
infrastructure.

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 814d13e..0ac592f 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -182,20 +182,22 @@ static int altcmp(const char *s, const char *e, const char *altstr)
 }
 
 /* search featureset for flag *[s..e), if found set corresponding bit in
- * *pval and return success, otherwise return zero
+ * *pval and return true, otherwise return false
  */
-static int lookup_feature(uint32_t *pval, const char *s, const char *e,
-    const char **featureset)
+static bool lookup_feature(uint32_t *pval, const char *s, const char *e,
+                           const char **featureset)
 {
     uint32_t mask;
     const char **ppc;
+    bool found = false;
 
-    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
+    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) {
         if (*ppc && !altcmp(s, e, *ppc)) {
             *pval |= mask;
-            break;
+            found = true;
         }
-    return (mask ? 1 : 0);
+    }
+    return found;
 }
 
 static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 2b/6] kvm: add kvmclock to its second bit
  2011-04-17 11:02     ` [Qemu-devel] " Jan Kiszka
@ 2011-04-19 11:06       ` Jan Kiszka
  -1 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-04-19 11:06 UTC (permalink / raw)
  To: Marcelo Tosatti, Glauber Costa
  Cc: Anthony Liguori, qemu-devel, kvm, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

We have two bits that can represent kvmclock in cpuid. They signal the
guest which msr set to use. When we tweak flags involving this value -
specially when we use "-", we have to act on both.

[Jan: factored out lookup_feature changes]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 target-i386/cpuid.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 0ac592f..e479a4d 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = {
 };
 
 static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, NULL,
+    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PATCH v2 2b/6] kvm: add kvmclock to its second bit
@ 2011-04-19 11:06       ` Jan Kiszka
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-04-19 11:06 UTC (permalink / raw)
  To: Marcelo Tosatti, Glauber Costa
  Cc: Anthony Liguori, qemu-devel, kvm, Avi Kivity

From: Glauber Costa <glommer@redhat.com>

We have two bits that can represent kvmclock in cpuid. They signal the
guest which msr set to use. When we tweak flags involving this value -
specially when we use "-", we have to act on both.

[Jan: factored out lookup_feature changes]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 target-i386/cpuid.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 0ac592f..e479a4d 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -73,7 +73,7 @@ static const char *ext3_feature_name[] = {
 };
 
 static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", NULL, "kvm_asyncpf", NULL, NULL, NULL,
+    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature
  2011-04-19 11:06       ` [Qemu-devel] " Jan Kiszka
@ 2011-04-27 18:38         ` Glauber Costa
  -1 siblings, 0 replies; 24+ messages in thread
From: Glauber Costa @ 2011-04-27 18:38 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Anthony Liguori, Marcelo Tosatti, qemu-devel, kvm, Avi Kivity

On Tue, 2011-04-19 at 13:06 +0200, Jan Kiszka wrote:
> kvmclock is represented by two feature bits. Therefore, lookup_feature
> needs to continue its search even after the first match. Enhance it
> accordingly and switch to a bool return type at this chance.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  target-i386/cpuid.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> Glauber, could you check/ack this? Marcelo, please respin the series
> afterward. I'd like to see all bits upstream and merged back into
> qemu-kvm to proceed with switching the latter to upstream's kvm
> infrastructure.

Yes, this patch is okay.

Actually, I did sent out something like this, maybe Marcelo applied only
part of the series?

Anyway, Jan's version is handy, please apply it.

> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index 814d13e..0ac592f 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -182,20 +182,22 @@ static int altcmp(const char *s, const char *e, const char *altstr)
>  }
>  
>  /* search featureset for flag *[s..e), if found set corresponding bit in
> - * *pval and return success, otherwise return zero
> + * *pval and return true, otherwise return false
>   */
> -static int lookup_feature(uint32_t *pval, const char *s, const char *e,
> -    const char **featureset)
> +static bool lookup_feature(uint32_t *pval, const char *s, const char *e,
> +                           const char **featureset)
>  {
>      uint32_t mask;
>      const char **ppc;
> +    bool found = false;
>  
> -    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
> +    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) {
>          if (*ppc && !altcmp(s, e, *ppc)) {
>              *pval |= mask;
> -            break;
> +            found = true;
>          }
> -    return (mask ? 1 : 0);
> +    }
> +    return found;
>  }
>  
>  static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature
@ 2011-04-27 18:38         ` Glauber Costa
  0 siblings, 0 replies; 24+ messages in thread
From: Glauber Costa @ 2011-04-27 18:38 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Anthony Liguori, Marcelo Tosatti, qemu-devel, kvm, Avi Kivity

On Tue, 2011-04-19 at 13:06 +0200, Jan Kiszka wrote:
> kvmclock is represented by two feature bits. Therefore, lookup_feature
> needs to continue its search even after the first match. Enhance it
> accordingly and switch to a bool return type at this chance.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  target-i386/cpuid.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> Glauber, could you check/ack this? Marcelo, please respin the series
> afterward. I'd like to see all bits upstream and merged back into
> qemu-kvm to proceed with switching the latter to upstream's kvm
> infrastructure.

Yes, this patch is okay.

Actually, I did sent out something like this, maybe Marcelo applied only
part of the series?

Anyway, Jan's version is handy, please apply it.

> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index 814d13e..0ac592f 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -182,20 +182,22 @@ static int altcmp(const char *s, const char *e, const char *altstr)
>  }
>  
>  /* search featureset for flag *[s..e), if found set corresponding bit in
> - * *pval and return success, otherwise return zero
> + * *pval and return true, otherwise return false
>   */
> -static int lookup_feature(uint32_t *pval, const char *s, const char *e,
> -    const char **featureset)
> +static bool lookup_feature(uint32_t *pval, const char *s, const char *e,
> +                           const char **featureset)
>  {
>      uint32_t mask;
>      const char **ppc;
> +    bool found = false;
>  
> -    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc)
> +    for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) {
>          if (*ppc && !altcmp(s, e, *ppc)) {
>              *pval |= mask;
> -            break;
> +            found = true;
>          }
> -    return (mask ? 1 : 0);
> +    }
> +    return found;
>  }
>  
>  static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2011-04-27 18:38 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-16 22:10 [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 1/6] kvm: use kernel-provided para_features instead of statically coming up with new capabilities Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 2/6] kvm: add kvmclock to its second bit Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-17 11:02   ` Jan Kiszka
2011-04-17 11:02     ` [Qemu-devel] " Jan Kiszka
2011-04-19 11:06     ` [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature Jan Kiszka
2011-04-19 11:06       ` [Qemu-devel] " Jan Kiszka
2011-04-27 18:38       ` Glauber Costa
2011-04-27 18:38         ` [Qemu-devel] " Glauber Costa
2011-04-19 11:06     ` [PATCH v2 2b/6] kvm: add kvmclock to its second bit Jan Kiszka
2011-04-19 11:06       ` [Qemu-devel] " Jan Kiszka
2011-04-16 22:10 ` [PATCH 3/6] kvm: create kvmclock when one of the flags are present Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 4/6] Break up user and system cpu_interrupt implementations Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 5/6] Redirect cpu_interrupt to callback handler Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 6/6] kvm: Install specialized interrupt handler Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 23:57 ` [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
2011-04-16 23:57   ` [Qemu-devel] " Anthony Liguori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.