Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20230729003643.1053367-33-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

-117
-2
tools/testing/selftests/kvm/aarch64/arch_timer.c
··· 19 19 * 20 20 * Copyright (c) 2021, Google LLC. 21 21 */ 22 - #define USE_GUEST_ASSERT_PRINTF 1 23 - 24 22 #define _GNU_SOURCE 25 23 26 24 #include <stdlib.h>
-2
tools/testing/selftests/kvm/aarch64/debug-exceptions.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #define USE_GUEST_ASSERT_PRINTF 1 3 - 4 2 #include <test_util.h> 5 3 #include <kvm_util.h> 6 4 #include <processor.h>
-2
tools/testing/selftests/kvm/aarch64/hypercalls.c
··· 8 8 * hypercalls are properly masked or unmasked to the guest when disabled or 9 9 * enabled from the KVM userspace, respectively. 10 10 */ 11 - #define USE_GUEST_ASSERT_PRINTF 1 12 - 13 11 #include <errno.h> 14 12 #include <linux/arm-smccc.h> 15 13 #include <asm/kvm.h>
-2
tools/testing/selftests/kvm/aarch64/page_fault_test.c
··· 7 7 * hugetlbfs with a hole). It checks that the expected handling method is 8 8 * called (e.g., uffd faults with the right address and write/read flag). 9 9 */ 10 - #define USE_GUEST_ASSERT_PRINTF 1 11 - 12 10 #define _GNU_SOURCE 13 11 #include <linux/bitmap.h> 14 12 #include <fcntl.h>
-2
tools/testing/selftests/kvm/aarch64/vgic_irq.c
··· 7 7 * host to inject a specific intid via a GUEST_SYNC call, and then checks that 8 8 * it received it. 9 9 */ 10 - #define USE_GUEST_ASSERT_PRINTF 1 11 - 12 10 #include <asm/kvm.h> 13 11 #include <asm/kvm_para.h> 14 12 #include <sys/eventfd.h>
-2
tools/testing/selftests/kvm/guest_print_test.c
··· 4 4 * 5 5 * Copyright 2022, Google, Inc. and/or its affiliates. 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <fcntl.h> 10 8 #include <stdio.h> 11 9 #include <stdlib.h>
-71
tools/testing/selftests/kvm/include/ucall_common.h
··· 66 66 GUEST_ASSERT_BUILTIN_NARGS 67 67 }; 68 68 69 - #ifdef USE_GUEST_ASSERT_PRINTF 70 69 #define ____GUEST_ASSERT(_condition, _exp, _fmt, _args...) \ 71 70 do { \ 72 71 if (!(_condition)) \ ··· 106 107 /* FIXME: Drop this alias once the param-based guest asserts are gone. */ 107 108 #define GUEST_ASSERT_1(_condition, arg1) \ 108 109 __GUEST_ASSERT(_condition, "arg1 = 0x%lx", arg1) 109 - 110 - #else 111 - 112 - #define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) \ 113 - do { \ 114 - if (!(_condition)) \ 115 - ucall(UCALL_ABORT, GUEST_ASSERT_BUILTIN_NARGS + _nargs, \ 116 - "Failed guest assert: " _condstr, \ 117 - __FILE__, __LINE__, ##_args); \ 118 - } while (0) 119 - 120 - #define GUEST_ASSERT(_condition) \ 121 - __GUEST_ASSERT(_condition, #_condition, 0, 0) 122 - 123 - #define GUEST_ASSERT_1(_condition, arg1) \ 124 - __GUEST_ASSERT(_condition, #_condition, 1, (arg1)) 125 - 126 - #define GUEST_ASSERT_2(_condition, arg1, arg2) \ 127 - __GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2)) 128 - 129 - #define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \ 130 - __GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3)) 131 - 132 - #define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \ 133 - __GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4)) 134 - 135 - #define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b) 136 - 137 - #define __REPORT_GUEST_ASSERT(_ucall, fmt, _args...) \ 138 - TEST_FAIL("%s at %s:%ld\n" fmt, \ 139 - (const char *)(_ucall).args[GUEST_ERROR_STRING], \ 140 - (const char *)(_ucall).args[GUEST_FILE], \ 141 - (_ucall).args[GUEST_LINE], \ 142 - ##_args) 143 - 144 - #define GUEST_ASSERT_ARG(ucall, i) ((ucall).args[GUEST_ASSERT_BUILTIN_NARGS + i]) 145 - 146 - #define REPORT_GUEST_ASSERT(ucall) \ 147 - __REPORT_GUEST_ASSERT((ucall), "") 148 - 149 - #define REPORT_GUEST_ASSERT_1(ucall, fmt) \ 150 - __REPORT_GUEST_ASSERT((ucall), \ 151 - fmt, \ 152 - GUEST_ASSERT_ARG((ucall), 0)) 153 - 154 - #define REPORT_GUEST_ASSERT_2(ucall, fmt) \ 155 - __REPORT_GUEST_ASSERT((ucall), \ 156 - fmt, \ 157 - GUEST_ASSERT_ARG((ucall), 0), \ 158 - GUEST_ASSERT_ARG((ucall), 1)) 159 - 160 - #define REPORT_GUEST_ASSERT_3(ucall, fmt) \ 161 - __REPORT_GUEST_ASSERT((ucall), \ 162 - fmt, \ 163 - GUEST_ASSERT_ARG((ucall), 0), \ 164 - GUEST_ASSERT_ARG((ucall), 1), \ 165 - GUEST_ASSERT_ARG((ucall), 2)) 166 - 167 - #define REPORT_GUEST_ASSERT_4(ucall, fmt) \ 168 - __REPORT_GUEST_ASSERT((ucall), \ 169 - fmt, \ 170 - GUEST_ASSERT_ARG((ucall), 0), \ 171 - GUEST_ASSERT_ARG((ucall), 1), \ 172 - GUEST_ASSERT_ARG((ucall), 2), \ 173 - GUEST_ASSERT_ARG((ucall), 3)) 174 - 175 - #define REPORT_GUEST_ASSERT_N(ucall, fmt, args...) \ 176 - __REPORT_GUEST_ASSERT((ucall), fmt, ##args) 177 - 178 - #endif /* USE_GUEST_ASSERT_PRINTF */ 179 110 180 111 #endif /* SELFTEST_KVM_UCALL_COMMON_H */
-2
tools/testing/selftests/kvm/memslot_perf_test.c
··· 6 6 * 7 7 * Basic guest setup / host vCPU thread code lifted from set_memory_region_test. 8 8 */ 9 - #define USE_GUEST_ASSERT_PRINTF 1 10 - 11 9 #include <pthread.h> 12 10 #include <sched.h> 13 11 #include <semaphore.h>
-2
tools/testing/selftests/kvm/s390x/memop.c
··· 4 4 * 5 5 * Copyright (C) 2019, Red Hat, Inc. 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <stdio.h> 10 8 #include <stdlib.h> 11 9 #include <string.h>
-2
tools/testing/selftests/kvm/s390x/tprot.c
··· 4 4 * 5 5 * Copyright IBM Corp. 2021 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <sys/mman.h> 10 8 #include "test_util.h" 11 9 #include "kvm_util.h"
-2
tools/testing/selftests/kvm/set_memory_region_test.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #define USE_GUEST_ASSERT_PRINTF 1 3 - 4 2 #define _GNU_SOURCE /* for program_invocation_short_name */ 5 3 #include <fcntl.h> 6 4 #include <pthread.h>
-2
tools/testing/selftests/kvm/steal_time.c
··· 4 4 * 5 5 * Copyright (C) 2020, Red Hat, Inc. 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #define _GNU_SOURCE 10 8 #include <stdio.h> 11 9 #include <time.h>
-2
tools/testing/selftests/kvm/x86_64/cpuid_test.c
··· 4 4 * 5 5 * Generic tests for KVM CPUID set/get ioctls 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <asm/kvm_para.h> 10 8 #include <linux/kvm_para.h> 11 9 #include <stdint.h>
-2
tools/testing/selftests/kvm/x86_64/hyperv_extended_hypercalls.c
··· 8 8 * Copyright 2022 Google LLC 9 9 * Author: Vipin Sharma <vipinsh@google.com> 10 10 */ 11 - #define USE_GUEST_ASSERT_PRINTF 1 12 - 13 11 #include "kvm_util.h" 14 12 #include "processor.h" 15 13 #include "hyperv.h"
-2
tools/testing/selftests/kvm/x86_64/hyperv_features.c
··· 4 4 * 5 5 * Tests for Hyper-V features enablement 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <asm/kvm_para.h> 10 8 #include <linux/kvm_para.h> 11 9 #include <stdint.h>
-2
tools/testing/selftests/kvm/x86_64/kvm_pv_test.c
··· 4 4 * 5 5 * Tests for KVM paravirtual feature disablement 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <asm/kvm_para.h> 10 8 #include <linux/kvm_para.h> 11 9 #include <stdint.h>
-2
tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #define USE_GUEST_ASSERT_PRINTF 1 3 - 4 2 #include <fcntl.h> 5 3 #include <stdio.h> 6 4 #include <stdlib.h>
-2
tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 - #define USE_GUEST_ASSERT_PRINTF 1 3 - 4 2 #define _GNU_SOURCE /* for program_invocation_short_name */ 5 3 6 4 #include "test_util.h"
-2
tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
··· 4 4 * 5 5 * Copyright (C) 2020, Red Hat, Inc. 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #define _GNU_SOURCE /* for program_invocation_name */ 10 8 #include <fcntl.h> 11 9 #include <stdio.h>
-2
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
··· 8 8 * Copyright (C) 2021, Red Hat, Inc. 9 9 * 10 10 */ 11 - #define USE_GUEST_ASSERT_PRINTF 1 12 - 13 11 #include <stdatomic.h> 14 12 #include <stdio.h> 15 13 #include <unistd.h>
-2
tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
··· 4 4 * 5 5 * Copyright (C) 2020, Red Hat, Inc. 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <stdio.h> 10 8 #include <string.h> 11 9 #include "kvm_util.h"
-2
tools/testing/selftests/kvm/x86_64/userspace_io_test.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #define USE_GUEST_ASSERT_PRINTF 1 3 - 4 2 #include <fcntl.h> 5 3 #include <stdio.h> 6 4 #include <stdlib.h>
-2
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
··· 10 10 * and check it can be retrieved with KVM_GET_MSR, also test 11 11 * the invalid LBR formats are rejected. 12 12 */ 13 - #define USE_GUEST_ASSERT_PRINTF 1 14 - 15 13 #define _GNU_SOURCE /* for program_invocation_short_name */ 16 14 #include <sys/ioctl.h> 17 15
-2
tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c
··· 4 4 * 5 5 * Copyright (C) 2022, Google LLC. 6 6 */ 7 - #define USE_GUEST_ASSERT_PRINTF 1 8 - 9 7 #include <fcntl.h> 10 8 #include <stdio.h> 11 9 #include <stdlib.h>