Skip to content

Commit 7ce7f8e

Browse files
committed
KVM: selftests: Rip out old, param-based guest assert macros
Drop the param-based guest assert macros and enable the printf versions for all selftests. Note! This change can affect tests even if they don't use directly use guest asserts! E.g. via library code, or due to the compiler making different optimization decisions. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 4e15c38 commit 7ce7f8e

24 files changed

+0
-117
lines changed

tools/testing/selftests/kvm/aarch64/arch_timer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
*
2020
* Copyright (c) 2021, Google LLC.
2121
*/
22-
#define USE_GUEST_ASSERT_PRINTF 1
23-
2422
#define _GNU_SOURCE
2523

2624
#include <stdlib.h>

tools/testing/selftests/kvm/aarch64/debug-exceptions.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#define USE_GUEST_ASSERT_PRINTF 1
3-
42
#include <test_util.h>
53
#include <kvm_util.h>
64
#include <processor.h>

tools/testing/selftests/kvm/aarch64/hypercalls.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* hypercalls are properly masked or unmasked to the guest when disabled or
99
* enabled from the KVM userspace, respectively.
1010
*/
11-
#define USE_GUEST_ASSERT_PRINTF 1
12-
1311
#include <errno.h>
1412
#include <linux/arm-smccc.h>
1513
#include <asm/kvm.h>

tools/testing/selftests/kvm/aarch64/page_fault_test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* hugetlbfs with a hole). It checks that the expected handling method is
88
* called (e.g., uffd faults with the right address and write/read flag).
99
*/
10-
#define USE_GUEST_ASSERT_PRINTF 1
11-
1210
#define _GNU_SOURCE
1311
#include <linux/bitmap.h>
1412
#include <fcntl.h>

tools/testing/selftests/kvm/aarch64/vgic_irq.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* host to inject a specific intid via a GUEST_SYNC call, and then checks that
88
* it received it.
99
*/
10-
#define USE_GUEST_ASSERT_PRINTF 1
11-
1210
#include <asm/kvm.h>
1311
#include <asm/kvm_para.h>
1412
#include <sys/eventfd.h>

tools/testing/selftests/kvm/guest_print_test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*
55
* Copyright 2022, Google, Inc. and/or its affiliates.
66
*/
7-
#define USE_GUEST_ASSERT_PRINTF 1
8-
97
#include <fcntl.h>
108
#include <stdio.h>
119
#include <stdlib.h>

tools/testing/selftests/kvm/include/ucall_common.h

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ enum guest_assert_builtin_args {
6666
GUEST_ASSERT_BUILTIN_NARGS
6767
};
6868

69-
#ifdef USE_GUEST_ASSERT_PRINTF
7069
#define ____GUEST_ASSERT(_condition, _exp, _fmt, _args...) \
7170
do { \
7271
if (!(_condition)) \
@@ -108,74 +107,4 @@ do { \
108107
#define GUEST_ASSERT_1(_condition, arg1) \
109108
__GUEST_ASSERT(_condition, "arg1 = 0x%lx", arg1)
110109

111-
#else
112-
113-
#define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) \
114-
do { \
115-
if (!(_condition)) \
116-
ucall(UCALL_ABORT, GUEST_ASSERT_BUILTIN_NARGS + _nargs, \
117-
"Failed guest assert: " _condstr, \
118-
__FILE__, __LINE__, ##_args); \
119-
} while (0)
120-
121-
#define GUEST_ASSERT(_condition) \
122-
__GUEST_ASSERT(_condition, #_condition, 0, 0)
123-
124-
#define GUEST_ASSERT_1(_condition, arg1) \
125-
__GUEST_ASSERT(_condition, #_condition, 1, (arg1))
126-
127-
#define GUEST_ASSERT_2(_condition, arg1, arg2) \
128-
__GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2))
129-
130-
#define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \
131-
__GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3))
132-
133-
#define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \
134-
__GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4))
135-
136-
#define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b)
137-
138-
#define __REPORT_GUEST_ASSERT(_ucall, fmt, _args...) \
139-
TEST_FAIL("%s at %s:%ld\n" fmt, \
140-
(const char *)(_ucall).args[GUEST_ERROR_STRING], \
141-
(const char *)(_ucall).args[GUEST_FILE], \
142-
(_ucall).args[GUEST_LINE], \
143-
##_args)
144-
145-
#define GUEST_ASSERT_ARG(ucall, i) ((ucall).args[GUEST_ASSERT_BUILTIN_NARGS + i])
146-
147-
#define REPORT_GUEST_ASSERT(ucall) \
148-
__REPORT_GUEST_ASSERT((ucall), "")
149-
150-
#define REPORT_GUEST_ASSERT_1(ucall, fmt) \
151-
__REPORT_GUEST_ASSERT((ucall), \
152-
fmt, \
153-
GUEST_ASSERT_ARG((ucall), 0))
154-
155-
#define REPORT_GUEST_ASSERT_2(ucall, fmt) \
156-
__REPORT_GUEST_ASSERT((ucall), \
157-
fmt, \
158-
GUEST_ASSERT_ARG((ucall), 0), \
159-
GUEST_ASSERT_ARG((ucall), 1))
160-
161-
#define REPORT_GUEST_ASSERT_3(ucall, fmt) \
162-
__REPORT_GUEST_ASSERT((ucall), \
163-
fmt, \
164-
GUEST_ASSERT_ARG((ucall), 0), \
165-
GUEST_ASSERT_ARG((ucall), 1), \
166-
GUEST_ASSERT_ARG((ucall), 2))
167-
168-
#define REPORT_GUEST_ASSERT_4(ucall, fmt) \
169-
__REPORT_GUEST_ASSERT((ucall), \
170-
fmt, \
171-
GUEST_ASSERT_ARG((ucall), 0), \
172-
GUEST_ASSERT_ARG((ucall), 1), \
173-
GUEST_ASSERT_ARG((ucall), 2), \
174-
GUEST_ASSERT_ARG((ucall), 3))
175-
176-
#define REPORT_GUEST_ASSERT_N(ucall, fmt, args...) \
177-
__REPORT_GUEST_ASSERT((ucall), fmt, ##args)
178-
179-
#endif /* USE_GUEST_ASSERT_PRINTF */
180-
181110
#endif /* SELFTEST_KVM_UCALL_COMMON_H */

tools/testing/selftests/kvm/memslot_perf_test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*
77
* Basic guest setup / host vCPU thread code lifted from set_memory_region_test.
88
*/
9-
#define USE_GUEST_ASSERT_PRINTF 1
10-
119
#include <pthread.h>
1210
#include <sched.h>
1311
#include <semaphore.h>

tools/testing/selftests/kvm/s390x/memop.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*
55
* Copyright (C) 2019, Red Hat, Inc.
66
*/
7-
#define USE_GUEST_ASSERT_PRINTF 1
8-
97
#include <stdio.h>
108
#include <stdlib.h>
119
#include <string.h>

tools/testing/selftests/kvm/s390x/tprot.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*
55
* Copyright IBM Corp. 2021
66
*/
7-
#define USE_GUEST_ASSERT_PRINTF 1
8-
97
#include <sys/mman.h>
108
#include "test_util.h"
119
#include "kvm_util.h"

0 commit comments

Comments
 (0)