Re: [PATCH] KVM: s390: generate kvm hypercall functions

Claudio Imbrenda
2021-07-14T09:38:52Z

On Tue, 13 Jul 2021 16:57:13 +0200
Heiko Carstens <hca@linux.ibm.com> wrote:

[snip]

> +#define HYPERCALL_ARGS_0
> +#define HYPERCALL_ARGS_1 , arg1
> +#define HYPERCALL_ARGS_2 HYPERCALL_ARGS_1, arg2
> +#define HYPERCALL_ARGS_3 HYPERCALL_ARGS_2, arg3
> +#define HYPERCALL_ARGS_4 HYPERCALL_ARGS_3, arg4
> +#define HYPERCALL_ARGS_5 HYPERCALL_ARGS_4, arg5
> +#define HYPERCALL_ARGS_6 HYPERCALL_ARGS_5, arg6
> +
> +#define GENERATE_KVM_HYPERCALL_FUNC(args)
> \ +static inline
> \ +long __kvm_hypercall##args(unsigned long
> nr HYPERCALL_PARM_##args) \ +{
> \
> + register unsigned long __nr asm("1") = nr;
> \
> + register long __rc asm("2");
> \

didn't we want to get rid of asm register allocations?

this would have been a nice time to do such a cleanup

> + HYPERCALL_REGS_##args;
> \
> +
> \
> + asm volatile (
> \
> + " diag 2,4,0x500\n"
> \
> + : "=d" (__rc)
> \
> + : "d" (__nr) HYPERCALL_FMT_##args
> \
> + : "memory", "cc");
> \
> + return __rc;
> \ +}
> \
> +
> \ +static inline
> \ +long kvm_hypercall##args(unsigned long nr
> HYPERCALL_PARM_##args) \ +{
> \
> + diag_stat_inc(DIAG_STAT_X500);
> \
> + return __kvm_hypercall##args(nr
> HYPERCALL_ARGS_##args); \ +}
> +
> +GENERATE_KVM_HYPERCALL_FUNC(0)
> +GENERATE_KVM_HYPERCALL_FUNC(1)
> +GENERATE_KVM_HYPERCALL_FUNC(2)
> +GENERATE_KVM_HYPERCALL_FUNC(3)
> +GENERATE_KVM_HYPERCALL_FUNC(4)
> +GENERATE_KVM_HYPERCALL_FUNC(5)
> +GENERATE_KVM_HYPERCALL_FUNC(6)
>
> /* kvm on s390 is always paravirtualization enabled */
> static inline int kvm_para_available(void)