Re: [PATCH 5/5] KVM: x86: Set kvm_x86_ops only after ->hardware_setup() completes
On Thu, Jan 30, 2020 at 06:44:09AM +0100, Paolo Bonzini wrote: > On 30/01/20 01:10, Sean Christopherson wrote: > > Set kvm_x86_ops with the vendor's ops only after ->hardware_setup() > > completes to "prevent" using kvm_x86_ops before they are ready, i.e. to > > generate a null pointer fault instead of silently consuming unconfigured > > state. > > What about even copying kvm_x86_ops by value, so that they can be > accessed with "kvm_x86_ops.callback()" and save one memory access? Oooh, I like that idea. And {svm,vmx}_x86_ops could be marked __initdata to save a few bytes and force all the runtime stuff through kvm_x86_ops. ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 1/5] KVM: Pass kvm_init()'s opaque param to additional arch funcs
On Wed, 29 Jan 2020 16:10:19 -0800 Sean Christopherson wrote: > Pass @opaque to kvm_arch_hardware_setup() and > kvm_arch_check_processor_compat() to allow architecture specific code to > reference @opaque without having to stash it away in a temporary global > variable. This will enable x86 to separate its vendor specific callback > ops, which are passed via @opaque, into "init" and "runtime" ops without > having to stash away the "init" ops. > > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > arch/mips/kvm/mips.c | 4 ++-- > arch/powerpc/kvm/powerpc.c | 4 ++-- > arch/s390/kvm/kvm-s390.c | 4 ++-- > arch/x86/kvm/x86.c | 4 ++-- > include/linux/kvm_host.h | 4 ++-- > virt/kvm/arm/arm.c | 4 ++-- > virt/kvm/kvm_main.c| 18 ++ > 7 files changed, 26 insertions(+), 16 deletions(-) > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index eb3709d55139..5ad252defa54 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -4345,14 +4345,22 @@ struct kvm_vcpu * __percpu > *kvm_get_running_vcpus(void) > return &kvm_running_vcpu; > } > > -static void check_processor_compat(void *rtn) > +struct kvm_cpu_compat_check { > + void *opaque; > + int *ret; > +}; > + > +static void check_processor_compat(void *data) > { > - *(int *)rtn = kvm_arch_check_processor_compat(); > + struct kvm_cpu_compat_check *c = data; > + > + *c->ret = kvm_arch_check_processor_compat(c->opaque); > } This function also looks better now :) Reviewed-by: Cornelia Huck Tested-by: Cornelia Huck #s390 ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm