diff options
author | Liu Yu-B13201 <Yu.Liu@freescale.com> | 2012-03-15 10:52:13 +0000 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-05-30 11:43:10 +0200 |
commit | 2e1ae9c07df5956ebab19144aa0da58ea37c9f69 (patch) | |
tree | 5ec9b74d22b72af3691897921ca6bce76ea7d4aa /arch/powerpc/kernel/epapr_paravirt.c | |
parent | b48b2c3e50433ff6f7e46186daa7f986bd960215 (diff) | |
download | talos-obmc-linux-2e1ae9c07df5956ebab19144aa0da58ea37c9f69.tar.gz talos-obmc-linux-2e1ae9c07df5956ebab19144aa0da58ea37c9f69.zip |
KVM: PPC: Factor out guest epapr initialization
epapr paravirtualization support is now a Kconfig
selectable option
Signed-off-by: Liu Yu <yu.liu@freescale.com>
[stuart.yoder@freescale.com: misc minor fixes, description update]
Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kernel/epapr_paravirt.c')
-rw-r--r-- | arch/powerpc/kernel/epapr_paravirt.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/epapr_paravirt.c b/arch/powerpc/kernel/epapr_paravirt.c new file mode 100644 index 000000000000..028aeae370b6 --- /dev/null +++ b/arch/powerpc/kernel/epapr_paravirt.c @@ -0,0 +1,52 @@ +/* + * 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 <linux/of.h> +#include <asm/epapr_hcalls.h> +#include <asm/cacheflush.h> +#include <asm/code-patching.h> + +bool epapr_paravirt_enabled; + +static int __init epapr_paravirt_init(void) +{ + struct device_node *hyper_node; + const u32 *insts; + int len, i; + + hyper_node = of_find_node_by_path("/hypervisor"); + if (!hyper_node) + return -ENODEV; + + insts = of_get_property(hyper_node, "hcall-instructions", &len); + if (!insts) + return -ENODEV; + + if (len % 4 || len > (4 * 4)) + return -ENODEV; + + for (i = 0; i < (len / 4); i++) + patch_instruction(epapr_hypercall_start + i, insts[i]); + + epapr_paravirt_enabled = true; + + return 0; +} + +early_initcall(epapr_paravirt_init); |