From: Auger Eric <eric.auger@redhat.com>
To: Ricardo Koller <ricarkol@google.com>,
kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: pbonzini@redhat.com, maz@kernel.org, drjones@redhat.com,
alexandru.elisei@arm.com
Subject: Re: [PATCH v3 3/5] KVM: selftests: Move GUEST_ASSERT_EQ to utils header
Date: Sun, 16 May 2021 11:50:52 +0200 [thread overview]
Message-ID: <b8e63f39-9545-4a43-362f-75e0489ae715@redhat.com> (raw)
In-Reply-To: <20210513002802.3671838-4-ricarkol@google.com>
Hi Ricardo,
On 5/13/21 2:28 AM, Ricardo Koller wrote:
> Move GUEST_ASSERT_EQ to a common header, kvm_util.h, for other
> architectures and tests to use. Also modify __GUEST_ASSERT so it can be
> reused to implement GUEST_ASSERT_EQ.
>
> Signed-off-by: Ricardo Koller <ricarkol@google.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> .../testing/selftests/kvm/include/kvm_util.h | 22 ++++++++++---------
> .../selftests/kvm/x86_64/tsc_msrs_test.c | 9 --------
> 2 files changed, 12 insertions(+), 19 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
> index 7880929ea548..fb2b8964f2ca 100644
> --- a/tools/testing/selftests/kvm/include/kvm_util.h
> +++ b/tools/testing/selftests/kvm/include/kvm_util.h
> @@ -366,26 +366,28 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc);
> ucall(UCALL_SYNC, 6, "hello", stage, arg1, arg2, arg3, arg4)
> #define GUEST_SYNC(stage) ucall(UCALL_SYNC, 2, "hello", stage)
> #define GUEST_DONE() ucall(UCALL_DONE, 0)
> -#define __GUEST_ASSERT(_condition, _nargs, _args...) do { \
> - if (!(_condition)) \
> - ucall(UCALL_ABORT, 2 + _nargs, \
> - "Failed guest assert: " \
> - #_condition, __LINE__, _args); \
> +#define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) do { \
> + if (!(_condition)) \
> + ucall(UCALL_ABORT, 2 + _nargs, \
> + "Failed guest assert: " \
> + _condstr, __LINE__, _args); \
> } while (0)
>
> #define GUEST_ASSERT(_condition) \
> - __GUEST_ASSERT((_condition), 0, 0)
> + __GUEST_ASSERT(_condition, #_condition, 0, 0)
>
> #define GUEST_ASSERT_1(_condition, arg1) \
> - __GUEST_ASSERT((_condition), 1, (arg1))
> + __GUEST_ASSERT(_condition, #_condition, 1, (arg1))
>
> #define GUEST_ASSERT_2(_condition, arg1, arg2) \
> - __GUEST_ASSERT((_condition), 2, (arg1), (arg2))
> + __GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2))
>
> #define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \
> - __GUEST_ASSERT((_condition), 3, (arg1), (arg2), (arg3))
> + __GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3))
>
> #define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \
> - __GUEST_ASSERT((_condition), 4, (arg1), (arg2), (arg3), (arg4))
> + __GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4))
> +
> +#define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b)
>
> #endif /* SELFTEST_KVM_UTIL_H */
> diff --git a/tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c b/tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
> index e357d8e222d4..5a6a662f2e59 100644
> --- a/tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
> @@ -18,15 +18,6 @@
> #define rounded_rdmsr(x) ROUND(rdmsr(x))
> #define rounded_host_rdmsr(x) ROUND(vcpu_get_msr(vm, 0, x))
>
> -#define GUEST_ASSERT_EQ(a, b) do { \
> - __typeof(a) _a = (a); \
> - __typeof(b) _b = (b); \
> - if (_a != _b) \
> - ucall(UCALL_ABORT, 4, \
> - "Failed guest assert: " \
> - #a " == " #b, __LINE__, _a, _b); \
> - } while(0)
> -
> static void guest_code(void)
> {
> u64 val = 0;
>
next prev parent reply other threads:[~2021-05-16 9:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-13 0:27 [PATCH v3 0/5] KVM: selftests: arm64 exception handling and debug test Ricardo Koller
2021-05-13 0:27 ` [PATCH v3 1/5] KVM: selftests: Rename vm_handle_exception Ricardo Koller
2021-05-13 0:27 ` [PATCH v3 2/5] KVM: selftests: Introduce UCALL_UNHANDLED for unhandled vector reporting Ricardo Koller
2021-05-13 0:28 ` [PATCH v3 3/5] KVM: selftests: Move GUEST_ASSERT_EQ to utils header Ricardo Koller
2021-05-13 7:35 ` Andrew Jones
2021-05-16 9:50 ` Auger Eric [this message]
2021-05-13 0:28 ` [PATCH v3 4/5] KVM: selftests: Add exception handling support for aarch64 Ricardo Koller
2021-05-13 8:05 ` Andrew Jones
2021-05-13 0:28 ` [PATCH v3 5/5] KVM: selftests: Add aarch64/debug-exceptions test Ricardo Koller
2021-05-13 6:37 ` [PATCH v3 0/5] KVM: selftests: arm64 exception handling and debug test Auger Eric
2021-05-14 18:31 ` Ricardo Koller
2021-06-01 9:34 ` Marc Zyngier
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=b8e63f39-9545-4a43-362f-75e0489ae715@redhat.com \
--to=eric.auger@redhat.com \
--cc=alexandru.elisei@arm.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=pbonzini@redhat.com \
--cc=ricarkol@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).