From patchwork Tue Sep 16 06:27:28 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ehrhardt@linux.vnet.ibm.com X-Patchwork-Id: 288 X-Patchwork-Delegate: hollis@penguinppc.org Return-Path: X-Original-To: patchwork@ozlabs.org Delivered-To: patchwork@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 5DB67DDF02 for ; Tue, 16 Sep 2008 16:28:31 +1000 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from mtagate2.de.ibm.com (mtagate2.de.ibm.com [195.212.17.162]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mtagate2.de.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 03567DDDFA for ; Tue, 16 Sep 2008 16:28:10 +1000 (EST) Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id m8G6Rwch030557 for ; Tue, 16 Sep 2008 06:28:01 GMT Received: from d12av01.megacenter.de.ibm.com (d12av01.megacenter.de.ibm.com [9.149.165.212]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m8G6Rwma2207950 for ; Tue, 16 Sep 2008 08:27:58 +0200 Received: from d12av01.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av01.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m8G6Rs2t025222 for ; Tue, 16 Sep 2008 08:27:55 +0200 Received: from localhost.localdomain (dyn-9-152-198-109.boeblingen.de.ibm.com [9.152.198.109]) by d12av01.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m8G6Rsbt024799; Tue, 16 Sep 2008 08:27:54 +0200 From: ehrhardt@linux.vnet.ibm.com To: linuxppc-dev@ozlabs.org, kvm-ppc@vger.kernel.org Subject: [PATCH 1/3] kvmppc: read device tree hypervisor node infrastructure Date: Tue, 16 Sep 2008 08:27:28 +0200 Message-Id: <1221546450-15761-2-git-send-email-ehrhardt@linux.vnet.ibm.com> X-Mailer: git-send-email 1.5.4.3 In-Reply-To: <1221546450-15761-1-git-send-email-ehrhardt@linux.vnet.ibm.com> References: <1221546450-15761-1-git-send-email-ehrhardt@linux.vnet.ibm.com> Cc: hollisb@us.ibm.com X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork=ozlabs.org@ozlabs.org From: Christian Ehrhardt 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 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 + * Christian Ehrhardt + */ + +#include +#include +#include + +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 #include #include +#include #include #include @@ -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 + * Authors: + * Hollis Blanchard + * Christian Ehrhardt */ #ifndef __POWERPC_KVM_PARA_H__ @@ -22,15 +24,50 @@ #ifdef __KERNEL__ +#include + +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__ */