Message ID | 1329384365-4028-2-git-send-email-yu.liu@freescale.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
On 16.02.2012, at 10:26, Liu Yu <yu.liu@freescale.com> wrote: > And add a new flag definition in kvm_ppc_pvinfo to indicate > whether host support EV_IDLE hcall. > > Signed-off-by: Liu Yu <yu.liu@freescale.com> > --- > 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 > --- a/arch/powerpc/include/asm/kvm_para.h > +++ b/arch/powerpc/include/asm/kvm_para.h > @@ -75,9 +75,19 @@ struct kvm_vcpu_arch_shared { > }; > > #define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */ > -#define HC_VENDOR_KVM (42 << 16) > + > +#include <asm/epapr_hcalls.h> > + > +/* ePAPR Hypercall Vendor ID */ > +#define HC_VENDOR_EPAPR (EV_EPAPR_VENDOR_ID << 16) > +#define HC_VENDOR_KVM (EV_KVM_VENDOR_ID << 16) > + > +/* ePAPR Hypercall Token */ > +#define HC_EV_IDLE EV_IDLE > + > +/* ePAPR Hypercall Return Codes */ > #define HC_EV_SUCCESS 0 > -#define HC_EV_UNIMPLEMENTED 12 > +#define HC_EV_UNIMPLEMENTED EV_UNIMPLEMENTED > > #define KVM_FEATURE_MAGIC_PAGE 1 > > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c > index 0e21d15..03ebd5d 100644 > --- a/arch/powerpc/kvm/powerpc.c > +++ b/arch/powerpc/kvm/powerpc.c > @@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) > > /* Second return value is in r4 */ > break; > + case HC_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 Why limit it to booke? The less ifdefs our code has, the better :) Alex > + pvinfo->flags |= KVM_PPC_PVINFO_FLAGS_EV_IDLE; > +#endif > + > return 0; > } > > diff --git a/include/linux/kvm.h b/include/linux/kvm.h > index acbe429..6b2c70e 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 */ > -- > 1.7.0.4 > > > -- > 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
> -----Original Message----- > From: Alexander Graf [mailto:agraf@suse.de] > Sent: Thursday, February 16, 2012 6:20 PM > To: Liu Yu-B13201 > Cc: <kvm-ppc@vger.kernel.org>; <kvm@vger.kernel.org>; <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 > > > > On 16.02.2012, at 10:26, Liu Yu <yu.liu@freescale.com> wrote: > > > And add a new flag definition in kvm_ppc_pvinfo to indicate whether > > host support EV_IDLE hcall. > > > > Signed-off-by: Liu Yu <yu.liu@freescale.com> > > --- > > 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 > > --- a/arch/powerpc/include/asm/kvm_para.h > > +++ b/arch/powerpc/include/asm/kvm_para.h > > @@ -75,9 +75,19 @@ struct kvm_vcpu_arch_shared { }; > > > > #define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */ > > -#define HC_VENDOR_KVM (42 << 16) > > + > > +#include <asm/epapr_hcalls.h> > > + > > +/* ePAPR Hypercall Vendor ID */ > > +#define HC_VENDOR_EPAPR (EV_EPAPR_VENDOR_ID << 16) > > +#define HC_VENDOR_KVM (EV_KVM_VENDOR_ID << 16) > > + > > +/* ePAPR Hypercall Token */ > > +#define HC_EV_IDLE EV_IDLE > > + > > +/* ePAPR Hypercall Return Codes */ > > #define HC_EV_SUCCESS 0 > > -#define HC_EV_UNIMPLEMENTED 12 > > +#define HC_EV_UNIMPLEMENTED EV_UNIMPLEMENTED > > > > #define KVM_FEATURE_MAGIC_PAGE 1 > > > > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c > > index 0e21d15..03ebd5d 100644 > > --- a/arch/powerpc/kvm/powerpc.c > > +++ b/arch/powerpc/kvm/powerpc.c > > @@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) > > > > /* Second return value is in r4 */ > > break; > > + case HC_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 > > + > > return 0; > > }> > > 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
On 17.02.2012, at 03:13, Liu Yu-B13201 wrote: > > >> -----Original Message----- >> From: Alexander Graf [mailto:agraf@suse.de] >> Sent: Thursday, February 16, 2012 6:20 PM >> To: Liu Yu-B13201 >> Cc: <kvm-ppc@vger.kernel.org>; <kvm@vger.kernel.org>; <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 >> >> >> >> On 16.02.2012, at 10:26, Liu Yu <yu.liu@freescale.com> wrote: >> >>> And add a new flag definition in kvm_ppc_pvinfo to indicate whether >>> host support EV_IDLE hcall. >>> >>> Signed-off-by: Liu Yu <yu.liu@freescale.com> >>> --- >>> 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 >>> --- a/arch/powerpc/include/asm/kvm_para.h >>> +++ b/arch/powerpc/include/asm/kvm_para.h >>> @@ -75,9 +75,19 @@ struct kvm_vcpu_arch_shared { }; >>> >>> #define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */ >>> -#define HC_VENDOR_KVM (42 << 16) >>> + >>> +#include <asm/epapr_hcalls.h> >>> + >>> +/* ePAPR Hypercall Vendor ID */ >>> +#define HC_VENDOR_EPAPR (EV_EPAPR_VENDOR_ID << 16) >>> +#define HC_VENDOR_KVM (EV_KVM_VENDOR_ID << 16) >>> + >>> +/* ePAPR Hypercall Token */ >>> +#define HC_EV_IDLE EV_IDLE >>> + >>> +/* ePAPR Hypercall Return Codes */ >>> #define HC_EV_SUCCESS 0 >>> -#define HC_EV_UNIMPLEMENTED 12 >>> +#define HC_EV_UNIMPLEMENTED EV_UNIMPLEMENTED >>> >>> #define KVM_FEATURE_MAGIC_PAGE 1 >>> >>> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c >>> index 0e21d15..03ebd5d 100644 >>> --- a/arch/powerpc/kvm/powerpc.c >>> +++ b/arch/powerpc/kvm/powerpc.c >>> @@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) >>> >>> /* Second return value is in r4 */ >>> break; >>> + case HC_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 >>> + >>> return 0; >>> }> >> >> 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 :) 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
diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h index 7b754e7..81a34c9 100644 --- a/arch/powerpc/include/asm/kvm_para.h +++ b/arch/powerpc/include/asm/kvm_para.h @@ -75,9 +75,19 @@ struct kvm_vcpu_arch_shared { }; #define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */ -#define HC_VENDOR_KVM (42 << 16) + +#include <asm/epapr_hcalls.h> + +/* ePAPR Hypercall Vendor ID */ +#define HC_VENDOR_EPAPR (EV_EPAPR_VENDOR_ID << 16) +#define HC_VENDOR_KVM (EV_KVM_VENDOR_ID << 16) + +/* ePAPR Hypercall Token */ +#define HC_EV_IDLE EV_IDLE + +/* ePAPR Hypercall Return Codes */ #define HC_EV_SUCCESS 0 -#define HC_EV_UNIMPLEMENTED 12 +#define HC_EV_UNIMPLEMENTED EV_UNIMPLEMENTED #define KVM_FEATURE_MAGIC_PAGE 1 diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 0e21d15..03ebd5d 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) /* Second return value is in r4 */ break; + case HC_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 + return 0; } diff --git a/include/linux/kvm.h b/include/linux/kvm.h index acbe429..6b2c70e 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 */
And add a new flag definition in kvm_ppc_pvinfo to indicate whether host support EV_IDLE hcall. Signed-off-by: Liu Yu <yu.liu@freescale.com> --- 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(-)