From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Shuah Khan" <shuah@kernel.org>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Fix a condition in test_hv_cpuid()
Date: Tue, 14 May 2019 13:22:56 +0000 [thread overview]
Message-ID: <87lfz9npan.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20190514103451.GA1694@mwanda>
Dan Carpenter <dan.carpenter@oracle.com> writes:
> The code is trying to check that all the padding is zeroed out and it
> does this:
>
> entry->padding[0] = entry->padding[1] = entry->padding[2] = 0
>
> Assume everything is zeroed correctly, then the first comparison is
> true, the next comparison is false and false is equal to zero so the
> overall condition is true. This bug doesn't affect run time very
> badly, but the code should instead just check that all three paddings
> are zero individually.
>
> Also the error message was copy and pasted from an earlier error and it
> wasn't correct.
>
> Fixes: 7edcb7343327 ("KVM: selftests: Add hyperv_cpuid test")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> index 9a21e912097c..63b9fc3fdfbe 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> @@ -58,9 +58,8 @@ static void test_hv_cpuid(struct kvm_cpuid2
> *hv_cpuid_entries,
we also seem to check for 'entry->index = 0' twice here.
> TEST_ASSERT(entry->flags = 0,
> ".flags field should be zero");
>
> - TEST_ASSERT(entry->padding[0] = entry->padding[1]
> - = entry->padding[2] = 0,
> - ".index field should be zero");
> + TEST_ASSERT(!entry->padding[0] && !entry->padding[1] &&
> + !entry->padding[2], "padding should be zero");
>
> /*
> * If needed for debug:
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
WARNING: multiple messages have this Message-ID (diff)
From: vkuznets at redhat.com (Vitaly Kuznetsov)
Subject: [PATCH] KVM: selftests: Fix a condition in test_hv_cpuid()
Date: Tue, 14 May 2019 09:22:56 -0400 [thread overview]
Message-ID: <87lfz9npan.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20190514103451.GA1694@mwanda>
Dan Carpenter <dan.carpenter at oracle.com> writes:
> The code is trying to check that all the padding is zeroed out and it
> does this:
>
> entry->padding[0] == entry->padding[1] == entry->padding[2] == 0
>
> Assume everything is zeroed correctly, then the first comparison is
> true, the next comparison is false and false is equal to zero so the
> overall condition is true. This bug doesn't affect run time very
> badly, but the code should instead just check that all three paddings
> are zero individually.
>
> Also the error message was copy and pasted from an earlier error and it
> wasn't correct.
>
> Fixes: 7edcb7343327 ("KVM: selftests: Add hyperv_cpuid test")
> Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
> ---
> tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> index 9a21e912097c..63b9fc3fdfbe 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> @@ -58,9 +58,8 @@ static void test_hv_cpuid(struct kvm_cpuid2
> *hv_cpuid_entries,
we also seem to check for 'entry->index == 0' twice here.
> TEST_ASSERT(entry->flags == 0,
> ".flags field should be zero");
>
> - TEST_ASSERT(entry->padding[0] == entry->padding[1]
> - == entry->padding[2] == 0,
> - ".index field should be zero");
> + TEST_ASSERT(!entry->padding[0] && !entry->padding[1] &&
> + !entry->padding[2], "padding should be zero");
>
> /*
> * If needed for debug:
Reviewed-by: Vitaly Kuznetsov <vkuznets at redhat.com>
--
Vitaly
WARNING: multiple messages have this Message-ID (diff)
From: vkuznets@redhat.com (Vitaly Kuznetsov)
Subject: [PATCH] KVM: selftests: Fix a condition in test_hv_cpuid()
Date: Tue, 14 May 2019 09:22:56 -0400 [thread overview]
Message-ID: <87lfz9npan.fsf@vitty.brq.redhat.com> (raw)
Message-ID: <20190514132256.j5MHcPLRI6W17zeinQH-_9CechMx4_Y94hUF1aGQGMg@z> (raw)
In-Reply-To: <20190514103451.GA1694@mwanda>
Dan Carpenter <dan.carpenter at oracle.com> writes:
> The code is trying to check that all the padding is zeroed out and it
> does this:
>
> entry->padding[0] == entry->padding[1] == entry->padding[2] == 0
>
> Assume everything is zeroed correctly, then the first comparison is
> true, the next comparison is false and false is equal to zero so the
> overall condition is true. This bug doesn't affect run time very
> badly, but the code should instead just check that all three paddings
> are zero individually.
>
> Also the error message was copy and pasted from an earlier error and it
> wasn't correct.
>
> Fixes: 7edcb7343327 ("KVM: selftests: Add hyperv_cpuid test")
> Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
> ---
> tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> index 9a21e912097c..63b9fc3fdfbe 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> @@ -58,9 +58,8 @@ static void test_hv_cpuid(struct kvm_cpuid2
> *hv_cpuid_entries,
we also seem to check for 'entry->index == 0' twice here.
> TEST_ASSERT(entry->flags == 0,
> ".flags field should be zero");
>
> - TEST_ASSERT(entry->padding[0] == entry->padding[1]
> - == entry->padding[2] == 0,
> - ".index field should be zero");
> + TEST_ASSERT(!entry->padding[0] && !entry->padding[1] &&
> + !entry->padding[2], "padding should be zero");
>
> /*
> * If needed for debug:
Reviewed-by: Vitaly Kuznetsov <vkuznets at redhat.com>
--
Vitaly
WARNING: multiple messages have this Message-ID (diff)
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Shuah Khan" <shuah@kernel.org>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Fix a condition in test_hv_cpuid()
Date: Tue, 14 May 2019 09:22:56 -0400 [thread overview]
Message-ID: <87lfz9npan.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20190514103451.GA1694@mwanda>
Dan Carpenter <dan.carpenter@oracle.com> writes:
> The code is trying to check that all the padding is zeroed out and it
> does this:
>
> entry->padding[0] == entry->padding[1] == entry->padding[2] == 0
>
> Assume everything is zeroed correctly, then the first comparison is
> true, the next comparison is false and false is equal to zero so the
> overall condition is true. This bug doesn't affect run time very
> badly, but the code should instead just check that all three paddings
> are zero individually.
>
> Also the error message was copy and pasted from an earlier error and it
> wasn't correct.
>
> Fixes: 7edcb7343327 ("KVM: selftests: Add hyperv_cpuid test")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> index 9a21e912097c..63b9fc3fdfbe 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> @@ -58,9 +58,8 @@ static void test_hv_cpuid(struct kvm_cpuid2
> *hv_cpuid_entries,
we also seem to check for 'entry->index == 0' twice here.
> TEST_ASSERT(entry->flags == 0,
> ".flags field should be zero");
>
> - TEST_ASSERT(entry->padding[0] == entry->padding[1]
> - == entry->padding[2] == 0,
> - ".index field should be zero");
> + TEST_ASSERT(!entry->padding[0] && !entry->padding[1] &&
> + !entry->padding[2], "padding should be zero");
>
> /*
> * If needed for debug:
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
next prev parent reply other threads:[~2019-05-14 13:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-14 10:34 [PATCH] KVM: selftests: Fix a condition in test_hv_cpuid() Dan Carpenter
2019-05-14 10:34 ` Dan Carpenter
2019-05-14 10:34 ` Dan Carpenter
2019-05-14 10:34 ` dan.carpenter
2019-05-14 13:22 ` Vitaly Kuznetsov [this message]
2019-05-14 13:22 ` Vitaly Kuznetsov
2019-05-14 13:22 ` Vitaly Kuznetsov
2019-05-14 13:22 ` vkuznets
2019-05-17 10:00 ` Thomas Huth
2019-05-17 10:00 ` Thomas Huth
2019-05-17 10:00 ` Thomas Huth
2019-05-17 10:00 ` thuth
2019-05-20 9:58 ` Paolo Bonzini
2019-05-20 9:58 ` Paolo Bonzini
2019-05-20 9:58 ` Paolo Bonzini
2019-05-20 9:58 ` pbonzini
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=87lfz9npan.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=shuah@kernel.org \
/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.