@@ -726,7 +727,7 @@ unsigned long kvm_hypercall(unsigned long *in,unsignedlongregisterr11asm("r11")=nr;unsignedlongregisterr12asm("r12");-asmvolatile("bl kvm_hypercall_start"+asmvolatile("bl epapr_hypercall_start":"=r"(r0),"=r"(r3),"=r"(r4),"=r"(r5),"=r"(r6),"=r"(r7),"=r"(r8),"=r"(r9),"=r"(r10),"=r"(r11),"=r"(r12)
@@ -747,29 +748,6 @@ unsigned long kvm_hypercall(unsigned long *in,}EXPORT_SYMBOL_GPL(kvm_hypercall);-staticintkvm_para_setup(void)-{-externu32kvm_hypercall_start;-structdevice_node*hyper_node;-u32*insts;-intlen,i;--hyper_node=of_find_node_by_path("/hypervisor");-if(!hyper_node)-return-1;--insts=(u32*)of_get_property(hyper_node,"hcall-instructions",&len);-if(len%4)-return-1;-if(len>(4*4))-return-1;--for(i=0;i<(len/4);i++)-kvm_patch_ins(&(&kvm_hypercall_start)[i],insts[i]);--return0;-}-static__initvoidkvm_free_tmp(void){unsignedlongstart,end;
@@ -791,7 +769,7 @@ static int __init kvm_guest_init(void)if(!kvm_para_available())gotofree_tmp;-if(kvm_para_setup())+if(!epapr_para_enabled)gotofree_tmp;if(kvm_para_has_feature(KVM_FEATURE_MAGIC_PAGE))
And add a new flag definition in kvm_ppc_pvinfo to indicate
whether host support EV_IDLE hcall.
Signed-off-by: Liu Yu <redacted>
---
v4:
no change
arch/powerpc/include/asm/kvm_para.h | 14 ++++++++++++--
arch/powerpc/kvm/powerpc.c | 8 ++++++++
include/linux/kvm.h | 2 ++
3 files changed, 22 insertions(+), 2 deletions(-)
@@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)/* Second return value is in r4 */break;+caseHC_VENDOR_EPAPR|HC_EV_IDLE:+r=HC_EV_SUCCESS;+kvm_vcpu_block(vcpu);+break;default:r=HC_EV_UNIMPLEMENTED;break;
@@ -746,6 +750,10 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)pvinfo->hcall[2]=inst_sc;pvinfo->hcall[3]=inst_nop;+#ifdef CONFIG_BOOKE+pvinfo->flags|=KVM_PPC_PVINFO_FLAGS_EV_IDLE;+#endif+return0;}
@@ -449,6 +449,8 @@ struct kvm_ppc_pvinfo {__u8pad[108];};+#define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0)+#define KVMIO 0xAE/* machine type bits, to be used as argument to KVM_CREATE_VM */
#define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, "r5"
#define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, "r4"
=20
+extern bool epapr_para_enabled;
+extern u32 epapr_hypercall_start[];
=20
/*
* We use "uintptr_t" to define a register because it's guaranteed to be a=
=20
config KVM_BOOK3S_HANDLER
bool
--=20
1.7.0.4
=20
=20
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Alexander Graf <hidden> Date: 2012-02-16 10:19:28
On 16.02.2012, at 10:26, Liu Yu [off-list ref] wrote:
quoted hunk
And add a new flag definition in kvm_ppc_pvinfo to indicate
whether host support EV_IDLE hcall.
=20
Signed-off-by: Liu Yu <redacted>
---
v4:
no change
=20
arch/powerpc/include/asm/kvm_para.h | 14 ++++++++++++--
arch/powerpc/kvm/powerpc.c | 8 ++++++++
include/linux/kvm.h | 2 ++
3 files changed, 22 insertions(+), 2 deletions(-)
=20
@@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
=20
/* Second return value is in r4 */
break;
+ case HC_VENDOR_EPAPR | HC_EV_IDLE:
+ r =3D HC_EV_SUCCESS;
+ kvm_vcpu_block(vcpu);
+ break;
default:
r =3D HC_EV_UNIMPLEMENTED;
break;
@@ -746,6 +750,10 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvi=
};
=20
+#define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0)
+
#define KVMIO 0xAE
=20
/* machine type bits, to be used as argument to KVM_CREATE_VM */
--=20
1.7.0.4
=20
=20
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
=20
+#define HC_VENDOR_EPAPR (1 << 16)
+#define HC_EV_IDLE 16
+
+_GLOBAL(epapr_ev_idle)
+epapr_ev_idle:
+ rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info */
+ lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */
+ ori r4,r4,_TLF_NAPPING /* so when we take an exception */
+ stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */
+
+ wrteei 1
+
+idle_loop:
+ LOAD_REG_IMMEDIATE(r11, HC_VENDOR_EPAPR | HC_EV_IDLE)
+
+.global epapr_ev_idle_start
+epapr_ev_idle_start:
+ li r3, -1
+ nop
+ nop
+ nop
Can't you just bl into epapr_hypercall_start? You don't even have to save th=
e old lr. because we never return anyways :)
Alex
+
+ /*
+ * Guard against spurious wakeups (e.g. from a hypervisor) --
+ * any real interrupt will cause us to return to LR due to
+ * _TLF_NAPPING.
+ */
+ b idle_loop
+
/* Hypercall entry point. Will be patched with device tree instructions. *=
@@ -35,10 +39,17 @@ static int __init epapr_para_init(void)
=20
insts =3D of_get_property(hyper_node, "hcall-instructions", &len);
if (!(len % 4) && (len >=3D (4 * 4))) {
- for (i =3D 0; i < (len / 4); i++)
+ for (i =3D 0; i < (len / 4); i++) {
epapr_hypercall_start[i] =3D insts[i];
+ epapr_ev_idle_start[i] =3D insts[i];
+ }
flush_icache_range((ulong)epapr_hypercall_start,
(ulong)epapr_hypercall_start + len);
+ flush_icache_range((ulong)epapr_ev_idle_start,
+ (ulong)epapr_ev_idle_start + len);
+
+ if (of_get_property(hyper_node, "has-idle", NULL))
+ ppc_md.power_save =3D epapr_ev_idle;
=20
epapr_para_enabled =3D true;
}
--=20
1.7.0.4
=20
=20
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Scott Wood <hidden> Date: 2012-02-16 16:58:13
On 02/16/2012 04:24 AM, Alexander Graf wrote:
On 16.02.2012, at 10:26, Liu Yu [off-list ref] wrote:
quoted
+_GLOBAL(epapr_ev_idle)
+epapr_ev_idle:
+ rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info */
+ lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */
+ ori r4,r4,_TLF_NAPPING /* so when we take an exception */
+ stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */
+
+ wrteei 1
+
+idle_loop:
+ LOAD_REG_IMMEDIATE(r11, HC_VENDOR_EPAPR | HC_EV_IDLE)
+
+.global epapr_ev_idle_start
+epapr_ev_idle_start:
+ li r3, -1
+ nop
+ nop
+ nop
Can't you just bl into epapr_hypercall_start? You don't even have to save the old lr. because we never return anyways :)
The interrupt will branch to LR, so no, we can't trash it or put it
anywhere else.
-scott
The comment about spelling out "paravirt" wasnn't meant to be restricted
to the kconfig symbol. There are lots of words that begin with "para",
and ePAPR isn't just about virtualization.
Use patch_instruction(), fix the if test, and remove unnecessary
parentheses. Print an error if the if test fails, but return silently
if the property is absent.
Please make asm/epapr_hcalls.h and asm/fsl_hcalls.h work with this as well.
-Scott
From: Scott Wood <hidden> Date: 2012-02-16 17:14:36
On 02/16/2012 03:26 AM, Liu Yu wrote:
If the guest hypervisor node contains "has-idle" property.
Signed-off-by: Liu Yu <redacted>
---
v4:
1. discard the CONFIG_E500 to make code for all powerpc platform
2. code cleanup
Is the TLF_NAPPING stuff supported on all powerpc platforms?
-Scott
From: Alexander Graf <hidden> Date: 2012-02-16 17:18:56
On 16.02.2012, at 17:58, Scott Wood wrote:
On 02/16/2012 04:24 AM, Alexander Graf wrote:
quoted
On 16.02.2012, at 10:26, Liu Yu [off-list ref] wrote:
quoted
+_GLOBAL(epapr_ev_idle)
+epapr_ev_idle:
+ rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info =
*/
quoted
quoted
+ lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */
+ ori r4,r4,_TLF_NAPPING /* so when we take an exception */
+ stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller =
=20
Can't you just bl into epapr_hypercall_start? You don't even have to =
save the old lr. because we never return anyways :)
=20
The interrupt will branch to LR, so no, we can't trash it or put it
anywhere else.
Hrm. But we can clobber ctr, right? So how about we make the generic =
version do a bctr and then just do a small C wrapper that takes lr, =
moves it to ctr and branches to the generic one?
Then we don't have to replicate the hypercall code all over again for =
every invocation.
Alex
From: Scott Wood <hidden> Date: 2012-02-16 17:28:50
On 02/16/2012 11:18 AM, Alexander Graf wrote:
On 16.02.2012, at 17:58, Scott Wood wrote:
quoted
On 02/16/2012 04:24 AM, Alexander Graf wrote:
quoted
On 16.02.2012, at 10:26, Liu Yu [off-list ref] wrote:
quoted
+_GLOBAL(epapr_ev_idle)
+epapr_ev_idle:
+ rlwinm r3,r1,0,0,31-THREAD_SHIFT /* current thread_info */
+ lwz r4,TI_LOCAL_FLAGS(r3) /* set napping bit */
+ ori r4,r4,_TLF_NAPPING /* so when we take an exception */
+ stw r4,TI_LOCAL_FLAGS(r3) /* it will return to our caller */
+
+ wrteei 1
+
+idle_loop:
+ LOAD_REG_IMMEDIATE(r11, HC_VENDOR_EPAPR | HC_EV_IDLE)
+
+.global epapr_ev_idle_start
+epapr_ev_idle_start:
+ li r3, -1
+ nop
+ nop
+ nop
Can't you just bl into epapr_hypercall_start? You don't even have to save the old lr. because we never return anyways :)
The interrupt will branch to LR, so no, we can't trash it or put it
anywhere else.
Hrm. But we can clobber ctr, right? So how about we make the generic version do a bctr and then just do a small C wrapper that takes lr, moves it to ctr and branches to the generic one?
If it's just for this, I would say don't mess with the normal hcall path
for the sake of idle. If using CTR would let us get away without
creating a stack frame in call sites, maybe that would be worthwhile,
depending on what sort of hcalls we end up having.
Then we don't have to replicate the hypercall code all over again for every invocation.
We shouldn't need to do it for every invocation. Idle is special due to
the TLF_NAPPING hack.
-Scott
=20
Can't you just bl into epapr_hypercall_start? You don't even have =
to save the old lr. because we never return anyways :)
quoted
quoted
=20
The interrupt will branch to LR, so no, we can't trash it or put it
anywhere else.
=20
Hrm. But we can clobber ctr, right? So how about we make the generic =
version do a bctr and then just do a small C wrapper that takes lr, =
moves it to ctr and branches to the generic one?
=20
If it's just for this, I would say don't mess with the normal hcall =
path
for the sake of idle. If using CTR would let us get away without
creating a stack frame in call sites, maybe that would be worthwhile,
depending on what sort of hcalls we end up having.
=20
quoted
Then we don't have to replicate the hypercall code all over again for =
every invocation.
=20
We shouldn't need to do it for every invocation. Idle is special due =
to
the TLF_NAPPING hack.
Famous last words. If it's the only case, duplication should be ok. =
Let's hope there are no others.
Alex
From: Scott Wood <hidden> Date: 2012-02-16 17:36:23
On 02/16/2012 11:30 AM, Alexander Graf wrote:
On 16.02.2012, at 18:28, Scott Wood wrote:
quoted
On 02/16/2012 11:18 AM, Alexander Graf wrote:
quoted
Hrm. But we can clobber ctr, right? So how about we make the generic version do a bctr and then just do a small C wrapper that takes lr, moves it to ctr and branches to the generic one?
If it's just for this, I would say don't mess with the normal hcall path
for the sake of idle. If using CTR would let us get away without
creating a stack frame in call sites, maybe that would be worthwhile,
depending on what sort of hcalls we end up having.
quoted
Then we don't have to replicate the hypercall code all over again for every invocation.
We shouldn't need to do it for every invocation. Idle is special due to
the TLF_NAPPING hack.
Famous last words. If it's the only case, duplication should be ok. Let's hope there are no others.
Actually, we can't use CTR -- it's volatile in the ePAPR hypercall ABI.
-Scott
From: Liu Yu-B13201 <hidden> Date: 2012-02-17 02:14:26
-----Original Message-----
From: Alexander Graf [mailto:agraf@suse.de]
Sent: Thursday, February 16, 2012 6:20 PM
To: Liu Yu-B13201
Cc: <redacted>; <redacted>; <linuxppc-
dev@ozlabs.org>; Wood Scott-B07421; Liu Yu-B13201
Subject: Re: [PATCH v4 2/3] KVM: PPC: epapr: Add idle hcall support for
host
=20
=20
=20
On 16.02.2012, at 10:26, Liu Yu [off-list ref] wrote:
=20
quoted
And add a new flag definition in kvm_ppc_pvinfo to indicate whether
host support EV_IDLE hcall.
Signed-off-by: Liu Yu <redacted>
---
v4:
no change
arch/powerpc/include/asm/kvm_para.h | 14 ++++++++++++--
arch/powerpc/kvm/powerpc.c | 8 ++++++++
include/linux/kvm.h | 2 ++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/kvm_para.h
b/arch/powerpc/include/asm/kvm_para.h
index 7b754e7..81a34c9 100644
@@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)/* Second return value is in r4 */break;+caseHC_VENDOR_EPAPR|HC_EV_IDLE:+r=3DHC_EV_SUCCESS;+kvm_vcpu_block(vcpu);+break;default:r=3DHC_EV_UNIMPLEMENTED;break;
@@ -746,6 +750,10 @@ static int kvm_vm_ioctl_get_pvinfo(struct
Why limit it to booke? The less ifdefs our code has, the better :)
The code here tells userspace that kvm support ev_idle.
But I'm not sure if the ev_idle code works for other platforms.
So I think we should keep the ifdef until other platform test the code :)
Thanks,
Yu
From: Alexander Graf <hidden> Date: 2012-02-17 02:20:24
On 17.02.2012, at 03:13, Liu Yu-B13201 wrote:
=20
=20
quoted
-----Original Message-----
From: Alexander Graf [mailto:agraf@suse.de]
Sent: Thursday, February 16, 2012 6:20 PM
To: Liu Yu-B13201
Cc: <redacted>; <redacted>; <linuxppc-
dev@ozlabs.org>; Wood Scott-B07421; Liu Yu-B13201
Subject: Re: [PATCH v4 2/3] KVM: PPC: epapr: Add idle hcall support =
for
quoted
host
=20
=20
=20
On 16.02.2012, at 10:26, Liu Yu [off-list ref] wrote:
=20
quoted
And add a new flag definition in kvm_ppc_pvinfo to indicate whether
host support EV_IDLE hcall.
=20
Signed-off-by: Liu Yu <redacted>
---
v4:
no change
=20
arch/powerpc/include/asm/kvm_para.h | 14 ++++++++++++--
arch/powerpc/kvm/powerpc.c | 8 ++++++++
include/linux/kvm.h | 2 ++
3 files changed, 22 insertions(+), 2 deletions(-)
=20
diff --git a/arch/powerpc/include/asm/kvm_para.h
b/arch/powerpc/include/asm/kvm_para.h
index 7b754e7..81a34c9 100644
@@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
=20
/* Second return value is in r4 */
break;
+ case HC_VENDOR_EPAPR | HC_EV_IDLE:
+ r =3D HC_EV_SUCCESS;
+ kvm_vcpu_block(vcpu);
+ break;
default:
r =3D HC_EV_UNIMPLEMENTED;
break;
@@ -746,6 +750,10 @@ static int kvm_vm_ioctl_get_pvinfo(struct
=20
Why limit it to booke? The less ifdefs our code has, the better :)
=20
The code here tells userspace that kvm support ev_idle.
But I'm not sure if the ev_idle code works for other platforms.
=20
So I think we should keep the ifdef until other platform test the code =
:)
But the implementation is in generic code and is not #ifdef'ed, so a =
guest could still call it just fine. It looks simple enough to work =
without major testing on different platforms, so I'd say just expose it =
and be done :)
Alex
The comment about spelling out "paravirt" wasnn't meant to be restricted
to the kconfig symbol. There are lots of words that begin with "para",
and ePAPR isn't just about virtualization.
What do you mean? Do you suggest that we should name it epapr_paravirt.c?
Yes, and likewise with variables and functions and such (at least
anything that is exposed outside a single file).
-Scott