[PATCH 1/4] kvmppc: read device tree hypervisor node infrastructure
ehrhardt at linux.vnet.ibm.com
ehrhardt at linux.vnet.ibm.com
Tue Aug 19 20:36:41 EST 2008
From: Christian Ehrhardt <ehrhardt at linux.vnet.ibm.com>
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 <ehrhardt at linux.vnet.ibm.com>
---
[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 <hollisb at us.ibm.com>
+ * Christian Ehrhardt <ehrhardt at de.ibm.com>
+ */
+
+#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 <hollisb at us.ibm.com>
+ * Authors:
+ * Hollis Blanchard <hollisb at us.ibm.com>
+ * Christian Ehrhardt <ehrhardt at de.ibm.com>
*/
#ifndef __POWERPC_KVM_PARA_H__
@@ -22,15 +24,50 @@
#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;
+ int ret;
+
+ dn = of_find_node_by_path("/hypervisor");
+ ret = !!dn;
+
+ of_node_put(dn);
+
+ return ret;
}
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); i++) {
+ dtval = of_get_property(dn, para_features[i].dtcell, NULL);
+ if (dtval && *dtval == 1)
+ features |= (1 << para_features[i].feature);
+ }
+
+ of_node_put(dn);
+
+ return features;
}
+
+void kvm_guest_init(void);
#endif /* __KERNEL__ */
More information about the Linuxppc-dev
mailing list