|
4 | 4 | *
|
5 | 5 | * Copyright (C) 2022, Google LLC.
|
6 | 6 | */
|
| 7 | +#define USE_GUEST_ASSERT_PRINTF 1 |
7 | 8 |
|
8 | 9 | #include <fcntl.h>
|
9 | 10 | #include <stdio.h>
|
|
20 | 21 | * Assert that architectural dependency rules are satisfied, e.g. that AVX is
|
21 | 22 | * supported if and only if SSE is supported.
|
22 | 23 | */
|
23 |
| -#define ASSERT_XFEATURE_DEPENDENCIES(supported_xcr0, xfeatures, dependencies) \ |
24 |
| -do { \ |
25 |
| - uint64_t __supported = (supported_xcr0) & ((xfeatures) | (dependencies)); \ |
26 |
| - \ |
27 |
| - GUEST_ASSERT_3((__supported & (xfeatures)) != (xfeatures) || \ |
28 |
| - __supported == ((xfeatures) | (dependencies)), \ |
29 |
| - __supported, (xfeatures), (dependencies)); \ |
| 24 | +#define ASSERT_XFEATURE_DEPENDENCIES(supported_xcr0, xfeatures, dependencies) \ |
| 25 | +do { \ |
| 26 | + uint64_t __supported = (supported_xcr0) & ((xfeatures) | (dependencies)); \ |
| 27 | + \ |
| 28 | + __GUEST_ASSERT((__supported & (xfeatures)) != (xfeatures) || \ |
| 29 | + __supported == ((xfeatures) | (dependencies)), \ |
| 30 | + "supported = 0x%llx, xfeatures = 0x%llx, dependencies = 0x%llx", \ |
| 31 | + __supported, (xfeatures), (dependencies)); \ |
30 | 32 | } while (0)
|
31 | 33 |
|
32 | 34 | /*
|
|
41 | 43 | do { \
|
42 | 44 | uint64_t __supported = (supported_xcr0) & (xfeatures); \
|
43 | 45 | \
|
44 |
| - GUEST_ASSERT_2(!__supported || __supported == (xfeatures), \ |
| 46 | + __GUEST_ASSERT(!__supported || __supported == (xfeatures), \ |
| 47 | + "supported = 0x%llx, xfeatures = 0x%llx", \ |
45 | 48 | __supported, (xfeatures)); \
|
46 | 49 | } while (0)
|
47 | 50 |
|
@@ -79,14 +82,18 @@ static void guest_code(void)
|
79 | 82 | XFEATURE_MASK_XTILE);
|
80 | 83 |
|
81 | 84 | vector = xsetbv_safe(0, supported_xcr0);
|
82 |
| - GUEST_ASSERT_2(!vector, supported_xcr0, vector); |
| 85 | + __GUEST_ASSERT(!vector, |
| 86 | + "Expected success on XSETBV(0x%llx), got vector '0x%x'", |
| 87 | + supported_xcr0, vector); |
83 | 88 |
|
84 | 89 | for (i = 0; i < 64; i++) {
|
85 | 90 | if (supported_xcr0 & BIT_ULL(i))
|
86 | 91 | continue;
|
87 | 92 |
|
88 | 93 | vector = xsetbv_safe(0, supported_xcr0 | BIT_ULL(i));
|
89 |
| - GUEST_ASSERT_3(vector == GP_VECTOR, supported_xcr0, vector, BIT_ULL(i)); |
| 94 | + __GUEST_ASSERT(vector == GP_VECTOR, |
| 95 | + "Expected #GP on XSETBV(0x%llx), supported XCR0 = %llx, got vector '0x%x'", |
| 96 | + BIT_ULL(i), supported_xcr0, vector); |
90 | 97 | }
|
91 | 98 |
|
92 | 99 | GUEST_DONE();
|
@@ -117,7 +124,7 @@ int main(int argc, char *argv[])
|
117 | 124 |
|
118 | 125 | switch (get_ucall(vcpu, &uc)) {
|
119 | 126 | case UCALL_ABORT:
|
120 |
| - REPORT_GUEST_ASSERT_3(uc, "0x%lx 0x%lx 0x%lx"); |
| 127 | + REPORT_GUEST_ASSERT(uc); |
121 | 128 | break;
|
122 | 129 | case UCALL_DONE:
|
123 | 130 | goto done;
|
|
0 commit comments