Skip to contentSkip to conversation

RFC: creating a particular vcpu type

PATCH In review Hollis Blanchard 5 participants 14 messages Feb 5, 2008 – Feb 11, 2008 4 messages not in the archive

Subsystems (5)
x86 KVM PowerPC KVM x86 +1 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RFC: creating a particular vcpu type

These patches allow PowerPC to create vcpus of a particular type. Since we are actually emulating the core's supervisor mode, we can choose to emulate any type of core. However, since the core chosen will change the size of the vcpu structure (among other things), we need to know it at vcpu creation time, rather than after the fact (which is how x86's cpuid is handled).

I've included the first example of how PowerPC will be using the new capability, and this will be significantly extended in the future. I think you get the idea...

I still need to update my tree and patch IA64 to match, but is this approach acceptable?

6 files changed, 99 insertions(+), 11 deletions(-)
arch/powerpc/kvm/powerpc.c     |   80 ++++++++++++++++++++++++++++++++++++++--
arch/x86/kvm/x86.c             |    4 +-
include/asm-powerpc/kvm_host.h |    5 ++
include/linux/kvm.h            |    8 ++++
include/linux/kvm_host.h       |    4 +-
virt/kvm/kvm_main.c            |    9 ++--

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#1 lore raw

PATCH 1/1 Pass an opaque parameter through kvm_vm_ioctl_vcpu_create() to kvm_arch_vcpu_create()

# HG changeset patch
# User Hollis Blanchard <hollisb-r/[email protected]> # Date 1202189664 21600
# Node ID bede9476e203f5bf59d21cc3cd71a30de2ce2c44
# Parent dfb0e1d58b57dfdf76b3111565815599bd38b92d

---

4 files changed, 9 insertions(+), 7 deletions(-)
arch/powerpc/kvm/powerpc.c |    3 ++-
arch/x86/kvm/x86.c         |    4 ++--
include/linux/kvm_host.h   |    3 ++-
virt/kvm/kvm_main.c        |    6 +++---
arch/powerpc/kvm/powerpc.c +2 -1
@@ -460,7 +460,8 @@ int kvm_arch_set_memory_region(struct kv
 	return 0;
 }
 
-struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
+struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id,
+                                      void *opaque)
 {
 	struct kvm_vcpu *vcpu;
 	int err;
arch/x86/kvm/x86.c +2 -2
@@ -3052,8 +3052,8 @@ void kvm_arch_vcpu_free(struct kvm_vcpu 
 	kvm_x86_ops->vcpu_free(vcpu);
 }
 
-struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
-						unsigned int id)
+struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id,
+                                      void *opaque)
 {
 	return kvm_x86_ops->vcpu_create(kvm, id);
 }
include/linux/kvm_host.h +2 -1
@@ -237,7 +237,8 @@ void kvm_arch_vcpu_free(struct kvm_vcpu 
 void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
-struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
+struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id,
+                                      void *opaque);
 int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu);
 
virt/kvm/kvm_main.c +3 -3
@@ -733,7 +733,7 @@ static int create_vcpu_fd(struct kvm_vcp
 /*
  * Creates some virtual cpus.  Good luck creating more than one.
  */
-static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
+static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n, void *opaque)
 {
 	int r;
 	struct kvm_vcpu *vcpu;
@@ -741,7 +741,7 @@ static int kvm_vm_ioctl_create_vcpu(stru
 	if (!valid_vcpu(n))
 		return -EINVAL;
 
-	vcpu = kvm_arch_vcpu_create(kvm, n);
+	vcpu = kvm_arch_vcpu_create(kvm, n, opaque);
 	if (IS_ERR(vcpu))
 		return PTR_ERR(vcpu);
 
@@ -945,7 +945,7 @@ static long kvm_vm_ioctl(struct file *fi
 		return -EIO;
 	switch (ioctl) {
 	case KVM_CREATE_VCPU:
-		r = kvm_vm_ioctl_create_vcpu(kvm, arg);
+		r = kvm_vm_ioctl_create_vcpu(kvm, arg, NULL);
 		if (r < 0)
 			goto out;
 		break;

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#2 lore raw

PATCH 1/1 Export kvm_vm_ioctl_create_vcpu() to be called from architecture modules

In reply to Hollis Blanchard

# HG changeset patch
# User Hollis Blanchard <hollisb-r/[email protected]> # Date 1202189666 21600
# Node ID 7dd50dab9096c8e0125792e3f48083c3f47fceab
# Parent bede9476e203f5bf59d21cc3cd71a30de2ce2c44

---

2 files changed, 3 insertions(+), 1 deletion(-)
include/linux/kvm_host.h |    1 +
virt/kvm/kvm_main.c      |    3 ++-
include/linux/kvm_host.h +1 -0
@@ -208,6 +208,7 @@ int kvm_vm_ioctl_set_memory_region(struc
 				   struct
 				   kvm_userspace_memory_region *mem,
 				   int user_alloc);
+int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n, void *opaque);
 long kvm_arch_vm_ioctl(struct file *filp,
 		       unsigned int ioctl, unsigned long arg);
 void kvm_arch_destroy_vm(struct kvm *kvm);
virt/kvm/kvm_main.c +2 -1
@@ -733,7 +733,7 @@ static int create_vcpu_fd(struct kvm_vcp
 /*
  * Creates some virtual cpus.  Good luck creating more than one.
  */
-static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n, void *opaque)
+int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n, void *opaque)
 {
 	int r;
 	struct kvm_vcpu *vcpu;
@@ -774,6 +774,7 @@ vcpu_destroy:
 	kvm_arch_vcpu_destroy(vcpu);
 	return r;
 }
+EXPORT_SYMBOL_GPL(kvm_vm_ioctl_create_vcpu);
 
 static int kvm_vcpu_ioctl_set_sigmask(struct kvm_vcpu *vcpu, sigset_t *sigset)
 {

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#3 lore raw

PATCH 1/1 Implement an ioctl that creates a vcpu of a particular type

In reply to Hollis Blanchard

# HG changeset patch
# User Hollis Blanchard <hollisb-r/[email protected]> # Date 1202189668 21600
# Node ID e6e0239e8df55c6af4e0b2959350215aaa119254
# Parent 7dd50dab9096c8e0125792e3f48083c3f47fceab
The ioctl accepts a core name as input and calls kvm_vm_ioctl_create_vcpu() with the corresponding "guest operations" structure. That structure, which will be extended with additional core-specific function pointers, is saved into the new vcpu by kvm_arch_vcpu_create().

---

3 files changed, 87 insertions(+), 3 deletions(-)
arch/powerpc/kvm/powerpc.c     |   77 ++++++++++++++++++++++++++++++++++++++--
include/asm-powerpc/kvm_host.h |    5 ++
include/linux/kvm.h            |    8 ++++
arch/powerpc/kvm/powerpc.c +74 -3
@@ -460,13 +460,22 @@ int kvm_arch_set_memory_region(struct kv
 	return 0;
 }
 
+/* XXX Make modules register kvmppc_core_spec pointers at init. */
+static struct kvmppc_core_spec kvmppc_supported_guests[] = {
+	{
+		.name = "ppc440",
+		.vcpu_size = sizeof(struct kvm_vcpu),
+	},
+};
+
 struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id,
                                       void *opaque)
 {
+	struct kvmppc_core_spec *s = opaque;
 	struct kvm_vcpu *vcpu;
 	int err;
 
-	vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
+	vcpu = vmalloc(s->vcpu_size);
 	if (!vcpu) {
 		err = -ENOMEM;
 		goto out;
@@ -479,7 +488,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(st
 	return vcpu;
 
 free_vcpu:
-	kmem_cache_free(kvm_vcpu_cache, vcpu);
+	vfree(vcpu);
 out:
 	return ERR_PTR(err);
 }
@@ -487,7 +496,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu 
 void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
 {
 	kvm_vcpu_uninit(vcpu);
-	kmem_cache_free(kvm_vcpu_cache, vcpu);
+	vfree(vcpu);
 }
 
 void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
@@ -800,12 +809,74 @@ int kvm_vm_ioctl_get_dirty_log(struct kv
 	return -ENOTSUPP;
 }
 
+static struct kvmppc_core_spec *kvmppc_guest_type(char *coretype)
+{
+	struct kvmppc_core_spec *c = kvmppc_supported_guests;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(kvmppc_supported_guests); i++,c++)
+		if (strcmp(c->name, coretype))
+			return c;
+
+	return 0;
+}
+
+static long kvmppc_arch_vcpu_create_type(struct kvm *kvm,
+                                  struct kvm_vcpu_create_type __user *user_type)
+{
+	struct kvm_vcpu_create_type type;
+	struct kvmppc_core_spec *s;
+	char *coretype;
+	long r;
+
+	if (copy_from_user(&type, user_type, sizeof(type))) {
+		r = -EFAULT;
+		goto out;
+	}
+
+	if (type.typelen > 32) {
+		r = -E2BIG;
+		goto out;
+	}
+
+	coretype = vmalloc(type.typelen);
+	if (!coretype) {
+		r = -ENOMEM;
+		goto out;
+	}
+
+	if (copy_from_user(coretype, type.type, type.typelen)) {
+		r = -EFAULT;
+		goto out_free;
+	}
+	coretype[type.typelen-1] = '\0';
+
+	s = kvmppc_guest_type(coretype);
+	if (!s) {
+		r = -ENOTSUPP;
+		goto out_free;
+	}
+
+	r = kvm_vm_ioctl_create_vcpu(kvm, type.id, s);
+
+out_free:
+	vfree(coretype);
+out:
+	return r;
+}
+
 long kvm_arch_vm_ioctl(struct file *filp,
                        unsigned int ioctl, unsigned long arg)
 {
+	struct kvm *kvm = filp->private_data;
+	void __user *argp = (void __user *)arg;
 	long r;
 
 	switch (ioctl) {
+	case KVM_CREATE_VCPU_TYPE: {
+		r = kvmppc_arch_vcpu_create_type(kvm, argp);
+		break;
+	}
 	default:
 		r = -EINVAL;
 	}
include/asm-powerpc/kvm_host.h +5 -0
@@ -49,6 +49,11 @@ struct tlbe {
 };
 
 struct kvm_arch {
+};
+
+struct kvmppc_core_spec {
+	const char *name;
+	unsigned int vcpu_size;
 };
 
 struct kvm_vcpu_arch {
include/linux/kvm.h +8 -0
@@ -211,6 +211,12 @@ struct kvm_vapic_addr {
 	__u64 vapic_addr;
 };
 
+struct kvm_vcpu_create_type {
+	__u32 id;
+	__u32 typelen;
+	char type[0];
+};
+
 #define KVMIO 0xAE
 
 /*
@@ -257,6 +263,8 @@ struct kvm_vapic_addr {
 #define KVM_GET_DIRTY_LOG         _IOW(KVMIO, 0x42, struct kvm_dirty_log)
 #define KVM_SET_MEMORY_ALIAS      _IOW(KVMIO, 0x43, struct kvm_memory_alias)
 #define KVM_GET_SUPPORTED_CPUID   _IOWR(KVMIO, 0x48, struct kvm_cpuid2)
+#define KVM_CREATE_VCPU_TYPE      _IOW(KVMIO,  0x49, struct kvm_vcpu_create_type)
+
 /* Device model IOC */
 #define KVM_CREATE_IRQCHIP	  _IO(KVMIO,  0x60)
 #define KVM_IRQ_LINE		  _IOW(KVMIO, 0x61, struct kvm_irq_level)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#4 lore raw

Re: [PATCH 3 of 3] [POWERPC] Implement an ioctl that creates a vcpu of a particular type

Quoted 7 lines · Hollis Blanchard

The ioctl accepts a core name as input and calls kvm_vm_ioctl_create_vcpu() with the corresponding "guest operations" structure. That structure, which will be extended with additional core-specific function pointers, is saved into the new vcpu by kvm_arch_vcpu_create().

[..]

arch/powerpc/kvm/powerpc.c int kvm_arch_set_memory_region(struct kv · line 467

Quoted 4 lines
arch/powerpc/kvm/powerpc.c +4 -0
+static struct kvmppc_core_spec kvmppc_supported_guests[] = {
+	{
+		.name = "ppc440",
+		.vcpu_size = sizeof(struct kvm_vcpu),

Just for clarification, here you want to add other configuration settings you want to imply with the set of the cpu core right ? E.g. we have discussed the pvr initialization on kvm-powerpc-devel and #kvm, do you intend to define the ppv440-pvr we want to set here in this struct?

[...]

arch/powerpc/kvm/powerpc.c int kvm_vm_ioctl_get_dirty_log(struct kv · line 846

Quoted 11 lines
arch/powerpc/kvm/powerpc.c +11 -0
+
+	if (type.typelen > 32) {
+		r = -E2BIG;
+		goto out;
+	}
+
+	coretype = vmalloc(type.typelen);
+	if (!coretype) {
+		r = -ENOMEM;
+		goto out;
+	}

If I don't overlook something we could use strnlen here instead of type.typelen and not trust userspace in any way (which is always good) that it passes us a good value.

arch/powerpc/kvm/powerpc.c int kvm_vm_ioctl_get_dirty_log(struct kv · line 853

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +6 -0
+	if (copy_from_user(coretype, type.type, type.typelen)) {
+		r = -EFAULT;
+		goto out_free;
+	}
+	coretype[type.typelen-1] = '\0';
+

Alltogether I like your patch even if I would have done details very different (and worse) and the main question about all that I wanted to point out is in your [0/3] mail:
"... is this approach acceptable?"
And if not what what would be alternative suggestions to pass information needed for vcpu_create?

include/linux/kvm.h struct kvm_vapic_addr { · line 218

Quoted 5 lines
include/linux/kvm.h +5 -0
+struct kvm_vcpu_create_type {
+	__u32 id;
+	__u32 typelen;
+	char type[0];
+};

This should work for other architectures too. While we need to specify cpu cores here others might specify something completely different with the same interface. So kvm_vcpu_create_type might be misleading while something like kvm_vcpu_create_info might be more generic.
Just to get some background - do anyone else see the need to specify a detail on vcpu_create for their implementation in future ?

Finally I wanted to add something more to think about while we discuss this interface. The approach itself looks good to me, but it might somewhen need an extension we should discuss and decide by now.
Think of the following situation:
a) In two years we might have some generic features which are part of the shared vcpu struct and we would need to specify sometihng for these features on vcpu_create
b) At the same time we would still have our need to specify arch dependent information on vcpu create.
Because the KVM_CREATE_VCPU_TYPE ioctl implies a vcpu create, we would need to set up these new stuff prior to that create in another new call. I think it might be much better if we would think now of how to specify multiple things in this extended vcpu_create.

This might either be done by removing the implicit vcpu creation for a workflow like that:
1. set generic feature a enabled
2. set generic feature b disabled
3. set arch specific core type to foo
4. create_vcpu (using all that)
Or on the other Hand we might think of a encapsulated or chained information that allows us to pass a variable number of settings with KVM_CREATE_VCPU_TYPE.

Signature · 8 lines
Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

A message that is not in the archive (sent off-list or not yet received): 47A85C09.5070609-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org

#6 lore raw

Re: [PATCH 3 of 3] [POWERPC] Implement an ioctl that creates a vcpu of a particular type

Quoted 7 lines · Christian Ehrhardt

This should work for other architectures too. While we need to specify cpu cores here others might specify something completely different with the same interface.
So kvm_vcpu_create_type might be misleading while something like kvm_vcpu_create_info might be more generic.
Just to get some background - do anyone else see the need to specify a detail on vcpu_create for their implementation in future ?

We do. For now, kvm_create_vcpu does create a cpu from a template. However our hardware control block allows to enable/disable various features. I would imagine that future userspace may want something different than the stock default values, and therefore a parameter would make sense for us too.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Re: [PATCH 3 of 3] [POWERPC] Implement an ioctl that creates a vcpu of a particular type

Quoted 5 lines · Carsten Otte

We do. For now, kvm_create_vcpu does create a cpu from a template. However our hardware control block allows to enable/disable various features. I would imagine that future userspace may want something different than the stock default values, and therefore a parameter would make sense for us too.

I suppose that parameter is supposed to show up in kvm_arch_vcpu_setup, not kvm_arch_vcpu_create?

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#9 lore raw

Re: [PATCH 3 of 3] [POWERPC] Implement an ioctl that creates a vcpu of a particular type

In reply to a message not in the archive
Quoted 9 lines · Christian Ehrhardt
Quoted 7 lines · Hollis Blanchard

The ioctl accepts a core name as input and calls kvm_vm_ioctl_create_vcpu() with the corresponding "guest operations" structure. That structure, which will be extended with additional core-specific function pointers, is saved into the new vcpu by kvm_arch_vcpu_create().

[..]

Quoted 10 lines

arch/powerpc/kvm/powerpc.c int kvm_arch_set_memory_region(struct kv · line 467

Quoted 4 lines
arch/powerpc/kvm/powerpc.c +4 -0
+static struct kvmppc_core_spec kvmppc_supported_guests[] = {
+	{
+		.name = "ppc440",
+		.vcpu_size = sizeof(struct kvm_vcpu),

Just for clarification, here you want to add other configuration settings you want to imply with the set of the cpu core right ? E.g. we have discussed the pvr initialization on kvm-powerpc-devel and #kvm, do you intend to define the ppv440-pvr we want to set here in this struct?

Yes, I tried to hint at this in the first mail. Note however, that this approach is an alternate design: rather than embedded a "cpu type" integer in the vcpu and adding switch tables at all decision points, we will add callbacks to this structure.

I have a followup patch to handle our TLB type disambiguation, but it was late and I didn't want to clean it up.

Quoted 7 lines
Quoted 7 lines
arch/powerpc/kvm/powerpc.c +7 -0
+
+	if (type.typelen > 32) {
+		r = -E2BIG;
+		goto out;
+	}
+
+	coretype = vmalloc(type.typelen);
Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvm_vm_ioctl_get_dirty_log(struct kv · line 846

Quoted 4 lines
arch/powerpc/kvm/powerpc.c +4 -0
+	if (!coretype) {
+		r = -ENOMEM;
+		goto out;
+	}

If I don't overlook something we could use strnlen here instead of type.typelen and not trust userspace in any way (which is always good) that it passes us a good value.

I wasn't liking that part of the interface anyways, so strnlen() sounds good to me. :)

Quoted 11 lines

include/linux/kvm.h struct kvm_vapic_addr { · line 218

Quoted 5 lines
include/linux/kvm.h +5 -0
+struct kvm_vcpu_create_type {
+	__u32 id;
+	__u32 typelen;
+	char type[0];
+};

This should work for other architectures too. While we need to specify cpu cores here others might specify something completely different with the same interface.
So kvm_vcpu_create_type might be misleading while something like kvm_vcpu_create_info might be more generic.

Yup, I think it makes sense to abstract this from a string to an arch-defined structure.

Another arch-specific interface might be needed to query capabilities in a similar way. Right now the extension stuff is based on encoded constants, but I'd explicitly like to avoid that because then you must also know the meaning of each constant. In other words, if you have

        #define POWERPC440 1

both the kernel and userspace must understand what "1" means as a parameter. That's why I went with strings...

On the other hand, encoded constants might be a better approach. For example, if we change what information we want to pass down for a particular vcpu type, we could do it like this:

        struct vcpu_type {
                __u32 type;
                union {
                        struct { foo; } type1;
                        struct { foo; bar; } type2;
                }
        }

and we could then use extension queries to find out if type=1 and type=2 are supported.

Quoted 2 lines

Just to get some background - do anyone else see the need to specify a detail on vcpu_create for their implementation in future ?

After talking to Carsten, it sounds like S390 could use this approach as well.

Quoted 5 lines

Finally I wanted to add something more to think about while we discuss this interface. The approach itself looks good to me, but it might somewhen need an extension we should discuss and decide by now. Think of the following situation:
a) In two years we might have some generic features which are part of

Quoted 8 lines

the shared vcpu struct and we would need to specify sometihng for these features on vcpu_create
b) At the same time we would still have our need to specify arch dependent information on vcpu create.
Because the KVM_CREATE_VCPU_TYPE ioctl implies a vcpu create, we would need to set up these new stuff prior to that create in another new call. I think it might be much better if we would think now of how to specify multiple things in this extended vcpu_create.

Agreed, I think we can handle that with my thoughts above.

Quoted 9 lines

This might either be done by removing the implicit vcpu creation for a workflow like that:
1. set generic feature a enabled
2. set generic feature b disabled
3. set arch specific core type to foo
4. create_vcpu (using all that)
Or on the other Hand we might think of a encapsulated or chained information that allows us to pass a variable number of settings with KVM_CREATE_VCPU_TYPE.

I don't like this design because it's inherently racy. It depends on no other actions taking place between "set feature bit" and "create vcpu". It's far better IMHO to supply all needed information at the same time.

Signature · 8 lines
Hollis Blanchard
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#10 lore raw
In reply to Hollis Blanchard

Why do this at the VCPU level? Would you ever want a VM with two VCPUs with different cores? You could just add a per-VM arch ioctl to set the core type that has to be issued before any VCPU creates. Then you don't have to do ugly stuff like calling ioctls from modules.

Regards,

Anthony Liguori

Quoted 21 lines · Hollis Blanchard

These patches allow PowerPC to create vcpus of a particular type. Since we are actually emulating the core's supervisor mode, we can choose to emulate any type of core. However, since the core chosen will change the size of the vcpu structure (among other things), we need to know it at vcpu creation time, rather than after the fact (which is how x86's cpuid is handled).

I've included the first example of how PowerPC will be using the new capability, and this will be significantly extended in the future. I think you get the idea...

I still need to update my tree and patch IA64 to match, but is this approach acceptable?

6 files changed, 99 insertions(+), 11 deletions(-)
arch/powerpc/kvm/powerpc.c     |   80 ++++++++++++++++++++++++++++++++++++++--
arch/x86/kvm/x86.c             |    4 +-
include/asm-powerpc/kvm_host.h |    5 ++
include/linux/kvm.h            |    8 ++++
include/linux/kvm_host.h       |    4 +-
virt/kvm/kvm_main.c            |    9 ++--
Quoted 9 lines

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

A message that is not in the archive (sent off-list or not yet received): 47A89285.40802-r/[email protected]

#12 lore raw

If it's the "ioctl" in the function name you object to, that's easily changed.

I think it's reasonable to say that single-system-image software requires identical cores, but that's not what we're talking about here. Heterogeneous core designs are not common, but a VM needs to reflect hardware layout, and people do it in hardware (again, not running a single system image).

"VCPU type" is a VCPU property, and I think the design should reflect that, and as you can see from the patch it's not at all difficult to do.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
Quoted 5 lines · Anthony Liguori

Why do this at the VCPU level? Would you ever want a VM with two VCPUs with different cores? You could just add a per-VM arch ioctl to set the core type that has to be issued before any VCPU creates. Then you don't have to do ugly stuff like calling ioctls from modules.

Quoted 35 lines

Regards,

Anthony Liguori

Quoted 30 lines · Hollis Blanchard

These patches allow PowerPC to create vcpus of a particular type. Since we are actually emulating the core's supervisor mode, we can choose to emulate any type of core. However, since the core chosen will change the size of the vcpu structure (among other things), we need to know it at vcpu creation time, rather than after the fact (which is how x86's cpuid is handled).

I've included the first example of how PowerPC will be using the new capability, and this will be significantly extended in the future. I think you get the idea...

I still need to update my tree and patch IA64 to match, but is this approach acceptable?

6 files changed, 99 insertions(+), 11 deletions(-)
arch/powerpc/kvm/powerpc.c     |   80 ++++++++++++++++++++++++++++++++++++++--
arch/x86/kvm/x86.c             |    4 +-
include/asm-powerpc/kvm_host.h |    5 ++
include/linux/kvm.h            |    8 ++++
include/linux/kvm_host.h       |    4 +-
virt/kvm/kvm_main.c            |    9 ++--

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#13 lore raw
Quoted 3 lines · Hollis Blanchard

If it's the "ioctl" in the function name you object to, that's easily changed.

It's not the name, it's what you're doing. You're introducing an architecture specific ioctl that essentially overrides an common-ioctl(). If anything, I would think it would be better to expand the existing common-ioctl with the notion and then have a per-architecture hook within that ioctl.

Quoted 9 lines

I think it's reasonable to say that single-system-image software requires identical cores, but that's not what we're talking about here. Heterogeneous core designs are not common, but a VM needs to reflect hardware layout, and people do it in hardware (again, not running a single system image).

"VCPU type" is a VCPU property, and I think the design should reflect that, and as you can see from the patch it's not at all difficult to do.

There are all sorts of crazy things you can do in actual hardware. Look at the way the cell processor handles memory for SPUs. You would need to change the KVM memory code to have per-CPU slots or something to support that.

We shouldn't design for any possible thing that anyone could want in the future, but rather for the things that we actually can see doing.

If you don't think there's a reasonable chance that you'll be attempting to implement asymmetric cores in the near future, I wouldn't think it's wise to over complicate things.

Regards,

Anthony Liguori

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

A message that is not in the archive (sent off-list or not yet received): 47A8A582.5060502-r/[email protected]

#15 lore raw
Quoted 10 lines · Anthony Liguori
Quoted 1 line · Hollis Blanchard

If it's the "ioctl" in the function name you object to, that's

easily

Quoted 2 lines

changed.

It's not the name, it's what you're doing. You're introducing an architecture specific ioctl that essentially overrides an common-ioctl().

No, I am introducing an architecture-specific ioctl that shares common code, which after all is the goal.

Quoted 3 lines

If anything, I would think it would be better to expand the existing common-ioctl with the notion and then have a per-architecture hook within that ioctl.

I *am* expanding the common ioctl. I am also preserving the existing
ABI: CREATE_VCPU still works, and CREATE_VCPU_TYPE is the new ioctl. And then, voila, we have an architecture-specific hook:
kvm_arch_vcpu_create().

I will happily move the KVM_CREATE_VCPU_TYPE case from kvm_arch_vm_ioctl() to kvm_vm_ioctl(), and since the additional parameter is necessarily architecture-specific, it will simply call kvm_arch_vcpu_create_type().

Signature · 8 lines
Hollis Blanchard
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#16 lore raw
Quoted 10 lines · Hollis Blanchard
Quoted 4 lines

If anything, I would think it would be better to expand the existing common-ioctl with the notion and then have a per-architecture hook within that ioctl.

I *am* expanding the common ioctl. I am also preserving the existing
ABI: CREATE_VCPU still works, and CREATE_VCPU_TYPE is the new ioctl. And then, voila, we have an architecture-specific hook:
kvm_arch_vcpu_create().

Quoted 5 lines

I will happily move the KVM_CREATE_VCPU_TYPE case from kvm_arch_vm_ioctl() to kvm_vm_ioctl(), and since the additional parameter is necessarily architecture-specific, it will simply call kvm_arch_vcpu_create_type().

So the new ioctl() has the extra data and the old ioctl() is just a compat interface which calls the new ioctl with a NULL extra data. I think this is the better approach if you're going this route.

However, I still don't think that supporting asymmetric cores is really useful at the moment and that introducing a per-vm arch ioctl would be the best approach.

Regards,

Anthony Liguori

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#17 lore raw
Quoted 8 lines · Anthony Liguori

So the new ioctl() has the extra data and the old ioctl() is just a compat interface which calls the new ioctl with a NULL extra data. I think this is the better approach if you're going this route.

However, I still don't think that supporting asymmetric cores is really useful at the moment and that introducing a per-vm arch ioctl would be the best approach.

Note that kvm/x86 supports slightly asymmetric cores, in that the cpuid results can be different for different vcpus. I can't judge how important this feature is for ppc, though.

Signature · 7 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/