Re: [PATCH v9 1/4] KVM: PPC: epapr: Factor out the epapr init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08.03.2012, at 00:12, Stuart Yoder wrote:

> From: Liu Yu-B13201 <Yu.Liu@xxxxxxxxxxxxx>
> 
> from the kvm guest paravirt init code.
> 
> Signed-off-by: Liu Yu <yu.liu@xxxxxxxxxxxxx>
> [stuart.yoder@xxxxxxxxxxxxx: misc minor fixes]
> Signed-off-by: Stuart Yoder <stuart.yoder@xxxxxxxxxxxxx>
> ---
> -v9: no changes
> 
> arch/powerpc/include/asm/epapr_hcalls.h |    2 +
> arch/powerpc/kernel/Makefile            |    1 +
> arch/powerpc/kernel/epapr_hcalls.S      |   25 +++++++++++++++
> arch/powerpc/kernel/epapr_paravirt.c    |   52 +++++++++++++++++++++++++++++++
> arch/powerpc/kernel/kvm.c               |   28 ++---------------
> arch/powerpc/kernel/kvm_emul.S          |   10 ------
> arch/powerpc/platforms/Kconfig          |    9 +++++
> 7 files changed, 92 insertions(+), 35 deletions(-)
> create mode 100644 arch/powerpc/kernel/epapr_hcalls.S
> create mode 100644 arch/powerpc/kernel/epapr_paravirt.c
> 
> diff --git a/arch/powerpc/include/asm/epapr_hcalls.h b/arch/powerpc/include/asm/epapr_hcalls.h
> index f3b0c2c..2173d4c 100644
> --- a/arch/powerpc/include/asm/epapr_hcalls.h
> +++ b/arch/powerpc/include/asm/epapr_hcalls.h
> @@ -148,6 +148,8 @@
> #define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, "r5"
> #define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, "r4"
> 
> +extern bool epapr_paravirt_enabled;
> +extern u32 epapr_hypercall_start[];
> 
> /*
>  * 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..09011d6 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_EPAPR_PARAVIRT)	+= epapr_paravirt.o epapr_hcalls.o
> obj-$(CONFIG_KVM_GUEST)		+= kvm.o kvm_emul.o
> 
> # Disable GCOV in odd or sensitive code
> diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S
> new file mode 100644
> index 0000000..697b390
> --- /dev/null
> +++ b/arch/powerpc/kernel/epapr_hcalls.S
> @@ -0,0 +1,25 @@
> +/*
> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +
> +#include <linux/threads.h>
> +#include <asm/reg.h>
> +#include <asm/page.h>
> +#include <asm/cputable.h>
> +#include <asm/thread_info.h>
> +#include <asm/ppc_asm.h>
> +#include <asm/asm-offsets.h>
> +
> +/* Hypercall entry point. Will be patched with device tree instructions. */
> +.global epapr_hypercall_start
> +epapr_hypercall_start:
> +	li	r3, -1
> +	nop
> +	nop
> +	nop
> +	blr
> diff --git a/arch/powerpc/kernel/epapr_paravirt.c b/arch/powerpc/kernel/epapr_paravirt.c
> new file mode 100644
> index 0000000..028aeae
> --- /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);

Just want to double-check. Are you 100% sure that this gets called before kvm_guest_init()?


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux