All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: Andrei Vagin <avagin@gmail.com>
Cc: linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH] selftests/kvm/x86_64: set rax before vmcall
Date: Fri, 29 Jul 2022 19:12:20 +0000	[thread overview]
Message-ID: <YuQxFDupaZuyUMmP@google.com> (raw)
In-Reply-To: <20220628193011.55403-1-avagin@gmail.com>

Hi Andrei,

On Tue, Jun 28, 2022 at 12:30:11PM -0700, Andrei Vagin wrote:
> kvm_hypercall has to place the hypercall number in rax.
> 
> Trace events show that kvm_pv_test doesn't work properly:
>      kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
>      kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
>      kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
> 
> With this change, it starts working as expected:
>      kvm_pv_test-54285: kvm_hypercall: nr 0x5 a0 0x0 a1 0x0 a2 0x0 a3 0x0
>      kvm_pv_test-54285: kvm_hypercall: nr 0xa a0 0x0 a1 0x0 a2 0x0 a3 0x0
>      kvm_pv_test-54285: kvm_hypercall: nr 0xb a0 0x0 a1 0x0 a2 0x0 a3 0x0
> 
> Signed-off-by: Andrei Vagin <avagin@gmail.com>
> ---

Good find, this is a rather silly bug. May I suggest the following for
the changelog to better describe the problem (and blame the original
commit):

KVM: selftests: Actually pass function in %rax when calling hypercall

The KVM hypercall ABI requires the caller to pass the hypercall function
number via %rax. Unfortunately, kvm_hypercall() in selftests falls
short and doesn't set the value of %rax.

In turn, trace events show that kvm_pv_test doesn't work properly:

     kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
     kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
     kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0

Fix the issue by taking the function number as an input operand to %rax.

Fixes: ac4a4d6de22e ("selftests: kvm: test enforcement of paravirtual cpuid features")

--
Thanks,
Oliver

      reply	other threads:[~2022-07-29 19:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 19:30 [PATCH] selftests/kvm/x86_64: set rax before vmcall Andrei Vagin
2022-07-29 19:12 ` Oliver Upton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YuQxFDupaZuyUMmP@google.com \
    --to=oliver.upton@linux.dev \
    --cc=avagin@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.