Re: [RFC V2 PATCH 1/8] selftests: kvm: Fix inline assembly for hypercall

Shuah Khan
2022-05-12T17:31:50Z

On 5/10/22 6:08 PM, Vishal Annapurve wrote:
> Fix inline assembly for hypercall to explicitly set
> eax with hypercall number to allow the implementation
> to work even in cases where compiler would inline the
> function.
>

Please explain what happens without this change as well.

> Signed-off-by: Vishal Annapurve <vannapurve@google.com>
> ---
> tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> index 9f000dfb5594..4d88e1a553bf 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> @@ -1461,7 +1461,7 @@ uint64_t kvm_hypercall(uint64_t nr, uint64_t a0, uint64_t a1, uint64_t a2,
>
> asm volatile("vmcall"
> : "=a"(r)
> - : "b"(a0), "c"(a1), "d"(a2), "S"(a3));
> + : "a"(nr), "b"(a0), "c"(a1), "d"(a2), "S"(a3));
> return r;
> }
>
>

With the above change to commit log:

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah