Message ID | 1331844737-30869-4-git-send-email-stuart.yoder@freescale.com |
---|---|
State | New, archived |
Headers | show |
On 15.03.2012, at 21:52, Stuart Yoder wrote: > From: Liu Yu-B13201 <Yu.Liu@freescale.com> > > And add a new flag definition in kvm_ppc_pvinfo to indicate > whether the host supports the EV_IDLE hcall. > > Signed-off-by: Liu Yu <yu.liu@freescale.com> > [stuart.yoder@freescale.com: cleanup,fixes for conditions allowing idle] > Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com> > --- > -v10: > -ePAPR definitions now addressed in separate patch > -move clearing of KVM_REQ_UNHALT after kvm_vcpu_block() call > > arch/powerpc/include/asm/Kbuild | 1 + > arch/powerpc/kvm/powerpc.c | 20 +++++++++++++++++--- > include/linux/kvm.h | 2 ++ > 3 files changed, 20 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild > index 7e313f1..13d6b7b 100644 > --- a/arch/powerpc/include/asm/Kbuild > +++ b/arch/powerpc/include/asm/Kbuild > @@ -34,5 +34,6 @@ header-y += termios.h > header-y += types.h > header-y += ucontext.h > header-y += unistd.h > +header-y += epapr_hcalls.h > > generic-y += rwsem.h > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c > index d738626..7c4e5cc 100644 > --- a/arch/powerpc/kvm/powerpc.c > +++ b/arch/powerpc/kvm/powerpc.c > @@ -38,8 +38,7 @@ > > int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) > { > - return !(v->arch.shared->msr & MSR_WE) || > - !!(v->arch.pending_exceptions) || > + return !!(v->arch.pending_exceptions) || Are you sure this doesn't break book3s or e500v2? > v->requests; > } > > @@ -86,6 +85,11 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) > > /* Second return value is in r4 */ > break; > + case _EV_HCALL_TOKEN(EV_EPAPR_VENDOR_ID, EV_IDLE): > + r = 0; /* success */ > + kvm_vcpu_block(vcpu); > + clear_bit(KVM_REQ_UNHALT, &vcpu->requests); > + break; > default: > r = EV_UNIMPLEMENTED; > break; > @@ -732,9 +736,16 @@ int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf) > > static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) > { > + u32 inst_nop = 0x60000000; > +#ifdef CONFIG_KVM_BOOKE_HV > + u32 inst_sc1 = 0x44000022; > + pvinfo->hcall[0] = inst_sc1; > + pvinfo->hcall[1] = inst_nop; > + pvinfo->hcall[2] = inst_nop; > + pvinfo->hcall[3] = inst_nop; > +#else This hunk is unrelated to the rest of the patch. Please factor it out into its own patch :). > u32 inst_lis = 0x3c000000; > u32 inst_ori = 0x60000000; > - u32 inst_nop = 0x60000000; > u32 inst_sc = 0x44000002; > u32 inst_imm_mask = 0xffff; > > @@ -751,6 +762,9 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) > pvinfo->hcall[1] = inst_ori | (KVM_SC_MAGIC_R0 & inst_imm_mask); > pvinfo->hcall[2] = inst_sc; > pvinfo->hcall[3] = inst_nop; > +#endif > + > + pvinfo->flags = KVM_PPC_PVINFO_FLAGS_EV_IDLE; > > return 0; > } > diff --git a/include/linux/kvm.h b/include/linux/kvm.h > index 7a9dd4b..640ec5a 100644 > --- a/include/linux/kvm.h > +++ b/include/linux/kvm.h > @@ -449,6 +449,8 @@ struct kvm_ppc_pvinfo { > __u8 pad[108]; > }; > > +#define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) This needs an update to the documentation in Documentation/virtual/kvm/api.txt. Please also update Documentation/virtual/kvm/ppc-pv.txt with the new hypercall. Alex -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 05/08/2012 05:40 AM, Alexander Graf wrote: > > On 15.03.2012, at 21:52, Stuart Yoder wrote: > >> From: Liu Yu-B13201 <Yu.Liu@freescale.com> >> >> And add a new flag definition in kvm_ppc_pvinfo to indicate >> whether the host supports the EV_IDLE hcall. >> >> Signed-off-by: Liu Yu <yu.liu@freescale.com> >> [stuart.yoder@freescale.com: cleanup,fixes for conditions allowing idle] >> Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com> >> --- >> -v10: >> -ePAPR definitions now addressed in separate patch >> -move clearing of KVM_REQ_UNHALT after kvm_vcpu_block() call >> >> arch/powerpc/include/asm/Kbuild | 1 + >> arch/powerpc/kvm/powerpc.c | 20 +++++++++++++++++--- >> include/linux/kvm.h | 2 ++ >> 3 files changed, 20 insertions(+), 3 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild >> index 7e313f1..13d6b7b 100644 >> --- a/arch/powerpc/include/asm/Kbuild >> +++ b/arch/powerpc/include/asm/Kbuild >> @@ -34,5 +34,6 @@ header-y += termios.h >> header-y += types.h >> header-y += ucontext.h >> header-y += unistd.h >> +header-y += epapr_hcalls.h >> >> generic-y += rwsem.h >> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c >> index d738626..7c4e5cc 100644 >> --- a/arch/powerpc/kvm/powerpc.c >> +++ b/arch/powerpc/kvm/powerpc.c >> @@ -38,8 +38,7 @@ >> >> int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) >> { >> - return !(v->arch.shared->msr & MSR_WE) || >> - !!(v->arch.pending_exceptions) || >> + return !!(v->arch.pending_exceptions) || > > Are you sure this doesn't break book3s or e500v2? It's only used inside kvm_vcpu_block(). We only call kvm_vcpu_block() if there's a request to go idle (MSR[WE], hcall, etc), and MSR[WE] can't be cleared except via exception or userspace. Exceptions are already checked for in runnable(), and an exit to userspace would exit kvm_vcpu_block(). -Scott -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild index 7e313f1..13d6b7b 100644 --- a/arch/powerpc/include/asm/Kbuild +++ b/arch/powerpc/include/asm/Kbuild @@ -34,5 +34,6 @@ header-y += termios.h header-y += types.h header-y += ucontext.h header-y += unistd.h +header-y += epapr_hcalls.h generic-y += rwsem.h diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index d738626..7c4e5cc 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -38,8 +38,7 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) { - return !(v->arch.shared->msr & MSR_WE) || - !!(v->arch.pending_exceptions) || + return !!(v->arch.pending_exceptions) || v->requests; } @@ -86,6 +85,11 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) /* Second return value is in r4 */ break; + case _EV_HCALL_TOKEN(EV_EPAPR_VENDOR_ID, EV_IDLE): + r = 0; /* success */ + kvm_vcpu_block(vcpu); + clear_bit(KVM_REQ_UNHALT, &vcpu->requests); + break; default: r = EV_UNIMPLEMENTED; break; @@ -732,9 +736,16 @@ int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf) static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) { + u32 inst_nop = 0x60000000; +#ifdef CONFIG_KVM_BOOKE_HV + u32 inst_sc1 = 0x44000022; + pvinfo->hcall[0] = inst_sc1; + pvinfo->hcall[1] = inst_nop; + pvinfo->hcall[2] = inst_nop; + pvinfo->hcall[3] = inst_nop; +#else u32 inst_lis = 0x3c000000; u32 inst_ori = 0x60000000; - u32 inst_nop = 0x60000000; u32 inst_sc = 0x44000002; u32 inst_imm_mask = 0xffff; @@ -751,6 +762,9 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) pvinfo->hcall[1] = inst_ori | (KVM_SC_MAGIC_R0 & inst_imm_mask); pvinfo->hcall[2] = inst_sc; pvinfo->hcall[3] = inst_nop; +#endif + + pvinfo->flags = KVM_PPC_PVINFO_FLAGS_EV_IDLE; return 0; } diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 7a9dd4b..640ec5a 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -449,6 +449,8 @@ struct kvm_ppc_pvinfo { __u8 pad[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 */