From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Mon, 02 Jan 2012 18:23:09 +0000 Subject: Re: [PATCH 2/2] KVM: PPC: epapr: Install ev_idle hcall for paravirt Message-Id: <4F01F60D.9010002@freescale.com> List-Id: References: <1325312176-17697-1-git-send-email-yu.liu@freescale.com> <1325312176-17697-2-git-send-email-yu.liu@freescale.com> In-Reply-To: <1325312176-17697-2-git-send-email-yu.liu@freescale.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Liu Yu Cc: agraf@suse.de, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org On 12/31/2011 12:16 AM, Liu Yu wrote: > If the guest hypervisor node contains "has-idle" property. > > Signed-off-by: Liu Yu > --- > arch/powerpc/kernel/kvm.c | 29 +++++++++++++++++++++++++++++ > 1 files changed, 29 insertions(+), 0 deletions(-) > > diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c > index b06bdae..258f129 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) > @@ -571,6 +572,30 @@ static __init void kvm_free_tmp(void) > } > } > > +static void kvm_hcall_ev_idle(void) > +{ > + ulong in[8]; > + ulong out[8]; > + > + current_thread_info()->local_flags |= _TLF_NAPPING; > + local_irq_enable(); > + kvm_hypercall(in, out, HC_VENDOR_EPAPR | HC_EV_IDLE); > +} I think this has to be done in assembly -- otherwise it's not safe for the interrupt handler to return directly to LR. > +static int kvm_para_ev_has_idle(void) > +{ > + struct device_node *hyper_node; > + > + hyper_node = of_find_node_by_path("/hypervisor"); > + if (!hyper_node) > + return 0; > + > + if (of_get_property(hyper_node, "has-idle", NULL)) > + return 1; > + > + return 0; > +} Since this is standardized in ePAPR, can we move it out of kvm.c an into generic code to work with any hypervisor that sets has-idle? Likewise with kvm_para_setup(). -Scott From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Subject: Re: [PATCH 2/2] KVM: PPC: epapr: Install ev_idle hcall for paravirt guest linux Date: Mon, 2 Jan 2012 12:23:09 -0600 Message-ID: <4F01F60D.9010002@freescale.com> References: <1325312176-17697-1-git-send-email-yu.liu@freescale.com> <1325312176-17697-2-git-send-email-yu.liu@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: , , To: Liu Yu Return-path: In-Reply-To: <1325312176-17697-2-git-send-email-yu.liu@freescale.com> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 12/31/2011 12:16 AM, Liu Yu wrote: > If the guest hypervisor node contains "has-idle" property. > > Signed-off-by: Liu Yu > --- > arch/powerpc/kernel/kvm.c | 29 +++++++++++++++++++++++++++++ > 1 files changed, 29 insertions(+), 0 deletions(-) > > diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c > index b06bdae..258f129 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) > @@ -571,6 +572,30 @@ static __init void kvm_free_tmp(void) > } > } > > +static void kvm_hcall_ev_idle(void) > +{ > + ulong in[8]; > + ulong out[8]; > + > + current_thread_info()->local_flags |= _TLF_NAPPING; > + local_irq_enable(); > + kvm_hypercall(in, out, HC_VENDOR_EPAPR | HC_EV_IDLE); > +} I think this has to be done in assembly -- otherwise it's not safe for the interrupt handler to return directly to LR. > +static int kvm_para_ev_has_idle(void) > +{ > + struct device_node *hyper_node; > + > + hyper_node = of_find_node_by_path("/hypervisor"); > + if (!hyper_node) > + return 0; > + > + if (of_get_property(hyper_node, "has-idle", NULL)) > + return 1; > + > + return 0; > +} Since this is standardized in ePAPR, can we move it out of kvm.c an into generic code to work with any hypervisor that sets has-idle? Likewise with kvm_para_setup(). -Scott