Skip to content

Commit 4d53dcc

Browse files
committed
KVM: selftests: Fix benign %llx vs. %lx issues in guest asserts
Convert %llx to %lx as appropriate in guest asserts. The guest printf implementation treats them the same as KVM selftests are 64-bit only, but strictly adhering to the correct format will allow annotating the underlying helpers with __printf() without introducing new warnings in the build. Link: https://lore.kernel.org/r/20231129224916.532431-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 1af3bf2 commit 4d53dcc

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

tools/testing/selftests/kvm/set_memory_region_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,17 @@ static void guest_code_move_memory_region(void)
157157
*/
158158
val = guest_spin_on_val(0);
159159
__GUEST_ASSERT(val == 1 || val == MMIO_VAL,
160-
"Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val);
160+
"Expected '1' or MMIO ('%lx'), got '%lx'", MMIO_VAL, val);
161161

162162
/* Spin until the misaligning memory region move completes. */
163163
val = guest_spin_on_val(MMIO_VAL);
164164
__GUEST_ASSERT(val == 1 || val == 0,
165-
"Expected '0' or '1' (no MMIO), got '%llx'", val);
165+
"Expected '0' or '1' (no MMIO), got '%lx'", val);
166166

167167
/* Spin until the memory region starts to get re-aligned. */
168168
val = guest_spin_on_val(0);
169169
__GUEST_ASSERT(val == 1 || val == MMIO_VAL,
170-
"Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val);
170+
"Expected '1' or MMIO ('%lx'), got '%lx'", MMIO_VAL, val);
171171

172172
/* Spin until the re-aligning memory region move completes. */
173173
val = guest_spin_on_val(MMIO_VAL);

tools/testing/selftests/kvm/x86_64/hyperv_features.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void guest_msr(struct msr_data *msr)
6666

6767
if (msr->write)
6868
__GUEST_ASSERT(!vector,
69-
"WRMSR(0x%x) to '0x%llx', RDMSR read '0x%llx'",
69+
"WRMSR(0x%x) to '0x%lx', RDMSR read '0x%lx'",
7070
msr->idx, msr->write_val, msr_val);
7171

7272
/* Invariant TSC bit appears when TSC invariant control MSR is written to */

tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ do { \
3535
\
3636
for (i = 0; i < size; i++) \
3737
__GUEST_ASSERT(mem[i] == pattern, \
38-
"Guest expected 0x%x at offset %lu (gpa 0x%llx), got 0x%x", \
38+
"Guest expected 0x%x at offset %lu (gpa 0x%lx), got 0x%x", \
3939
pattern, i, gpa + i, mem[i]); \
4040
} while (0)
4141

tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void l1_guest_code(struct svm_test_data *svm, uint64_t is_nmi, uint64_t i
103103

104104
run_guest(vmcb, svm->vmcb_gpa);
105105
__GUEST_ASSERT(vmcb->control.exit_code == SVM_EXIT_VMMCALL,
106-
"Expected VMMCAL #VMEXIT, got '0x%x', info1 = '0x%llx, info2 = '0x%llx'",
106+
"Expected VMMCAL #VMEXIT, got '0x%x', info1 = '0x%lx, info2 = '0x%lx'",
107107
vmcb->control.exit_code,
108108
vmcb->control.exit_info_1, vmcb->control.exit_info_2);
109109

@@ -133,7 +133,7 @@ static void l1_guest_code(struct svm_test_data *svm, uint64_t is_nmi, uint64_t i
133133

134134
run_guest(vmcb, svm->vmcb_gpa);
135135
__GUEST_ASSERT(vmcb->control.exit_code == SVM_EXIT_HLT,
136-
"Expected HLT #VMEXIT, got '0x%x', info1 = '0x%llx, info2 = '0x%llx'",
136+
"Expected HLT #VMEXIT, got '0x%x', info1 = '0x%lx, info2 = '0x%lx'",
137137
vmcb->control.exit_code,
138138
vmcb->control.exit_info_1, vmcb->control.exit_info_2);
139139

tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void guest_test_perf_capabilities_gp(uint64_t val)
5656
uint8_t vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, val);
5757

5858
__GUEST_ASSERT(vector == GP_VECTOR,
59-
"Expected #GP for value '0x%llx', got vector '0x%x'",
59+
"Expected #GP for value '0x%lx', got vector '0x%x'",
6060
val, vector);
6161
}
6262

tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ do { \
2525
\
2626
__GUEST_ASSERT((__supported & (xfeatures)) != (xfeatures) || \
2727
__supported == ((xfeatures) | (dependencies)), \
28-
"supported = 0x%llx, xfeatures = 0x%llx, dependencies = 0x%llx", \
28+
"supported = 0x%lx, xfeatures = 0x%llx, dependencies = 0x%llx", \
2929
__supported, (xfeatures), (dependencies)); \
3030
} while (0)
3131

@@ -42,7 +42,7 @@ do { \
4242
uint64_t __supported = (supported_xcr0) & (xfeatures); \
4343
\
4444
__GUEST_ASSERT(!__supported || __supported == (xfeatures), \
45-
"supported = 0x%llx, xfeatures = 0x%llx", \
45+
"supported = 0x%lx, xfeatures = 0x%llx", \
4646
__supported, (xfeatures)); \
4747
} while (0)
4848

@@ -81,7 +81,7 @@ static void guest_code(void)
8181

8282
vector = xsetbv_safe(0, supported_xcr0);
8383
__GUEST_ASSERT(!vector,
84-
"Expected success on XSETBV(0x%llx), got vector '0x%x'",
84+
"Expected success on XSETBV(0x%lx), got vector '0x%x'",
8585
supported_xcr0, vector);
8686

8787
for (i = 0; i < 64; i++) {
@@ -90,7 +90,7 @@ static void guest_code(void)
9090

9191
vector = xsetbv_safe(0, supported_xcr0 | BIT_ULL(i));
9292
__GUEST_ASSERT(vector == GP_VECTOR,
93-
"Expected #GP on XSETBV(0x%llx), supported XCR0 = %llx, got vector '0x%x'",
93+
"Expected #GP on XSETBV(0x%llx), supported XCR0 = %lx, got vector '0x%x'",
9494
BIT_ULL(i), supported_xcr0, vector);
9595
}
9696

0 commit comments

Comments
 (0)