Re: [PATCH 1/5] KVM: Pass kvm_init()'s opaque param to additional arch funcs

From: Cornelia Huck
Date: Fri Jan 31 2020 - 07:06:44 EST


On Wed, 29 Jan 2020 16:10:19 -0800
Sean Christopherson <sean.j.christopherson@xxxxxxxxx> 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 <sean.j.christopherson@xxxxxxxxx>
> ---
> 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 <cohuck@xxxxxxxxxx>
Tested-by: Cornelia Huck <cohuck@xxxxxxxxxx> #s390