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

Christian Borntraeger
2021-07-14T10:03:29Z

On 14.07.21 11:50, Heiko Carstens wrote:
> On Wed, Jul 14, 2021 at 11:38:43AM +0200, Claudio Imbrenda wrote:
>> 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
>
> I see only two ways to get rid them, both are suboptimal, therefore I
> decided to keep them at very few places; one of them this one.
>
> Alternatively to this approach it would be possible to:
>
> a) write the function entirely in assembler (instead of inlining it).

I would like to keep this as is, unless we know that this could break.
Maybe we should add something like nokasan or whatever?

> b) pass a structure with all parameters to the inline assembly and
> clobber a large amount of registers, which _might_ even lead to
> compile errors since the compiler might run out of registers when
> allocating registers for the inline asm.
>
> Given that hypercall is slow anyway a) might be an option. But that's
> up to you guys. Otherwise I would consider this the "final" solution
> until we get compiler support which allows for something better.