From: Scott Wood <scottwood@freescale.com>
To: Liu Yu <yu.liu@freescale.com>
Cc: agraf@suse.de, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
linuxppc-dev@ozlabs.org, galak@kernel.crashing.org,
timur@freescale.com
Subject: Re: [PATCH v2 3/3] KVM: PPC: epapr: install ev_idle hcall for e500
Date: Mon, 09 Jan 2012 21:15:31 +0000 [thread overview]
Message-ID: <4F0B58F3.7040308@freescale.com> (raw)
In-Reply-To: <1325754412-29963-2-git-send-email-yu.liu@freescale.com>
On 01/05/2012 03:06 AM, Liu Yu wrote:
> diff --git a/arch/powerpc/kernel/idle_e500.S b/arch/powerpc/kernel/idle_e500.S
> index 3e2b95c..6ea95f0 100644
> --- a/arch/powerpc/kernel/idle_e500.S
> +++ b/arch/powerpc/kernel/idle_e500.S
> @@ -85,6 +85,23 @@ END_FTR_SECTION_IFSET(CPU_FTR_L2CSR|CPU_FTR_CAN_NAP)
> 2: b 2b
> #endif /* !E500MC */
>
> +#ifdef CONFIG_KVM_GUEST
> +/*
> + * r3 contains the pointer to in[8]
> + * r4 contains the pointer to out[8]
> + * r5 contains the hcall vendor and nr
> + * r6 contains the handler which send hcall
> + */
> +_GLOBAL(e500_ev_idle)
> + rlwinm r7,r1,0,0,31-THREAD_SHIFT /* current thread_info */
> + lwz r8,TI_LOCAL_FLAGS(r7) /* set napping bit */
> + ori r8,r8,_TLF_NAPPING /* so when we take an exception */
> + stw r8,TI_LOCAL_FLAGS(r7) /* it will return to our caller */
> + wrteei 1
> + mtctr r6
> + bctr
> +#endif /* KVM_GUEST */
You'll need to branch back to the hcall invocation in an infinite loop
-- the only way we should leave is via an interrupt.
> +static void kvm_hcall_idle(void)
> +{
> +#ifdef CONFIG_KVM_E500
> + ulong in[8];
> + ulong out[8];
> +
> + e500_ev_idle(in, out, HC_VENDOR_EPAPR | HC_EV_IDLE, kvm_hypercall);
> +#endif
> +}
kvm_hypercall is C code. As stated before, you cannot use C code while
_TLF_NAPPING is set.
> +static bool kvm_para_has_idle(void)
> +{
> +#ifdef CONFIG_BOOKE
> + return epapr_hcall_has_idle;
> +#else
> + return false;
> +#endif
> +}
> +
> static int __init kvm_guest_init(void)
> {
> if (!kvm_para_available())
> @@ -594,6 +614,10 @@ static int __init kvm_guest_init(void)
> powersave_nap = 1;
> #endif
>
> + /* Install hcall based power_save for guest kernel */
> + if (kvm_para_has_idle())
> + ppc_md.power_save = kvm_hcall_idle;
Why did you only move it halfway out of KVM code? ePAPR features such
as idle hcall should work on any ePAPR hypervisor, even with all KVM
code disabled.
Plus everything Alex said. :-)
-Scott
WARNING: multiple messages have this Message-ID (diff)
From: Scott Wood <scottwood@freescale.com>
To: Liu Yu <yu.liu@freescale.com>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, agraf@suse.de,
linuxppc-dev@ozlabs.org, timur@freescale.com
Subject: Re: [PATCH v2 3/3] KVM: PPC: epapr: install ev_idle hcall for e500 guest
Date: Mon, 9 Jan 2012 15:15:31 -0600 [thread overview]
Message-ID: <4F0B58F3.7040308@freescale.com> (raw)
In-Reply-To: <1325754412-29963-2-git-send-email-yu.liu@freescale.com>
On 01/05/2012 03:06 AM, Liu Yu wrote:
> diff --git a/arch/powerpc/kernel/idle_e500.S b/arch/powerpc/kernel/idle_e500.S
> index 3e2b95c..6ea95f0 100644
> --- a/arch/powerpc/kernel/idle_e500.S
> +++ b/arch/powerpc/kernel/idle_e500.S
> @@ -85,6 +85,23 @@ END_FTR_SECTION_IFSET(CPU_FTR_L2CSR|CPU_FTR_CAN_NAP)
> 2: b 2b
> #endif /* !E500MC */
>
> +#ifdef CONFIG_KVM_GUEST
> +/*
> + * r3 contains the pointer to in[8]
> + * r4 contains the pointer to out[8]
> + * r5 contains the hcall vendor and nr
> + * r6 contains the handler which send hcall
> + */
> +_GLOBAL(e500_ev_idle)
> + rlwinm r7,r1,0,0,31-THREAD_SHIFT /* current thread_info */
> + lwz r8,TI_LOCAL_FLAGS(r7) /* set napping bit */
> + ori r8,r8,_TLF_NAPPING /* so when we take an exception */
> + stw r8,TI_LOCAL_FLAGS(r7) /* it will return to our caller */
> + wrteei 1
> + mtctr r6
> + bctr
> +#endif /* KVM_GUEST */
You'll need to branch back to the hcall invocation in an infinite loop
-- the only way we should leave is via an interrupt.
> +static void kvm_hcall_idle(void)
> +{
> +#ifdef CONFIG_KVM_E500
> + ulong in[8];
> + ulong out[8];
> +
> + e500_ev_idle(in, out, HC_VENDOR_EPAPR | HC_EV_IDLE, kvm_hypercall);
> +#endif
> +}
kvm_hypercall is C code. As stated before, you cannot use C code while
_TLF_NAPPING is set.
> +static bool kvm_para_has_idle(void)
> +{
> +#ifdef CONFIG_BOOKE
> + return epapr_hcall_has_idle;
> +#else
> + return false;
> +#endif
> +}
> +
> static int __init kvm_guest_init(void)
> {
> if (!kvm_para_available())
> @@ -594,6 +614,10 @@ static int __init kvm_guest_init(void)
> powersave_nap = 1;
> #endif
>
> + /* Install hcall based power_save for guest kernel */
> + if (kvm_para_has_idle())
> + ppc_md.power_save = kvm_hcall_idle;
Why did you only move it halfway out of KVM code? ePAPR features such
as idle hcall should work on any ePAPR hypervisor, even with all KVM
code disabled.
Plus everything Alex said. :-)
-Scott
WARNING: multiple messages have this Message-ID (diff)
From: Scott Wood <scottwood@freescale.com>
To: Liu Yu <yu.liu@freescale.com>
Cc: <agraf@suse.de>, <kvm-ppc@vger.kernel.org>, <kvm@vger.kernel.org>,
<linuxppc-dev@ozlabs.org>, <galak@kernel.crashing.org>,
<timur@freescale.com>
Subject: Re: [PATCH v2 3/3] KVM: PPC: epapr: install ev_idle hcall for e500 guest
Date: Mon, 9 Jan 2012 15:15:31 -0600 [thread overview]
Message-ID: <4F0B58F3.7040308@freescale.com> (raw)
In-Reply-To: <1325754412-29963-2-git-send-email-yu.liu@freescale.com>
On 01/05/2012 03:06 AM, Liu Yu wrote:
> diff --git a/arch/powerpc/kernel/idle_e500.S b/arch/powerpc/kernel/idle_e500.S
> index 3e2b95c..6ea95f0 100644
> --- a/arch/powerpc/kernel/idle_e500.S
> +++ b/arch/powerpc/kernel/idle_e500.S
> @@ -85,6 +85,23 @@ END_FTR_SECTION_IFSET(CPU_FTR_L2CSR|CPU_FTR_CAN_NAP)
> 2: b 2b
> #endif /* !E500MC */
>
> +#ifdef CONFIG_KVM_GUEST
> +/*
> + * r3 contains the pointer to in[8]
> + * r4 contains the pointer to out[8]
> + * r5 contains the hcall vendor and nr
> + * r6 contains the handler which send hcall
> + */
> +_GLOBAL(e500_ev_idle)
> + rlwinm r7,r1,0,0,31-THREAD_SHIFT /* current thread_info */
> + lwz r8,TI_LOCAL_FLAGS(r7) /* set napping bit */
> + ori r8,r8,_TLF_NAPPING /* so when we take an exception */
> + stw r8,TI_LOCAL_FLAGS(r7) /* it will return to our caller */
> + wrteei 1
> + mtctr r6
> + bctr
> +#endif /* KVM_GUEST */
You'll need to branch back to the hcall invocation in an infinite loop
-- the only way we should leave is via an interrupt.
> +static void kvm_hcall_idle(void)
> +{
> +#ifdef CONFIG_KVM_E500
> + ulong in[8];
> + ulong out[8];
> +
> + e500_ev_idle(in, out, HC_VENDOR_EPAPR | HC_EV_IDLE, kvm_hypercall);
> +#endif
> +}
kvm_hypercall is C code. As stated before, you cannot use C code while
_TLF_NAPPING is set.
> +static bool kvm_para_has_idle(void)
> +{
> +#ifdef CONFIG_BOOKE
> + return epapr_hcall_has_idle;
> +#else
> + return false;
> +#endif
> +}
> +
> static int __init kvm_guest_init(void)
> {
> if (!kvm_para_available())
> @@ -594,6 +614,10 @@ static int __init kvm_guest_init(void)
> powersave_nap = 1;
> #endif
>
> + /* Install hcall based power_save for guest kernel */
> + if (kvm_para_has_idle())
> + ppc_md.power_save = kvm_hcall_idle;
Why did you only move it halfway out of KVM code? ePAPR features such
as idle hcall should work on any ePAPR hypervisor, even with all KVM
code disabled.
Plus everything Alex said. :-)
-Scott
next prev parent reply other threads:[~2012-01-09 21:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-05 9:06 [PATCH 1/3] KVM: PPC: epapr: Factor out the epapr init Liu Yu
2012-01-05 9:06 ` Liu Yu
2012-01-05 9:06 ` Liu Yu
2012-01-05 9:06 ` [PATCH v2 3/3] KVM: PPC: epapr: install ev_idle hcall for e500 guest Liu Yu
2012-01-05 9:06 ` Liu Yu
2012-01-05 9:06 ` Liu Yu
2012-01-09 14:05 ` Alexander Graf
2012-01-09 14:05 ` Alexander Graf
2012-01-09 14:05 ` Alexander Graf
2012-01-09 21:15 ` Scott Wood [this message]
2012-01-09 21:15 ` Scott Wood
2012-01-09 21:15 ` Scott Wood
2012-01-09 13:50 ` [PATCH 1/3] KVM: PPC: epapr: Factor out the epapr init Alexander Graf
2012-01-09 13:50 ` Alexander Graf
2012-01-09 13:50 ` Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F0B58F3.7040308@freescale.com \
--to=scottwood@freescale.com \
--cc=agraf@suse.de \
--cc=galak@kernel.crashing.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=timur@freescale.com \
--cc=yu.liu@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.