]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - pending-5.1/kvm-selftests-fix-a-condition-in-test_hv_cpuid.patch
move existing queues out of the way for the moment...
[thirdparty/kernel/stable-queue.git] / pending-5.1 / kvm-selftests-fix-a-condition-in-test_hv_cpuid.patch
1 From f814a74c2501910f198d748a47aa3f991541927c Mon Sep 17 00:00:00 2001
2 From: Dan Carpenter <dan.carpenter@oracle.com>
3 Date: Tue, 14 May 2019 13:34:51 +0300
4 Subject: KVM: selftests: Fix a condition in test_hv_cpuid()
5
6 [ Upstream commit be7fcf1d1701a5266dd36eab4978476f63d1bd57 ]
7
8 The code is trying to check that all the padding is zeroed out and it
9 does this:
10
11 entry->padding[0] == entry->padding[1] == entry->padding[2] == 0
12
13 Assume everything is zeroed correctly, then the first comparison is
14 true, the next comparison is false and false is equal to zero so the
15 overall condition is true. This bug doesn't affect run time very
16 badly, but the code should instead just check that all three paddings
17 are zero individually.
18
19 Also the error message was copy and pasted from an earlier error and it
20 wasn't correct.
21
22 Fixes: 7edcb7343327 ("KVM: selftests: Add hyperv_cpuid test")
23 Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
24 Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
25 Reviewed-by: Thomas Huth <thuth@redhat.com>
26 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
27 Signed-off-by: Sasha Levin <sashal@kernel.org>
28 ---
29 tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 5 ++---
30 1 file changed, 2 insertions(+), 3 deletions(-)
31
32 diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
33 index 9a21e912097c..63b9fc3fdfbe 100644
34 --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
35 +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
36 @@ -58,9 +58,8 @@ static void test_hv_cpuid(struct kvm_cpuid2 *hv_cpuid_entries,
37 TEST_ASSERT(entry->flags == 0,
38 ".flags field should be zero");
39
40 - TEST_ASSERT(entry->padding[0] == entry->padding[1]
41 - == entry->padding[2] == 0,
42 - ".index field should be zero");
43 + TEST_ASSERT(!entry->padding[0] && !entry->padding[1] &&
44 + !entry->padding[2], "padding should be zero");
45
46 /*
47 * If needed for debug:
48 --
49 2.20.1
50