Re: [PATCH 1/6] kvmppc: read device tree hypervisor node infrastructure

2008-07-24 Thread Christian Ehrhardt

Tony Breeds wrote:

On Wed, Jul 23, 2008 at 10:36:42AM +0200, [EMAIL PROTECTED] wrote:

Hi Christian,
A few comments inlined ...

  

[...]

+
 static inline int kvm_para_available(void)
 {
-   return 0;
+   struct device_node *dn;
+
+   dn = of_find_node_by_path(/hypervisor);



You need an of_node_put(dn);

  
I just looked at the linux/of.h and did not see that I have to free it 
again.

Thanks for the hint, I inserted both calls.

+
+   return !!dn;
 }
 
 static inline unsigned int kvm_arch_para_features(void)

 {
-   return 0;
+   struct device_node *dn;
+   const int *dtval;
+   unsigned int features = 0;
+   int i;
+
+   dn = of_find_node_by_path(/hypervisor);
+   if (!dn)
+   return 0;
+
+   for (i = 0; i  ARRAY_SIZE(para_features)-1; i++) {



Why -1?  Isn't ARRAY_SIZE(para_features) adequate?
  


yeah I already had this, bit the change was folded into the wrong patch, 
fixed now


[...]

Yours Tony

  linux.conf.auhttp://www.marchsouth.org/
  Jan 19 - 24 2009 The Australian Linux Technical Conference!

  



--

GrĂ¼sse / regards, 
Christian Ehrhardt

IBM Linux Technology Center, Open Virtualization

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

[PATCH 1/6] kvmppc: read device tree hypervisor node infrastructure

2008-07-23 Thread ehrhardt
From: Christian Ehrhardt [EMAIL PROTECTED]

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 [EMAIL PROTECTED]
---

[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]

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -80,6 +80,8 @@
 
 obj-$(CONFIG_8XX_MINIMAL_FPEMU) += softemu8xx.o
 
+obj-$(CONFIG_KVM_GUEST)+= kvm.o
+
 ifneq ($(CONFIG_PPC_INDIRECT_IO),y)
 obj-y  += iomap.o
 endif
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
new file mode 100644
--- /dev/null
+++ b/arch/powerpc/kernel/kvm.c
@@ -0,0 +1,30 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * Authors:
+ * Hollis Blanchard [EMAIL PROTECTED]
+ * Christian Ehrhardt [EMAIL PROTECTED]
+ */
+
+#include linux/percpu.h
+#include linux/mm.h
+#include linux/kvm_para.h
+
+void __init kvm_guest_init(void)
+{
+   if (!kvm_para_available())
+   return;
+}
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -17,6 +17,7 @@
 #include linux/cpu.h
 #include linux/console.h
 #include linux/lmb.h
+#include linux/kvm_para.h
 
 #include asm/io.h
 #include asm/prom.h
@@ -319,5 +320,7 @@
ppc_md.setup_arch();
if ( ppc_md.progress ) ppc_md.progress(arch: exit, 0x3eab);
 
+   kvm_guest_init();
+
paging_init();
 }
diff --git a/arch/powerpc/platforms/44x/Kconfig 
b/arch/powerpc/platforms/44x/Kconfig
--- a/arch/powerpc/platforms/44x/Kconfig
+++ b/arch/powerpc/platforms/44x/Kconfig
@@ -152,3 +152,10 @@
 # 44x errata/workaround config symbols, selected by the CPU models above
 config IBM440EP_ERR42
bool
+
+config KVM_GUEST
+   bool KVM Guest support
+   depends on EXPERIMENTAL
+   help
+   This option enables various optimizations for running under the KVM
+   hypervisor.
diff --git a/include/asm-powerpc/kvm_para.h b/include/asm-powerpc/kvm_para.h
--- a/include/asm-powerpc/kvm_para.h
+++ b/include/asm-powerpc/kvm_para.h
@@ -14,7 +14,9 @@
  *
  * Copyright IBM Corp. 2008
  *
- * Authors: Hollis Blanchard [EMAIL PROTECTED]
+ * Authors:
+ * Hollis Blanchard [EMAIL PROTECTED]
+ * Christian Ehrhardt [EMAIL PROTECTED]
  */
 
 #ifndef __POWERPC_KVM_PARA_H__
@@ -22,15 +24,44 @@
 
 #ifdef __KERNEL__
 
+#include linux/of.h
+
+static struct kvmppc_para_features {
+   char *dtcell;
+   int feature;
+} para_features[] = {
+};
+
 static inline int kvm_para_available(void)
 {
-   return 0;
+   struct device_node *dn;
+
+   dn = of_find_node_by_path(/hypervisor);
+
+   return !!dn;
 }
 
 static inline unsigned int kvm_arch_para_features(void)
 {
-   return 0;
+   struct device_node *dn;
+   const int *dtval;
+   unsigned int features = 0;
+   int i;
+
+   dn = of_find_node_by_path(/hypervisor);
+   if (!dn)
+   return 0;
+
+   for (i = 0; i  ARRAY_SIZE(para_features)-1; i++) {
+   dtval = of_get_property(dn, para_features[i].dtcell, NULL);
+   if (dtval  *dtval == 1)
+   features |= (1  para_features[i].feature);
+   }
+
+   return features;
 }
+
+void kvm_guest_init(void);
 
 #endif /* __KERNEL__ */
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/6] kvmppc: read device tree hypervisor node infrastructure

2008-07-23 Thread Tony Breeds
On Wed, Jul 23, 2008 at 10:36:42AM +0200, [EMAIL PROTECTED] wrote:

Hi Christian,
A few comments inlined ...

 diff --git a/include/asm-powerpc/kvm_para.h b/include/asm-powerpc/kvm_para.h
 --- a/include/asm-powerpc/kvm_para.h
 +++ b/include/asm-powerpc/kvm_para.h
 @@ -14,7 +14,9 @@
   *
   * Copyright IBM Corp. 2008
   *
 - * Authors: Hollis Blanchard [EMAIL PROTECTED]
 + * Authors:
 + *   Hollis Blanchard [EMAIL PROTECTED]
 + *   Christian Ehrhardt [EMAIL PROTECTED]
   */
  
  #ifndef __POWERPC_KVM_PARA_H__
 @@ -22,15 +24,44 @@
  
  #ifdef __KERNEL__
  
 +#include linux/of.h
 +
 +static struct kvmppc_para_features {
 + char *dtcell;
 + int feature;
 +} para_features[] = {
 +};
 +
  static inline int kvm_para_available(void)
  {
 - return 0;
 + struct device_node *dn;
 +
 + dn = of_find_node_by_path(/hypervisor);

You need an of_node_put(dn);

 +
 + return !!dn;
  }
  
  static inline unsigned int kvm_arch_para_features(void)
  {
 - return 0;
 + struct device_node *dn;
 + const int *dtval;
 + unsigned int features = 0;
 + int i;
 +
 + dn = of_find_node_by_path(/hypervisor);
 + if (!dn)
 + return 0;
 +
 + for (i = 0; i  ARRAY_SIZE(para_features)-1; i++) {

Why -1?  Isn't ARRAY_SIZE(para_features) adequate?

 + dtval = of_get_property(dn, para_features[i].dtcell, NULL);
 + if (dtval  *dtval == 1)
 + features |= (1  para_features[i].feature);
 + }
 +

You need an of_node_put(dn);

 + return features;
  }

Yours Tony

  linux.conf.auhttp://www.marchsouth.org/
  Jan 19 - 24 2009 The Australian Linux Technical Conference!

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev