From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Andrei Vagin <avagin@google.com>, Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Andrei Vagin <avagin@google.com>,
Sean Christopherson <seanjc@google.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jianfeng Tan <henry.tjf@antfin.com>,
Adin Scannell <ascannell@google.com>,
Konstantin Bogomolov <bogomolov@google.com>,
Etienne Perot <eperot@google.com>
Subject: Re: [PATCH 4/5] selftests/kvm/x86_64: set rax before vmcall
Date: Mon, 01 Aug 2022 13:32:24 +0200 [thread overview]
Message-ID: <87y1w819o7.fsf@redhat.com> (raw)
In-Reply-To: <20220722230241.1944655-5-avagin@google.com>
Andrei Vagin <avagin@google.com> writes:
> 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
>
Fixes: ac4a4d6de22e ("selftests: kvm: test enforcement of paravirtual cpuid features")
> Signed-off-by: Andrei Vagin <avagin@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 ead7011ee8f6..5d85e1c021da 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> @@ -1422,7 +1422,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));
Wouldn't '"+a"(r)' instead of '"=a"(r)' suffice (assuming we also assing
'r' to 'nr' in the beginning, something like
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
index ead7011ee8f6..fdd6554b94a1 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
@@ -1418,10 +1418,10 @@ bool set_cpuid(struct kvm_cpuid2 *cpuid,
uint64_t kvm_hypercall(uint64_t nr, uint64_t a0, uint64_t a1, uint64_t a2,
uint64_t a3)
{
- uint64_t r;
+ uint64_t r = nr;
asm volatile("vmcall"
- : "=a"(r)
+ : "+a"(r)
: "b"(a0), "c"(a1), "d"(a2), "S"(a3));
return r;
}
--
Vitaly
next prev parent reply other threads:[~2022-08-01 11:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 23:02 [PATCH 0/5] KVM/x86: add a new hypercall to execute host system Andrei Vagin
2022-07-22 23:02 ` [PATCH 1/5] kernel: add a new helper to execute system calls from kernel code Andrei Vagin
2022-07-22 23:02 ` [PATCH 2/5] kvm/x86: add controls to enable/disable paravirtualized system calls Andrei Vagin
2022-07-22 23:02 ` [PATCH 3/5] KVM/x86: add a new hypercall to execute host " Andrei Vagin
2022-07-22 23:02 ` [PATCH 4/5] selftests/kvm/x86_64: set rax before vmcall Andrei Vagin
2022-08-01 11:32 ` Vitaly Kuznetsov [this message]
2022-08-01 12:43 ` Paolo Bonzini
2022-07-22 23:02 ` [PATCH 5/5] selftests/kvm/x86_64: add tests for KVM_HC_HOST_SYSCALL Andrei Vagin
2022-07-22 23:41 ` [PATCH 0/5] KVM/x86: add a new hypercall to execute host system Sean Christopherson
2022-07-26 8:33 ` Andrei Vagin
2022-07-26 10:27 ` Paolo Bonzini
2022-07-27 6:44 ` Andrei Vagin
2022-07-26 15:10 ` Sean Christopherson
2022-07-26 22:10 ` Thomas Gleixner
2022-07-27 1:03 ` Andrei Vagin
2022-08-22 20:26 ` Andrei Vagin
2022-07-27 0:25 ` Andrei Vagin
2022-07-26 21:27 ` Thomas Gleixner
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=87y1w819o7.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=ascannell@google.com \
--cc=avagin@google.com \
--cc=bogomolov@google.com \
--cc=eperot@google.com \
--cc=henry.tjf@antfin.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=wanpengli@tencent.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.