From patchwork Thu Jan 5 09:06:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Yu-B13201 X-Patchwork-Id: 134453 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 8EAB81008A9 for ; Thu, 5 Jan 2012 20:57:43 +1100 (EST) Received: by ozlabs.org (Postfix) id 3FF6F1007D6; Thu, 5 Jan 2012 20:57:31 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from TX2EHSOBE006.bigfish.com (tx2ehsobe003.messaging.microsoft.com [65.55.88.13]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Microsoft Secure Server Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id D2DAF1007D7 for ; Thu, 5 Jan 2012 20:57:30 +1100 (EST) Received: from mail148-tx2-R.bigfish.com (10.9.14.238) by TX2EHSOBE006.bigfish.com (10.9.40.26) with Microsoft SMTP Server id 14.1.225.23; Thu, 5 Jan 2012 09:57:26 +0000 Received: from mail148-tx2 (localhost [127.0.0.1]) by mail148-tx2-R.bigfish.com (Postfix) with ESMTP id CBBCD4801EC; Thu, 5 Jan 2012 09:57:26 +0000 (UTC) X-SpamScore: 3 X-BigFish: VS3(zzc8kzz1202hzz8275bhz2dh2a8h668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail148-tx2 (localhost.localdomain [127.0.0.1]) by mail148-tx2 (MessageSwitch) id 1325757446568721_28392; Thu, 5 Jan 2012 09:57:26 +0000 (UTC) Received: from TX2EHSMHS033.bigfish.com (unknown [10.9.14.238]) by mail148-tx2.bigfish.com (Postfix) with ESMTP id 8463E8004D; Thu, 5 Jan 2012 09:57:26 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS033.bigfish.com (10.9.99.133) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 5 Jan 2012 09:57:26 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.355.3; Thu, 5 Jan 2012 03:57:25 -0600 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id q059vMs9029306; Thu, 5 Jan 2012 03:57:23 -0600 (CST) From: Liu Yu To: , , Subject: [PATCH 1/3] KVM: PPC: epapr: Factor out the epapr init Date: Thu, 5 Jan 2012 17:06:51 +0800 Message-ID: <1325754412-29963-1-git-send-email-yu.liu@freescale.com> X-Mailer: git-send-email 1.6.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: scottwood@freescale.com, linuxppc-dev@ozlabs.org, Liu Yu , timur@freescale.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org from the kvm guest paravirt init code. Signed-off-by: Liu Yu --- arch/powerpc/include/asm/epapr_hcalls.h | 8 +++++ arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/epapr_para.c | 45 +++++++++++++++++++++++++++++++ arch/powerpc/kernel/kvm.c | 9 +++++- 4 files changed, 62 insertions(+), 1 deletions(-) create mode 100644 arch/powerpc/kernel/epapr_para.c diff --git a/arch/powerpc/include/asm/epapr_hcalls.h b/arch/powerpc/include/asm/epapr_hcalls.h index f3b0c2c..c4b86e4 100644 --- a/arch/powerpc/include/asm/epapr_hcalls.h +++ b/arch/powerpc/include/asm/epapr_hcalls.h @@ -148,6 +148,14 @@ #define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, "r5" #define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, "r4" +extern u32 *epapr_hcall_insts; +extern int epapr_hcall_insts_len; + +static inline void epapr_get_hcall_insts(u32 **instp, int *lenp) +{ + *instp = epapr_hcall_insts; + *lenp = epapr_hcall_insts_len; +} /* * We use "uintptr_t" to define a register because it's guaranteed to be a diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index ce4f7f1..1052bbc 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -134,6 +134,7 @@ ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),) obj-y += ppc_save_regs.o endif +obj-$(CONFIG_BOOKE) += epapr_para.o obj-$(CONFIG_KVM_GUEST) += kvm.o kvm_emul.o # Disable GCOV in odd or sensitive code diff --git a/arch/powerpc/kernel/epapr_para.c b/arch/powerpc/kernel/epapr_para.c new file mode 100644 index 0000000..714dcb3 --- /dev/null +++ b/arch/powerpc/kernel/epapr_para.c @@ -0,0 +1,45 @@ +/* + * ePAPR para-virtualization support. + * + * 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 (C) 2012 Freescale Semiconductor, Inc. + */ + +#include +#include + +u32 *epapr_hcall_insts; +int epapr_hcall_insts_len; + +static int __init epapr_para_init(void) +{ + struct device_node *hyper_node; + u32 *insts; + int len; + + hyper_node = of_find_node_by_path("/hypervisor"); + if (!hyper_node) + return -ENODEV; + + insts = (u32*)of_get_property(hyper_node, "hcall-instructions", &len); + if (!(len % 4) && (len >= (4 * 4))) { + epapr_hcall_insts = insts; + epapr_hcall_insts_len = len; + } + + return 0; +} + +early_initcall(epapr_para_init); diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c index b06bdae..82a9137 100644 --- a/arch/powerpc/kernel/kvm.c +++ b/arch/powerpc/kernel/kvm.c @@ -28,6 +28,7 @@ #include #include #include +#include #define KVM_MAGIC_PAGE (-4096L) #define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x) @@ -535,9 +536,10 @@ EXPORT_SYMBOL_GPL(kvm_hypercall); static int kvm_para_setup(void) { extern u32 kvm_hypercall_start; - struct device_node *hyper_node; u32 *insts; int len, i; +#ifndef CONFIG_BOOKE + struct device_node *hyper_node; hyper_node = of_find_node_by_path("/hypervisor"); if (!hyper_node) @@ -548,6 +550,11 @@ static int kvm_para_setup(void) return -1; if (len > (4 * 4)) return -1; +#else + epapr_get_hcall_insts(&insts, &len); + if (insts == NULL) + return -1; +#endif /* !BOOKE */ for (i = 0; i < (len / 4); i++) kvm_patch_ins(&(&kvm_hypercall_start)[i], insts[i]);