All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-1.4 qom-cpu 1/9] kvm: Create kvm_arch_vcpu_id() function
       [not found] <1358886309-26258-1-git-send-email-ehabkost@redhat.com>
@ 2013-01-22 20:25 ` Eduardo Habkost
  2013-01-23 10:26   ` Gleb Natapov
  2013-01-22 20:25 ` [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
  1 sibling, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2013-01-22 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: kvm, Gleb Natapov, Michael S. Tsirkin, Marcelo Tosatti,
	Igor Mammedov, Andreas Färber

This will allow each architecture to define how the VCPU ID is set on
the KVM_CREATE_VCPU ioctl call.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: kvm@vger.kernel.org
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>

Changes v2:
 - Get CPUState as argument instead of CPUArchState

Changes v3:
 - Convert KVM_CREATE_VCPU ioctl() argument to void*, so
   the argument type matches the type expected by kvm_vm_ioctl()
---
 include/sysemu/kvm.h | 3 +++
 kvm-all.c            | 2 +-
 target-i386/kvm.c    | 5 +++++
 target-ppc/kvm.c     | 5 +++++
 target-s390x/kvm.c   | 5 +++++
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 22acf91..384ee66 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -196,6 +196,9 @@ int kvm_arch_init(KVMState *s);
 
 int kvm_arch_init_vcpu(CPUState *cpu);
 
+/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
+unsigned long kvm_arch_vcpu_id(CPUState *cpu);
+
 void kvm_arch_reset_vcpu(CPUState *cpu);
 
 int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
diff --git a/kvm-all.c b/kvm-all.c
index 6278d61..363a358 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -222,7 +222,7 @@ int kvm_init_vcpu(CPUState *cpu)
 
     DPRINTF("kvm_init_vcpu\n");
 
-    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, cpu->cpu_index);
+    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, (void *)kvm_arch_vcpu_id(cpu));
     if (ret < 0) {
         DPRINTF("kvm_create_vcpu failed\n");
         goto err;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 3acff40..5f3f789 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -411,6 +411,11 @@ static void cpu_update_state(void *opaque, int running, RunState state)
     }
 }
 
+unsigned long kvm_arch_vcpu_id(CPUState *cpu)
+{
+    return cpu->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUState *cs)
 {
     struct {
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 2f4f068..2c64c63 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -384,6 +384,11 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu)
 
 #endif /* !defined (TARGET_PPC64) */
 
+unsigned long kvm_arch_vcpu_id(CPUState *cpu)
+{
+    return cpu->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index add6a58..99deddf 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -76,6 +76,11 @@ int kvm_arch_init(KVMState *s)
     return 0;
 }
 
+unsigned long kvm_arch_vcpu_id(CPUState *cpu)
+{
+    return cpu->cpu_index;
+}
+
 int kvm_arch_init_vcpu(CPUState *cpu)
 {
     int ret = 0;
-- 
1.8.1

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

* [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index
       [not found] <1358886309-26258-1-git-send-email-ehabkost@redhat.com>
  2013-01-22 20:25 ` [PATCH for-1.4 qom-cpu 1/9] kvm: Create kvm_arch_vcpu_id() function Eduardo Habkost
@ 2013-01-22 20:25 ` Eduardo Habkost
  2013-01-23 10:26   ` Gleb Natapov
  1 sibling, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2013-01-22 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: kvm, Gleb Natapov, Michael S. Tsirkin, Marcelo Tosatti,
	Igor Mammedov, Andreas Färber

The CPU ID in KVM is supposed to be the APIC ID, so change the
KVM_CREATE_VCPU call to match it. The current behavior didn't break
anything yet because today the APIC ID is assumed to be equal to the CPU
index, but this won't be true in the future.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
---
Cc: kvm@vger.kernel.org
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>

Changes v2:
 - Change only i386 code (kvm_arch_vcpu_id())

Changes v3:
 - Get CPUState as argument instead of CPUArchState
---
 target-i386/kvm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 5f3f789..c440809 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -411,9 +411,10 @@ static void cpu_update_state(void *opaque, int running, RunState state)
     }
 }
 
-unsigned long kvm_arch_vcpu_id(CPUState *cpu)
+unsigned long kvm_arch_vcpu_id(CPUState *cs)
 {
-    return cpu->cpu_index;
+    X86CPU *cpu = X86_CPU(cs);
+    return cpu->env.cpuid_apic_id;
 }
 
 int kvm_arch_init_vcpu(CPUState *cs)
-- 
1.8.1

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

* Re: [PATCH for-1.4 qom-cpu 1/9] kvm: Create kvm_arch_vcpu_id() function
  2013-01-22 20:25 ` [PATCH for-1.4 qom-cpu 1/9] kvm: Create kvm_arch_vcpu_id() function Eduardo Habkost
@ 2013-01-23 10:26   ` Gleb Natapov
  0 siblings, 0 replies; 5+ messages in thread
From: Gleb Natapov @ 2013-01-23 10:26 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: kvm, Michael S. Tsirkin, Marcelo Tosatti, qemu-devel,
	Igor Mammedov, Andreas Färber

On Tue, Jan 22, 2013 at 06:25:01PM -0200, Eduardo Habkost wrote:
> This will allow each architecture to define how the VCPU ID is set on
> the KVM_CREATE_VCPU ioctl call.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Gleb Natapov <gleb@redhat.com>

> ---
> Cc: kvm@vger.kernel.org
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> 
> Changes v2:
>  - Get CPUState as argument instead of CPUArchState
> 
> Changes v3:
>  - Convert KVM_CREATE_VCPU ioctl() argument to void*, so
>    the argument type matches the type expected by kvm_vm_ioctl()
> ---
>  include/sysemu/kvm.h | 3 +++
>  kvm-all.c            | 2 +-
>  target-i386/kvm.c    | 5 +++++
>  target-ppc/kvm.c     | 5 +++++
>  target-s390x/kvm.c   | 5 +++++
>  5 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 22acf91..384ee66 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -196,6 +196,9 @@ int kvm_arch_init(KVMState *s);
>  
>  int kvm_arch_init_vcpu(CPUState *cpu);
>  
> +/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
> +unsigned long kvm_arch_vcpu_id(CPUState *cpu);
> +
>  void kvm_arch_reset_vcpu(CPUState *cpu);
>  
>  int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
> diff --git a/kvm-all.c b/kvm-all.c
> index 6278d61..363a358 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -222,7 +222,7 @@ int kvm_init_vcpu(CPUState *cpu)
>  
>      DPRINTF("kvm_init_vcpu\n");
>  
> -    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, cpu->cpu_index);
> +    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, (void *)kvm_arch_vcpu_id(cpu));
>      if (ret < 0) {
>          DPRINTF("kvm_create_vcpu failed\n");
>          goto err;
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 3acff40..5f3f789 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -411,6 +411,11 @@ static void cpu_update_state(void *opaque, int running, RunState state)
>      }
>  }
>  
> +unsigned long kvm_arch_vcpu_id(CPUState *cpu)
> +{
> +    return cpu->cpu_index;
> +}
> +
>  int kvm_arch_init_vcpu(CPUState *cs)
>  {
>      struct {
> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> index 2f4f068..2c64c63 100644
> --- a/target-ppc/kvm.c
> +++ b/target-ppc/kvm.c
> @@ -384,6 +384,11 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu)
>  
>  #endif /* !defined (TARGET_PPC64) */
>  
> +unsigned long kvm_arch_vcpu_id(CPUState *cpu)
> +{
> +    return cpu->cpu_index;
> +}
> +
>  int kvm_arch_init_vcpu(CPUState *cs)
>  {
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
> index add6a58..99deddf 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -76,6 +76,11 @@ int kvm_arch_init(KVMState *s)
>      return 0;
>  }
>  
> +unsigned long kvm_arch_vcpu_id(CPUState *cpu)
> +{
> +    return cpu->cpu_index;
> +}
> +
>  int kvm_arch_init_vcpu(CPUState *cpu)
>  {
>      int ret = 0;
> -- 
> 1.8.1

--
			Gleb.

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

* Re: [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index
  2013-01-22 20:25 ` [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
@ 2013-01-23 10:26   ` Gleb Natapov
  2013-01-23 16:12     ` [Qemu-devel] " Andreas Färber
  0 siblings, 1 reply; 5+ messages in thread
From: Gleb Natapov @ 2013-01-23 10:26 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: kvm, Michael S. Tsirkin, Marcelo Tosatti, qemu-devel,
	Igor Mammedov, Andreas Färber

On Tue, Jan 22, 2013 at 06:25:02PM -0200, Eduardo Habkost wrote:
> The CPU ID in KVM is supposed to be the APIC ID, so change the
> KVM_CREATE_VCPU call to match it. The current behavior didn't break
> anything yet because today the APIC ID is assumed to be equal to the CPU
> index, but this won't be true in the future.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Acked-by: Gleb Natapov <gleb@redhat.com>

> ---
> Cc: kvm@vger.kernel.org
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> 
> Changes v2:
>  - Change only i386 code (kvm_arch_vcpu_id())
> 
> Changes v3:
>  - Get CPUState as argument instead of CPUArchState
> ---
>  target-i386/kvm.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 5f3f789..c440809 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -411,9 +411,10 @@ static void cpu_update_state(void *opaque, int running, RunState state)
>      }
>  }
>  
> -unsigned long kvm_arch_vcpu_id(CPUState *cpu)
> +unsigned long kvm_arch_vcpu_id(CPUState *cs)
>  {
> -    return cpu->cpu_index;
> +    X86CPU *cpu = X86_CPU(cs);
> +    return cpu->env.cpuid_apic_id;
>  }
>  
>  int kvm_arch_init_vcpu(CPUState *cs)
> -- 
> 1.8.1

--
			Gleb.

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

* Re: [Qemu-devel] [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index
  2013-01-23 10:26   ` Gleb Natapov
@ 2013-01-23 16:12     ` Andreas Färber
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2013-01-23 16:12 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Gleb Natapov, kvm, Michael S. Tsirkin, Marcelo Tosatti,
	qemu-devel, Igor Mammedov

Am 23.01.2013 11:26, schrieb Gleb Natapov:
> On Tue, Jan 22, 2013 at 06:25:02PM -0200, Eduardo Habkost wrote:
>> The CPU ID in KVM is supposed to be the APIC ID, so change the
>> KVM_CREATE_VCPU call to match it. The current behavior didn't break
>> anything yet because today the APIC ID is assumed to be equal to the CPU
>> index, but this won't be true in the future.
>>
>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
> Acked-by: Gleb Natapov <gleb@redhat.com>

Thanks, applied these two to qom-cpu already:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

end of thread, other threads:[~2013-01-23 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1358886309-26258-1-git-send-email-ehabkost@redhat.com>
2013-01-22 20:25 ` [PATCH for-1.4 qom-cpu 1/9] kvm: Create kvm_arch_vcpu_id() function Eduardo Habkost
2013-01-23 10:26   ` Gleb Natapov
2013-01-22 20:25 ` [PATCH for-1.4 qom-cpu 2/9] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
2013-01-23 10:26   ` Gleb Natapov
2013-01-23 16:12     ` [Qemu-devel] " Andreas Färber

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.