KVM: selftests: Rip out old, param-based guest assert macros
authorSean Christopherson <seanjc@google.com>
Sat, 29 Jul 2023 00:36:41 +0000 (17:36 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 2 Aug 2023 21:43:16 +0000 (14:43 -0700)
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/20230729003643.1053367-33-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
24 files changed:
tools/testing/selftests/kvm/aarch64/arch_timer.c
tools/testing/selftests/kvm/aarch64/debug-exceptions.c
tools/testing/selftests/kvm/aarch64/hypercalls.c
tools/testing/selftests/kvm/aarch64/page_fault_test.c
tools/testing/selftests/kvm/aarch64/vgic_irq.c
tools/testing/selftests/kvm/guest_print_test.c
tools/testing/selftests/kvm/include/ucall_common.h
tools/testing/selftests/kvm/memslot_perf_test.c
tools/testing/selftests/kvm/s390x/memop.c
tools/testing/selftests/kvm/s390x/tprot.c
tools/testing/selftests/kvm/set_memory_region_test.c
tools/testing/selftests/kvm/steal_time.c
tools/testing/selftests/kvm/x86_64/cpuid_test.c
tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c
tools/testing/selftests/kvm/x86_64/hyperv_features.c
tools/testing/selftests/kvm/x86_64/kvm_pv_test.c
tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c
tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
tools/testing/selftests/kvm/x86_64/userspace_io_test.c
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c

index b53bcf126e6a6a44837d537a5422f094750126bd..274b8465b42a5aa1d210ced625db7ce42799e693 100644 (file)
@@ -19,8 +19,6 @@
  *
  * Copyright (c) 2021, Google LLC.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #define _GNU_SOURCE
 
 #include <stdlib.h>
index fdd5b05e1b0e5baeaaa4120f82eb14595088054e..f5b6cb3a00191dff32f0406a61464c2fd7b8105b 100644 (file)
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <test_util.h>
 #include <kvm_util.h>
 #include <processor.h>
index 94555a7d3c7ee084905586635c039f0687774b77..31f66ba97228babe46bf2c46640077065ded7241 100644 (file)
@@ -8,8 +8,6 @@
  * hypercalls are properly masked or unmasked to the guest when disabled or
  * enabled from the KVM userspace, respectively.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <errno.h>
 #include <linux/arm-smccc.h>
 #include <asm/kvm.h>
index 0b0dd90feae5c4d8a5cafc70c593eb9b098d33b3..47bb914ab2fa8357c5b813084718ba05afa223d4 100644 (file)
@@ -7,8 +7,6 @@
  * hugetlbfs with a hole). It checks that the expected handling method is
  * called (e.g., uffd faults with the right address and write/read flag).
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #define _GNU_SOURCE
 #include <linux/bitmap.h>
 #include <fcntl.h>
index 67da33aa6d17de7ca3c1c1d85a3826606fba60c9..2e64b4856e38836956ca66441c25767ec230f302 100644 (file)
@@ -7,8 +7,6 @@
  * host to inject a specific intid via a GUEST_SYNC call, and then checks that
  * it received it.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <asm/kvm.h>
 #include <asm/kvm_para.h>
 #include <sys/eventfd.h>
index 267e01d057fb4b02a71eb76efb800924155da4de..41230b74619023d447f48fc8555936e194ce9387 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Copyright 2022, Google, Inc. and/or its affiliates.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
index 9e5948dab0304a46489a3f9cda26be835f540ff9..99bbb56cd1a519069c82aae636cc22943887ec7e 100644 (file)
@@ -66,7 +66,6 @@ enum guest_assert_builtin_args {
        GUEST_ASSERT_BUILTIN_NARGS
 };
 
-#ifdef USE_GUEST_ASSERT_PRINTF
 #define ____GUEST_ASSERT(_condition, _exp, _fmt, _args...)                             \
 do {                                                                                   \
        if (!(_condition))                                                              \
@@ -108,74 +107,4 @@ do {                                                                               \
 #define GUEST_ASSERT_1(_condition, arg1) \
        __GUEST_ASSERT(_condition, "arg1 = 0x%lx", arg1)
 
-#else
-
-#define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...)         \
-do {                                                                   \
-       if (!(_condition))                                              \
-               ucall(UCALL_ABORT, GUEST_ASSERT_BUILTIN_NARGS + _nargs, \
-                     "Failed guest assert: " _condstr,                 \
-                     __FILE__, __LINE__, ##_args);                     \
-} while (0)
-
-#define GUEST_ASSERT(_condition) \
-       __GUEST_ASSERT(_condition, #_condition, 0, 0)
-
-#define GUEST_ASSERT_1(_condition, arg1) \
-       __GUEST_ASSERT(_condition, #_condition, 1, (arg1))
-
-#define GUEST_ASSERT_2(_condition, arg1, arg2) \
-       __GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2))
-
-#define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \
-       __GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3))
-
-#define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \
-       __GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4))
-
-#define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b)
-
-#define __REPORT_GUEST_ASSERT(_ucall, fmt, _args...)                   \
-       TEST_FAIL("%s at %s:%ld\n" fmt,                                 \
-                 (const char *)(_ucall).args[GUEST_ERROR_STRING],      \
-                 (const char *)(_ucall).args[GUEST_FILE],              \
-                 (_ucall).args[GUEST_LINE],                            \
-                 ##_args)
-
-#define GUEST_ASSERT_ARG(ucall, i) ((ucall).args[GUEST_ASSERT_BUILTIN_NARGS + i])
-
-#define REPORT_GUEST_ASSERT(ucall)             \
-       __REPORT_GUEST_ASSERT((ucall), "")
-
-#define REPORT_GUEST_ASSERT_1(ucall, fmt)                      \
-       __REPORT_GUEST_ASSERT((ucall),                          \
-                             fmt,                              \
-                             GUEST_ASSERT_ARG((ucall), 0))
-
-#define REPORT_GUEST_ASSERT_2(ucall, fmt)                      \
-       __REPORT_GUEST_ASSERT((ucall),                          \
-                             fmt,                              \
-                             GUEST_ASSERT_ARG((ucall), 0),     \
-                             GUEST_ASSERT_ARG((ucall), 1))
-
-#define REPORT_GUEST_ASSERT_3(ucall, fmt)                      \
-       __REPORT_GUEST_ASSERT((ucall),                          \
-                             fmt,                              \
-                             GUEST_ASSERT_ARG((ucall), 0),     \
-                             GUEST_ASSERT_ARG((ucall), 1),     \
-                             GUEST_ASSERT_ARG((ucall), 2))
-
-#define REPORT_GUEST_ASSERT_4(ucall, fmt)                      \
-       __REPORT_GUEST_ASSERT((ucall),                          \
-                             fmt,                              \
-                             GUEST_ASSERT_ARG((ucall), 0),     \
-                             GUEST_ASSERT_ARG((ucall), 1),     \
-                             GUEST_ASSERT_ARG((ucall), 2),     \
-                             GUEST_ASSERT_ARG((ucall), 3))
-
-#define REPORT_GUEST_ASSERT_N(ucall, fmt, args...)     \
-       __REPORT_GUEST_ASSERT((ucall), fmt, ##args)
-
-#endif /* USE_GUEST_ASSERT_PRINTF */
-
 #endif /* SELFTEST_KVM_UCALL_COMMON_H */
index 55f1bc70e571975aff199c4adc56e26f9ce9d360..20eb2e730800e3a7075bc2af258ba0fafc8c9e5e 100644 (file)
@@ -6,8 +6,6 @@
  *
  * Basic guest setup / host vCPU thread code lifted from set_memory_region_test.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <pthread.h>
 #include <sched.h>
 #include <semaphore.h>
index a49173907cec2baea02054585411ce4b5e2f2e1f..bb3ca9a5d7318ebe88fbe9f5a7ebfaaf0c2235b6 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Copyright (C) 2019, Red Hat, Inc.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index c12c6824d96367528f73f77e83c9c60667dcea35..c73f948c9b63792cf2776ef3308763547ecec0ca 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Copyright IBM Corp. 2021
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <sys/mman.h>
 #include "test_util.h"
 #include "kvm_util.h"
index dd8f4bac9df8aad9ab7794358e82f20c05eea45d..b32960189f5f18eb688ae5a9066ed6764efdabd1 100644 (file)
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #define _GNU_SOURCE /* for program_invocation_short_name */
 #include <fcntl.h>
 #include <pthread.h>
index 8649c8545882aaa4ed75fcf7db6d4ded05a4166f..171adfb2a6cbc45ffee0fcf4d149b49ed29ab2d7 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Copyright (C) 2020, Red Hat, Inc.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <time.h>
index eb1b65ffc0d5eceea77dbac77aeccbb6082ea80f..3b34d8156d1c97a879d497a12eefe4f110628973 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Generic tests for KVM CPUID set/get ioctls
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <asm/kvm_para.h>
 #include <linux/kvm_para.h>
 #include <stdint.h>
index 0107d54a1a08ee99e23b8b06f63e1e1f6514716e..e036db1f32b9b33d99e0cbb55b349b87dbcdb6ef 100644 (file)
@@ -8,8 +8,6 @@
  * Copyright 2022 Google LLC
  * Author: Vipin Sharma <vipinsh@google.com>
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include "kvm_util.h"
 #include "processor.h"
 #include "hyperv.h"
index 41a6beff78c4379dc0b7df0254d2dcd43d905472..9f28aa276c4e23608f22cb97c2fd5f4a84084988 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Tests for Hyper-V features enablement
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <asm/kvm_para.h>
 #include <linux/kvm_para.h>
 #include <stdint.h>
index 1c28b77ff3cd224bd0d884d47f7ae98c857eec51..9e2879af7c201fb749120cee94a61e03dfaf162b 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Tests for KVM paravirtual feature disablement
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <asm/kvm_para.h>
 #include <linux/kvm_para.h>
 #include <stdint.h>
index 960fecab37424ef691f87b5a58cdc16cc808e1e3..80aa3d8b18f803c20092cc938d6822866146beda 100644 (file)
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
index 4a29f59a76be6c3705b7a191875e7f11688e8355..3670331adf21ad1ae9bbc3f450ea1cc1d7eed062 100644 (file)
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0-only
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #define _GNU_SOURCE /* for program_invocation_short_name */
 
 #include "test_util.h"
index abb3f26d3ce0270a8be273e8578ffa0376c60858..366cf18600bc7eb736657f3d0591bcde8aabccaf 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Copyright (C) 2020, Red Hat, Inc.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #define _GNU_SOURCE /* for program_invocation_name */
 #include <fcntl.h>
 #include <stdio.h>
index c908412c57541367a1fceb0e1a8a26b7bf65ccff..7ee44496cf97f62a9dcd2637fad26d210eac43be 100644 (file)
@@ -8,8 +8,6 @@
  *   Copyright (C) 2021, Red Hat, Inc.
  *
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <stdatomic.h>
 #include <stdio.h>
 #include <unistd.h>
index cf9114f70e1c06848bccbeebafa1539a2d340840..12b0964f4f13199e4fa7862c6871adeed4dd70b2 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Copyright (C) 2020, Red Hat, Inc.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <stdio.h>
 #include <string.h>
 #include "kvm_util.h"
index 2c5d2a18d184acbc93499a904b44864a472c91cf..255c50b0dc32675dfef64e65e1a0c6b164d0ca39 100644 (file)
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
index ba09d5a01c395ecf40b73ea78fb5babc59904700..ebbcb0a3f7438720932decc70b6539a607319f0a 100644 (file)
@@ -10,8 +10,6 @@
  * and check it can be retrieved with KVM_GET_MSR, also test
  * the invalid LBR formats are rejected.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #define _GNU_SOURCE /* for program_invocation_short_name */
 #include <sys/ioctl.h>
 
index 5e82907977209bd7b968f4648bb3de87b63a7f09..77d04a7bdaddd59d04f723d2b6858ca950eb9534 100644 (file)
@@ -4,8 +4,6 @@
  *
  * Copyright (C) 2022, Google LLC.
  */
-#define USE_GUEST_ASSERT_PRINTF 1
-
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>