Skip to contentSkip to conversation

Fix PowerPC KVM build breaks

PATCH New Hollis Blanchard 5 participants 8 messages Nov 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix PowerPC KVM build breaks

Hi Anthony, please apply these two patches to fix the PowerPC KVM build.

-Hollis

#1 lore raw

PATCH 1/1 kvm: Move KVM mp_state accessors to i386-specific code

Unbreaks PowerPC and S390 KVM builds.

kvm-all.c +0 -20
@@ -207,26 +207,6 @@ err:
     return ret;
 }
 
-int kvm_put_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
-
-    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
-}
-
-int kvm_get_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state;
-    int ret;
-
-    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
-    if (ret < 0) {
-        return ret;
-    }
-    env->mp_state = mp_state.mp_state;
-    return 0;
-}
-
 /*
  * dirty pages logging control
  */
kvm.h +0 -3
@@ -74,9 +74,6 @@ int kvm_vm_ioctl(KVMState *s, int type, 
 
 int kvm_vcpu_ioctl(CPUState *env, int type, ...);
 
-int kvm_get_mp_state(CPUState *env);
-int kvm_put_mp_state(CPUState *env);
-
 /* Arch specific hooks */
 
 int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
target-i386/kvm.c +20 -0
@@ -659,6 +659,26 @@ static int kvm_get_msrs(CPUState *env)
     return 0;
 }
 
+static int kvm_put_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
+
+    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
+}
+
+static int kvm_get_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state;
+    int ret;
+
+    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
+    if (ret < 0) {
+        return ret;
+    }
+    env->mp_state = mp_state.mp_state;
+    return 0;
+}
+
 int kvm_arch_put_registers(CPUState *env)
 {
     int ret;
#2 lore raw

Re: [PATCH 1 of 2] kvm: Move KVM mp_state accessors to i386-specific

Quoted 1 line · Hollis Blanchard

Unbreaks PowerPC and S390 KVM builds.

What breaks precisely?

Note that KVM_GET/SET_MP_STATE are generic IOCTLs and supposed to be shared with ia64 - one day. We could still move things back then, but maybe we can handle the build issues already in place, specifically as qemu-kvm is carrying this in generic code since ages.

Jan

Quoted 76 lines
kvm-all.c +0 -20
@@ -207,26 +207,6 @@ err:
     return ret;
 }
 
-int kvm_put_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
-
-    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
-}
-
-int kvm_get_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state;
-    int ret;
-
-    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
-    if (ret < 0) {
-        return ret;
-    }
-    env->mp_state = mp_state.mp_state;
-    return 0;
-}
-
 /*
  * dirty pages logging control
  */
kvm.h +0 -3
@@ -74,9 +74,6 @@ int kvm_vm_ioctl(KVMState *s, int type, 
 
 int kvm_vcpu_ioctl(CPUState *env, int type, ...);
 
-int kvm_get_mp_state(CPUState *env);
-int kvm_put_mp_state(CPUState *env);
-
 /* Arch specific hooks */
 
 int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
target-i386/kvm.c +20 -0
@@ -659,6 +659,26 @@ static int kvm_get_msrs(CPUState *env)
     return 0;
 }
 
+static int kvm_put_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
+
+    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
+}
+
+static int kvm_get_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state;
+    int ret;
+
+    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
+    if (ret < 0) {
+        return ret;
+    }
+    env->mp_state = mp_state.mp_state;
+    return 0;
+}
+
 int kvm_arch_put_registers(CPUState *env)
 {
     int ret;
#3 lore raw

Re: [PATCH 1 of 2] kvm: Move KVM mp_state accessors to i386-specific code

Quoted 9 lines · Jan Kiszka
Quoted 1 line · Hollis Blanchard

Unbreaks PowerPC and S390 KVM builds.

What breaks precisely?

Note that KVM_GET/SET_MP_STATE are generic IOCTLs and supposed to be shared with ia64 - one day. We could still move things back then, but maybe we can handle the build issues already in place, specifically as qemu-kvm is carrying this in generic code since ages.

The "generic" code tries to access env->mp_state which doesn't exist in PPC's env because it's only defined in the X86 env.

I honestly don't care where to move things. And I don't think anyone else should. Either move it to CPU_COMMON if you think it's generic or move the code to the platform specific part.

We've been going through this at least 2 times in previous threads. But qemu HEAD has been broken for PPC kvm since MP states got introduced and it's no fun talking against walls on this.

Alex

#4 lore raw

Re: [PATCH 1 of 2] kvm: Move KVM mp_state accessors to i386-specific

In reply to Jan Kiszka

This is the technique Anthony requested this morning, rather than relocating mp_state. To be honest, I don't care which way it's fixed; this is at least the 3rd patch to solve this seemingly trivial problem.

/home/hollisb/source/qemu-fresh.hg/kvm-all.c: In function 'kvm_put_mp_state':
/home/hollisb/source/qemu-fresh.hg/kvm-all.c:212: error: 'struct CPUPPCState' has no member named 'mp_state'

-Hollis

Quoted 91 lines · Jan Kiszka
Quoted 1 line · Hollis Blanchard

Unbreaks PowerPC and S390 KVM builds.

What breaks precisely?

Note that KVM_GET/SET_MP_STATE are generic IOCTLs and supposed to be shared with ia64 - one day. We could still move things back then, but maybe we can handle the build issues already in place, specifically as qemu-kvm is carrying this in generic code since ages.

Jan

Quoted 76 lines
kvm-all.c +0 -20
@@ -207,26 +207,6 @@ err:
      return ret;
  }
 
-int kvm_put_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
-
-    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
-}
-
-int kvm_get_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state;
-    int ret;
-
-    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
-    if (ret < 0) {
-        return ret;
-    }
-    env->mp_state = mp_state.mp_state;
-    return 0;
-}
-
  /*
   * dirty pages logging control
   */
kvm.h +0 -3
@@ -74,9 +74,6 @@ int kvm_vm_ioctl(KVMState *s, int type,
 
  int kvm_vcpu_ioctl(CPUState *env, int type, ...);
 
-int kvm_get_mp_state(CPUState *env);
-int kvm_put_mp_state(CPUState *env);
-
  /* Arch specific hooks */
 
  int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
target-i386/kvm.c +20 -0
@@ -659,6 +659,26 @@ static int kvm_get_msrs(CPUState *env)
      return 0;
  }
 
+static int kvm_put_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
+
+    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
+}
+
+static int kvm_get_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state;
+    int ret;
+
+    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
+    if (ret < 0) {
+        return ret;
+    }
+    env->mp_state = mp_state.mp_state;
+    return 0;
+}
+
  int kvm_arch_put_registers(CPUState *env)
  {
      int ret;
#5 lore raw

Re: [PATCH 1 of 2] kvm: Move KVM mp_state accessors to i386-specific

Quoted 2 lines · Hollis Blanchard

This is the technique Anthony requested this morning, rather than relocating mp_state.

Then let's move it. There is not that much code to share anyway.

Quoted 3 lines

To be honest, I don't care which way it's fixed; this is at least the 3rd patch to solve this seemingly trivial problem.

That's indeed unfortunate, but I think to remember that not all of these attempts were clean.

Jan

Quoted 96 lines

/home/hollisb/source/qemu-fresh.hg/kvm-all.c: In function 'kvm_put_mp_state':
/home/hollisb/source/qemu-fresh.hg/kvm-all.c:212: error: 'struct CPUPPCState' has no member named 'mp_state'

-Hollis

Quoted 88 lines · Jan Kiszka
Quoted 1 line · Hollis Blanchard

Unbreaks PowerPC and S390 KVM builds.

What breaks precisely?

Note that KVM_GET/SET_MP_STATE are generic IOCTLs and supposed to be shared with ia64 - one day. We could still move things back then, but maybe we can handle the build issues already in place, specifically as qemu-kvm is carrying this in generic code since ages.

Jan

Quoted 75 lines
kvm-all.c +0 -20
@@ -207,26 +207,6 @@ err:
     return ret;
 }
 
-int kvm_put_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
-
-    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
-}
-
-int kvm_get_mp_state(CPUState *env)
-{
-    struct kvm_mp_state mp_state;
-    int ret;
-
-    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
-    if (ret < 0) {
-        return ret;
-    }
-    env->mp_state = mp_state.mp_state;
-    return 0;
-}
-
 /*
  * dirty pages logging control
  */
kvm.h +0 -3
@@ -74,9 +74,6 @@ int kvm_vm_ioctl(KVMState *s, int type,
 
 int kvm_vcpu_ioctl(CPUState *env, int type, ...);
 
-int kvm_get_mp_state(CPUState *env);
-int kvm_put_mp_state(CPUState *env);
-
 /* Arch specific hooks */
 
 int kvm_arch_post_run(CPUState *env, struct kvm_run *run);
target-i386/kvm.c +20 -0
@@ -659,6 +659,26 @@ static int kvm_get_msrs(CPUState *env)
     return 0;
 }
 
+static int kvm_put_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
+
+    return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
+}
+
+static int kvm_get_mp_state(CPUState *env)
+{
+    struct kvm_mp_state mp_state;
+    int ret;
+
+    ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state);
+    if (ret < 0) {
+        return ret;
+    }
+    env->mp_state = mp_state.mp_state;
+    return 0;
+}
+
 int kvm_arch_put_registers(CPUState *env)
 {
     int ret;
#6 lore raw

Re: [PATCH 1 of 2] kvm: Move KVM mp_state accessors to i386-specific

In reply to Jan Kiszka
Quoted 5 lines · Jan Kiszka
Quoted 2 lines · Hollis Blanchard

Unbreaks PowerPC and S390 KVM builds.

Quoted 7 lines

What breaks precisely?

Note that KVM_GET/SET_MP_STATE are generic IOCTLs and supposed to be shared with ia64 - one day. We could still move things back then, but maybe we can handle the build issues already in place, specifically as qemu-kvm is carrying this in generic code since ages.

mp_state is pretty specific to the in-kernel apic. ia64 may share because it shares an interrupt controller but that does not make it generic. That just makes two architectures have a common field.

I don't think there's anything wrong with kvm exposing this as a common ioctl but from a qemu perspective, it makes no sense as a common cpu field. It only makes sense when using kvm and when using an in-kernel apic. That's very architecture specific from an qemu perspective.

Signature · 3 lines
Regards,

Anthony Liguori