From: Christian Ehrhardt <redacted>
This patch series implements a paravirtualization interface using:
- the device tree mechanism to pass hypervisor informations to the guest
- hypercalls for guest->host calls
- an example exploiter of that interface (magic page)
This is work in progress, but working so far. I just start to really exploit
the fuctionality behind the magic page mechanism therefor I can't provide any
performance improvements so far, but it is evolved enough for RFC and to start
the standardization discussion.
The used hypercall ABI was already discussed on the embedded-hypervisor mailing
list and is available at http://kvm.qumranet.com/kvmwiki/PowerPC_Hypercall_ABI
The device tree format used here (=base for the discussions on
embedded-hypervisor) is the following.
- A node "hypervisor" to show the general availability of some hypervisor data
- flags for features like the example "feature,pv-magicpage"
setting 1 = available, everything else = unavailable
- Some features might need to pass more data and can use an entry in the
device tree like the example of "data,pv-magicpage-size"
Parties on cc:
linuxppc-dev@ozlabs.org
The patches affect code in the generic powerpc boot&setup so I would be
happy about comments if the hooks are ok that way.
embedded-hypervisor@power.org
This power.org TSC discusses about standardization of the virtualization
interfaces. This patch series is perfectly suited due to it's simple changes
to start the discussion about the device tree there.
kvm-ppc@vger.kernel.org
The code is made for kvm on powerpc which lives on this list.
[patches in series]
Subject: [PATCH 1/6] kvmppc: read device tree hypervisor node infrastructure
Providing the guest functionality to read hypervisor features from the
device tree and adding the basic hook to the powerpc boot6setup code
Subject: [PATCH 2/6] kvmppc: add hypercall infrastructure - host part
Subject: [PATCH 3/6] kvmppc: add hypercall infrastructure - guest part
patch 2&3 add the hypercall infrastruture as mentioned above
Subject: [PATCH 4/6] kvmppc: magic page hypercall - host part
Subject: [PATCH 5/6] kvmppc: magic page paravirtualization - guest part
patch 4&5 add the magic page mechanism which will later on be used for
binary rewriting the guest.
Subject: [PATCH 6/6] kvmppc: kvm-userspace: device tree modification for magicpage
This connects host and guest reading host capabilities and modifying the
device tree passed to the guest accordingly
---
[diffstat]
arch/powerpc/kernel/kvm.c | 48 +++++++++++++++++++++++++++++++++++
arch/powerpc/kvm/emulate.c | 5 +++
b/arch/powerpc/kernel/Makefile | 2 +
b/arch/powerpc/kernel/kvm.c | 30 +++++++++++++++++++++
b/arch/powerpc/kernel/setup_32.c | 3 ++
b/arch/powerpc/kvm/emulate.c | 27 +++++++++++++++++++
b/arch/powerpc/kvm/powerpc.c | 18 ++++++++++++-
b/arch/powerpc/platforms/44x/Kconfig | 7 +++++
b/include/asm-powerpc/kvm_para.h | 37 ++++++++++++++++++++++++--
b/include/linux/kvm.h | 6 ++++
b/libkvm/libkvm-powerpc.c | 6 ++++
b/libkvm/libkvm.h | 6 ++++
b/qemu/hw/device_tree.c | 10 +++++++
b/qemu/hw/device_tree.h | 1
b/qemu/hw/ppc440_bamboo.c | 15 ++++++++++
b/qemu/qemu-kvm-powerpc.c | 5 +++
b/qemu/qemu-kvm.h | 1
include/asm-powerpc/kvm_para.h | 47 +++++++++++++++++++++++++++++++++-
18 files changed, 269 insertions(+), 5 deletions(-)
From: Christian Ehrhardt <redacted>
This patch adds the guest portion of the device tree based host->guest
communication. Using the device tree infrastructure this patch implements
kvm_para_available and kvm_arch_para_features (in this patch just the
infrastructure, no specific feature registered).
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
arch/powerpc/kernel/Makefile | 2 ++
arch/powerpc/kernel/kvm.c | 30 ++++++++++++++++++++++++++++++
arch/powerpc/kernel/setup_32.c | 3 +++
arch/powerpc/platforms/44x/Kconfig | 7 +++++++
include/asm-powerpc/kvm_para.h | 37 ++++++++++++++++++++++++++++++++++---
5 files changed, 76 insertions(+), 3 deletions(-)
[diff]
From: Christian Ehrhardt <redacted>
This patch adds the guest handling for the magic page mechanism. A Hypervisor
can modify the device tree passed to the guest. Using that already existing
interface a guest can simply detect available hypervisor features and agree
on the supported ones using hypercalls.
In this example it is checked for the feature switch "feature,pv-magicpage"
in the hypervisor node and additional data which represents the size the
hypervisor requests in "data,pv-magicpage-size".
When the guest read that data and wants to support it the memory is allocated
and passed to the hypervisor using the KVM_HCALL_RESERVE_MAGICPAGE hypercall.
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
arch/powerpc/kernel/kvm.c | 48 +++++++++++++++++++++++++++++++++++++++++
include/asm-powerpc/kvm_para.h | 27 ++++++++++++++++++++++-
2 files changed, 74 insertions(+), 1 deletion(-)
[diff]
@@ -28,10 +28,18 @@#define KVM_HYPERCALL_BIN 0x03ffffff+#define KVM_HCALL_RESERVE_MAGICPAGE 0++#define KVM_PVDATA_MAGICPAGE_SIZE "data,pv-magicpage-size"++/* List of PV features supported, returned as a bitfield */+#define KVM_FEATURE_PPCPV_MAGICPAGE 0+staticstructkvmppc_para_features{char*dtcell;intfeature;}para_features[]={+{"feature,pv-magicpage",KVM_FEATURE_PPCPV_MAGICPAGE}};staticinlineintkvm_para_available(void)
@@ -54,13 +62,30 @@if(!dn)return0;-for(i=0;i<ARRAY_SIZE(para_features)-1;i++){+for(i=0;i<ARRAY_SIZE(para_features);i++){dtval=of_get_property(dn,para_features[i].dtcell,NULL);if(dtval&&*dtval==1)features|=(1<<para_features[i].feature);}returnfeatures;+}++/* reads the specified data field out of the hypervisor node */+staticinlineintkvmppc_pv_read_data(char*dtcell)+{+structdevice_node*dn;+constint*dtval;++dn=of_find_node_by_path("/hypervisor");+if(!dn)+return-EINVAL;++dtval=of_get_property(dn,dtcell,NULL);+if(dtval)+return*dtval;+else+return-EINVAL;}voidkvm_guest_init(void);
From: Tony Breeds <hidden> Date: 2008-07-24 01:59:26
On Wed, Jul 23, 2008 at 10:36:46AM +0200, ehrhardt@linux.vnet.ibm.com wrote:
Hi Christian,
<snip>
+/*
+ * this is guest memory granted to the hypervisor;
+ * the hypervisor can place data in this area and rewrite
+ * privileged instructions to read from this area without
+ * trapping.
+ * Only the Hypervisor needs to be aware of the structure layout
+ * which makes the guest more felxible - the guest only guarantees
+ * the size which is requested by the hypervisor and read from a
+ * device tree entry.
+ */
+void *kvm_magicpage;
static?
<snip>
+/* reads the specified data field out of the hypervisor node */
+static inline int kvmppc_pv_read_data(char *dtcell)
+{
+ struct device_node *dn;
+ const int *dtval;
+
+ dn = of_find_node_by_path("/hypervisor");
+ if (!dn)
+ return -EINVAL;
+
+ dtval = of_get_property(dn, dtcell, NULL);
+ if (dtval)
+ return *dtval;
+ else
+ return -EINVAL;
You need an of_node_put(dn) in this function somewhere.
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!
From: Christian Ehrhardt <redacted>
This adds the guest portion of the hypercall infrastructure, basically an
illegal instruction with a defined layout.
See http://kvm.qumranet.com/kvmwiki/PowerPC_Hypercall_ABI for more detail
on the hypercall ABI for powerpc.
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
kvm_para.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
[diff]
From: Tony Breeds <hidden> Date: 2008-07-24 01:45:42
On Wed, Jul 23, 2008 at 10:36:44AM +0200, ehrhardt@linux.vnet.ibm.com wrote:
From: Christian Ehrhardt <redacted>
Hi Christian,
quoted hunk
This adds the guest portion of the hypercall infrastructure, basically an
illegal instruction with a defined layout.
See http://kvm.qumranet.com/kvmwiki/PowerPC_Hypercall_ABI for more detail
on the hypercall ABI for powerpc.
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
kvm_para.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
[diff]
Ummm didn't you add this in patch 2 of 6?
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!
From: Christian Ehrhardt <hidden> Date: 2008-07-24 07:57:05
Tony Breeds wrote:
On Wed, Jul 23, 2008 at 10:36:44AM +0200, ehrhardt@linux.vnet.ibm.com wrote:
quoted
From: Christian Ehrhardt <redacted>
Hi Christian,
quoted
This adds the guest portion of the hypercall infrastructure, basically an
illegal instruction with a defined layout.
See http://kvm.qumranet.com/kvmwiki/PowerPC_Hypercall_ABI for more detail
on the hypercall ABI for powerpc.
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
kvm_para.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
[diff]
This is just because I initially wanted to split Host & Guest patch series.
I need to separate my patches a bit more anyway for the next submission
thanks for pointing out this duplication.
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!
--
Grüsse / regards,
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization
From: Christian Ehrhardt <redacted>
This patch to kvm-userspace connects the other host & guest patches in this
series. On guest initialization it checks the hosts capabilities for the
magicpage mechanism. If available the device tree passed to the guest gets the
"hypervisor" node added and in that node the feature flag and the requested
magic page size (read from the host kernel via an ioctl) is stored.
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
libkvm/libkvm-powerpc.c | 6 ++++++
libkvm/libkvm.h | 6 ++++++
qemu/hw/device_tree.c | 10 ++++++++++
qemu/hw/device_tree.h | 1 +
qemu/hw/ppc440_bamboo.c | 15 +++++++++++++++
qemu/qemu-kvm-powerpc.c | 5 +++++
qemu/qemu-kvm.h | 1 +
7 files changed, 44 insertions(+)
[diff]
@@ -190,4 +190,14 @@exit(1);}}++voiddt_add_subnode(void*fdt,constchar*name,char*node_path)+{+intoffset;+offset=get_offset_of_node(fdt,node_path);+if(fdt_add_subnode(fdt,offset,name)<0){+printf("Unable to create device tree node '%s'\n",name);+exit(1);+}+}#endif
From: Christian Ehrhardt <redacted>
This adds the host part of the magic page registration. This is a memory
area of the guest granted to the host.
The patch just introduces the infrastruture to receive the guest paddr.
This is work in progress and it is intended to later on use this memory
as storage area a guest can read unprivileged (using binary rewriting to
change privileges instructions).
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
arch/powerpc/kvm/emulate.c | 5 +++++
arch/powerpc/kvm/powerpc.c | 18 +++++++++++++++++-
include/asm-powerpc/kvm_para.h | 2 ++
include/linux/kvm.h | 6 ++++++
4 files changed, 30 insertions(+), 1 deletion(-)
[diff]
@@ -208,6 +208,11 @@intret=0;switch(vcpu->arch.gpr[0]){+caseKVM_HCALL_RESERVE_MAGICPAGE:+/* FIXME TODO implement the real fuctionality using that */+printk(KERN_ERR"%s - receive magicpage address 0x%x\n",+__func__,vcpu->arch.gpr[3]);+break;default:printk(KERN_ERR"unknown hypercall %d\n",vcpu->arch.gpr[0]);kvmppc_dump_vcpu(vcpu);
From: Tony Breeds <hidden> Date: 2008-07-24 01:49:17
On Wed, Jul 23, 2008 at 10:36:45AM +0200, ehrhardt@linux.vnet.ibm.com wrote:
Hi Christian,
long kvm_arch_dev_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{
- return -EINVAL;
+ long r = -EINVAL;
+
+ switch (ioctl) {
+ case KVM_GET_PPCPV_MAGICPAGE_SIZE:
+ r = -EINVAL;
Not needed you set it on the declaration.
+ if (arg)
+ goto out;
+ r = 1024;
Ummm what does 1024 represent? can it me #defined? or at least add a
comment.
+ break;
+ default:
+ r = -EINVAL;
Not needed you set it on the declaration.
+ }
+out:
+ return r;
}
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!
From: Christian Ehrhardt <redacted>
This adds the host portion of the hypercall infrastructure which receives
the guest calls - no specific hcall function is implemented in this patch.
Signed-off-by: Christian Ehrhardt <redacted>
---
[diffstat]
arch/powerpc/kvm/emulate.c | 27 +++++++++++++++++++++++++++
include/asm-powerpc/kvm_para.h | 2 ++
2 files changed, 29 insertions(+)
[diff]
I think the preffered style is printk(KERN_ERR "...) You've made the
same style mistake in most of you printk()'s in your other patches
aswell.
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!
I think the preffered style is printk(KERN_ERR "...) You've made the
same style mistake in most of you printk()'s in your other patches
aswell.
Note that these days people use pr_err() instead.
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven@eu.sony.com
Internet: http://www.sony-europe.com/
A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis 293-0376800-10 GEBA-BE-BB
From: Tony Breeds <hidden> Date: 2008-07-24 02:01:13
On Wed, Jul 23, 2008 at 10:36:41AM +0200, ehrhardt@linux.vnet.ibm.com wrote:
From: Christian Ehrhardt <redacted>
This patch series implements a paravirtualization interface using:
- the device tree mechanism to pass hypervisor informations to the guest
- hypercalls for guest->host calls
- an example exploiter of that interface (magic page)
This is work in progress, but working so far. I just start to really exploit
the fuctionality behind the magic page mechanism therefor I can't provide any
performance improvements so far, but it is evolved enough for RFC and to start
the standardization discussion.
Are you aiming this for the current merge window, ie for 2.6.27?
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!
From: Christian Ehrhardt <hidden> Date: 2008-07-24 08:17:37
Tony Breeds wrote:
On Wed, Jul 23, 2008 at 10:36:41AM +0200, ehrhardt@linux.vnet.ibm.com wrote:
quoted
From: Christian Ehrhardt <redacted>
This patch series implements a paravirtualization interface using:
- the device tree mechanism to pass hypervisor informations to the guest
- hypercalls for guest->host calls
- an example exploiter of that interface (magic page)
This is work in progress, but working so far. I just start to really exploit
the fuctionality behind the magic page mechanism therefor I can't provide any
performance improvements so far, but it is evolved enough for RFC and to start
the standardization discussion.
Are you aiming this for the current merge window, ie for 2.6.27?
The aim is not really fixed. It would be nice to get into 2.6.27, but
since I can't yet expect how long it takes ...
Actually the guest patches would already go through reviews and
upstream, due to the fact that the guest code changes are not that (the
major part of the implementation will go over kvmppc -> kvm upstream).
But since I want to discuss about the standardization on the embedded
hypervisor list first, the naming of the device tree entries are not
fixed yet.
Therefor I can't yet define which kernel version merge window I'll
target/reach.
btw - embedded hypervisor - I got advised that this is a closed list
which I forgot.
Sorry for all who got bounces on a replay-all action. The next version
of the patch series will go to the involved open source lists only and a
separate more standardization than patch style mail series to embedded
hypervisor.
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!
--
Grüsse / regards,
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization
From: Tony Breeds <hidden> Date: 2008-07-25 01:08:45
On Thu, Jul 24, 2008 at 10:17:31AM +0200, Christian Ehrhardt wrote:
The aim is not really fixed. It would be nice to get into 2.6.27, but
since I can't yet expect how long it takes ...
Ahh okay, Id say given that we're 2/3rds through the merge window then
2.8.28 is a safer target.
Actually the guest patches would already go through reviews and
upstream, due to the fact that the guest code changes are not that (the
major part of the implementation will go over kvmppc -> kvm upstream).
But since I want to discuss about the standardization on the embedded
hypervisor list first, the naming of the device tree entries are not
fixed yet.
Okay. When that's done we can take another look at them.
Therefor I can't yet define which kernel version merge window I'll
target/reach.
btw - embedded hypervisor - I got advised that this is a closed list
which I forgot.
... snipped from this reply
Yours Tony
linux.conf.au http://www.marchsouth.org/
Jan 19 - 24 2009 The Australian Linux Technical Conference!