Re: [PATCH v2 12/45] KVM: PPC: Allocate vcpu struct in common PPC code
On Tue, Jan 21, 2020 at 12:05:00PM +0100, Paolo Bonzini wrote: > On 20/01/20 05:04, Paul Mackerras wrote: > > On Wed, Dec 18, 2019 at 01:54:57PM -0800, Sean Christopherson wrote: > >> Move allocation of all flavors of PPC vCPUs to common PPC code. All > >> variants either allocate 'struct kvm_vcpu' directly, or require that > >> the embedded 'struct kvm_vcpu' member be located at offset 0, i.e. > >> guarantee that the allocation can be directly interpreted as a 'struct > >> kvm_vcpu' object. > >> > >> Remove the message from the build-time assertion regarding placement of > >> the struct, as compatibility with the arch usercopy region is no longer > >> the sole dependent on 'struct kvm_vcpu' being at offset zero. > >> > >> Signed-off-by: Sean Christopherson > > > > This fails to compile for Book E configs: > > > > CC arch/powerpc/kvm/e500.o > > /home/paulus/kernel/kvm/arch/powerpc/kvm/e500.c: In function > > ‘kvmppc_core_vcpu_create_e500’: > > /home/paulus/kernel/kvm/arch/powerpc/kvm/e500.c:464:9: error: return makes > > integer from pointer without a cast [-Werror=int-conversion] > > return vcpu; > > ^ > > cc1: all warnings being treated as errors > > make[3]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:266: > > arch/powerpc/kvm/e500.o] Error 1 > > > > There is a "return vcpu" statement in kvmppc_core_vcpu_create_e500(), > > and another in kvmppc_core_vcpu_create_e500mc(), which both need to be > > changed to "return 0". > > > > (By the way, I do appreciate you fixing the PPC code, even if there > > are some errors.) > > Squashed: Thanks for cleaning up after me, not having to rebase and resend this series made my day :-) > diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c > index 96d9cde3d2e3..f5dd2c7adcd4 100644 > --- a/arch/powerpc/kvm/e500.c > +++ b/arch/powerpc/kvm/e500.c > @@ -461,7 +461,7 @@ static int kvmppc_core_vcpu_create_e500(struct kvm *kvm, > struct kvm_vcpu *vcpu, > goto uninit_tlb; > } > > - return vcpu; > + return 0; > > uninit_tlb: > kvmppc_e500_tlb_uninit(vcpu_e500); > diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c > index aea588f73bf7..7c0d392f667a 100644 > --- a/arch/powerpc/kvm/e500mc.c > +++ b/arch/powerpc/kvm/e500mc.c > @@ -327,7 +327,7 @@ static int kvmppc_core_vcpu_create_e500mc(struct kvm > *kvm, struct kvm_vcpu *vcpu > goto uninit_tlb; > } > > - return vcpu; > + return 0; > > uninit_tlb: > kvmppc_e500_tlb_uninit(vcpu_e500); > > ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v2 12/45] KVM: PPC: Allocate vcpu struct in common PPC code
On 20/01/20 05:04, Paul Mackerras wrote: > On Wed, Dec 18, 2019 at 01:54:57PM -0800, Sean Christopherson wrote: >> Move allocation of all flavors of PPC vCPUs to common PPC code. All >> variants either allocate 'struct kvm_vcpu' directly, or require that >> the embedded 'struct kvm_vcpu' member be located at offset 0, i.e. >> guarantee that the allocation can be directly interpreted as a 'struct >> kvm_vcpu' object. >> >> Remove the message from the build-time assertion regarding placement of >> the struct, as compatibility with the arch usercopy region is no longer >> the sole dependent on 'struct kvm_vcpu' being at offset zero. >> >> Signed-off-by: Sean Christopherson > > This fails to compile for Book E configs: > > CC arch/powerpc/kvm/e500.o > /home/paulus/kernel/kvm/arch/powerpc/kvm/e500.c: In function > ‘kvmppc_core_vcpu_create_e500’: > /home/paulus/kernel/kvm/arch/powerpc/kvm/e500.c:464:9: error: return makes > integer from pointer without a cast [-Werror=int-conversion] > return vcpu; > ^ > cc1: all warnings being treated as errors > make[3]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:266: > arch/powerpc/kvm/e500.o] Error 1 > > There is a "return vcpu" statement in kvmppc_core_vcpu_create_e500(), > and another in kvmppc_core_vcpu_create_e500mc(), which both need to be > changed to "return 0". > > (By the way, I do appreciate you fixing the PPC code, even if there > are some errors.) Squashed: diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c index 96d9cde3d2e3..f5dd2c7adcd4 100644 --- a/arch/powerpc/kvm/e500.c +++ b/arch/powerpc/kvm/e500.c @@ -461,7 +461,7 @@ static int kvmppc_core_vcpu_create_e500(struct kvm *kvm, struct kvm_vcpu *vcpu, goto uninit_tlb; } - return vcpu; + return 0; uninit_tlb: kvmppc_e500_tlb_uninit(vcpu_e500); diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c index aea588f73bf7..7c0d392f667a 100644 --- a/arch/powerpc/kvm/e500mc.c +++ b/arch/powerpc/kvm/e500mc.c @@ -327,7 +327,7 @@ static int kvmppc_core_vcpu_create_e500mc(struct kvm *kvm, struct kvm_vcpu *vcpu goto uninit_tlb; } - return vcpu; + return 0; uninit_tlb: kvmppc_e500_tlb_uninit(vcpu_e500); ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH v2 12/45] KVM: PPC: Allocate vcpu struct in common PPC code
On Wed, Dec 18, 2019 at 01:54:57PM -0800, Sean Christopherson wrote: > Move allocation of all flavors of PPC vCPUs to common PPC code. All > variants either allocate 'struct kvm_vcpu' directly, or require that > the embedded 'struct kvm_vcpu' member be located at offset 0, i.e. > guarantee that the allocation can be directly interpreted as a 'struct > kvm_vcpu' object. > > Remove the message from the build-time assertion regarding placement of > the struct, as compatibility with the arch usercopy region is no longer > the sole dependent on 'struct kvm_vcpu' being at offset zero. > > Signed-off-by: Sean Christopherson This fails to compile for Book E configs: CC arch/powerpc/kvm/e500.o /home/paulus/kernel/kvm/arch/powerpc/kvm/e500.c: In function ‘kvmppc_core_vcpu_create_e500’: /home/paulus/kernel/kvm/arch/powerpc/kvm/e500.c:464:9: error: return makes integer from pointer without a cast [-Werror=int-conversion] return vcpu; ^ cc1: all warnings being treated as errors make[3]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:266: arch/powerpc/kvm/e500.o] Error 1 There is a "return vcpu" statement in kvmppc_core_vcpu_create_e500(), and another in kvmppc_core_vcpu_create_e500mc(), which both need to be changed to "return 0". (By the way, I do appreciate you fixing the PPC code, even if there are some errors.) Paul. ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
[PATCH v2 12/45] KVM: PPC: Allocate vcpu struct in common PPC code
Move allocation of all flavors of PPC vCPUs to common PPC code. All variants either allocate 'struct kvm_vcpu' directly, or require that the embedded 'struct kvm_vcpu' member be located at offset 0, i.e. guarantee that the allocation can be directly interpreted as a 'struct kvm_vcpu' object. Remove the message from the build-time assertion regarding placement of the struct, as compatibility with the arch usercopy region is no longer the sole dependent on 'struct kvm_vcpu' being at offset zero. Signed-off-by: Sean Christopherson --- arch/powerpc/include/asm/kvm_ppc.h | 7 --- arch/powerpc/kvm/book3s.c | 5 +++-- arch/powerpc/kvm/book3s_hv.c | 20 +--- arch/powerpc/kvm/book3s_pr.c | 18 +- arch/powerpc/kvm/booke.c | 5 +++-- arch/powerpc/kvm/e500.c| 24 ++-- arch/powerpc/kvm/e500mc.c | 22 +- arch/powerpc/kvm/powerpc.c | 23 ++- 8 files changed, 49 insertions(+), 75 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 3d2f871241a8..8f77ca5ace6f 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -119,8 +119,8 @@ extern int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, enum xlate_instdata xlid, enum xlate_readwrite xlrw, struct kvmppc_pte *pte); -extern struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, -unsigned int id); +extern int kvmppc_core_vcpu_create(struct kvm *kvm, struct kvm_vcpu *vcpu, + unsigned int id); extern void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu); extern int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu); extern int kvmppc_core_check_processor_compat(void); @@ -274,7 +274,8 @@ struct kvmppc_ops { void (*inject_interrupt)(struct kvm_vcpu *vcpu, int vec, u64 srr1_flags); void (*set_msr)(struct kvm_vcpu *vcpu, u64 msr); int (*vcpu_run)(struct kvm_run *run, struct kvm_vcpu *vcpu); - struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned int id); + int (*vcpu_create)(struct kvm *kvm, struct kvm_vcpu *vcpu, + unsigned int id); void (*vcpu_free)(struct kvm_vcpu *vcpu); int (*check_requests)(struct kvm_vcpu *vcpu); int (*get_dirty_log)(struct kvm *kvm, struct kvm_dirty_log *log); diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 58a59ee998e2..13385656b90d 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -789,9 +789,10 @@ void kvmppc_decrementer_func(struct kvm_vcpu *vcpu) kvm_vcpu_kick(vcpu); } -struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id) +int kvmppc_core_vcpu_create(struct kvm *kvm, struct kvm_vcpu *vcpu, + unsigned int id) { - return kvm->arch.kvm_ops->vcpu_create(kvm, id); + return kvm->arch.kvm_ops->vcpu_create(kvm, vcpu, id); } void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index d07d2f5273e5..3fb41fe24f58 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2271,22 +2271,16 @@ static void debugfs_vcpu_init(struct kvm_vcpu *vcpu, unsigned int id) } #endif /* CONFIG_KVM_BOOK3S_HV_EXIT_TIMING */ -static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, - unsigned int id) +static int kvmppc_core_vcpu_create_hv(struct kvm *kvm, struct kvm_vcpu *vcpu, + unsigned int id) { - struct kvm_vcpu *vcpu; int err; int core; struct kvmppc_vcore *vcore; - err = -ENOMEM; - vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL); - if (!vcpu) - goto out; - err = kvm_vcpu_init(vcpu, kvm, id); if (err) - goto free_vcpu; + return err; vcpu->arch.shared = >arch.shregs; #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE @@ -2383,14 +2377,11 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, debugfs_vcpu_init(vcpu, id); - return vcpu; + return 0; uninit_vcpu: kvm_vcpu_uninit(vcpu); -free_vcpu: - kmem_cache_free(kvm_vcpu_cache, vcpu); -out: - return ERR_PTR(err); + return err; } static int kvmhv_set_smt_mode(struct kvm *kvm, unsigned long smt_mode, @@ -2445,7 +2436,6 @@ static void kvmppc_core_vcpu_free_hv(struct kvm_vcpu *vcpu) unpin_vpa(vcpu->kvm, >arch.vpa); spin_unlock(>arch.vpa_update_lock); kvm_vcpu_uninit(vcpu); - kmem_cache_free(kvm_vcpu_cache, vcpu); } static int kvmppc_core_check_requests_hv(struct kvm_vcpu *vcpu) diff --git a/arch/powerpc/kvm/book3s_pr.c