@@ -458,13 +458,10 @@ static bool parse_args(int argc, char *argv[])
return false;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vm *vm;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
if (!parse_args(argc, argv))
exit(KSFT_SKIP);
@@ -246,7 +246,7 @@ static int debug_version(struct kvm_vcpu *vcpu)
return id_aa64dfr0 & 0xf;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -596,7 +596,7 @@ static struct vcpu_config *parse_config(const char *config)
return c;
}
-int main(int ac, char **av)
+void __main(int argc, char *argv[])
{
struct vcpu_config *c, *sel = NULL;
int i, ret = 0;
@@ -304,10 +304,8 @@ static void test_run(void)
kvm_vm_free(vm);
}
-int main(void)
+void __main(int argc, char *argv[])
{
- setbuf(stdout, NULL);
-
test_run();
return 0;
}
@@ -189,7 +189,7 @@ static void host_test_system_suspend(void)
kvm_vm_free(vm);
}
-int main(void)
+void __main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_SYSTEM_SUSPEND));
@@ -76,7 +76,7 @@ static int add_2vcpus_init_2vcpus(struct kvm_vcpu_init *init0,
* The other is running KVM_CREATE_VCPU and KVM_ARM_VCPU_INIT for a vCPU,
* and then run those commands for another vCPU.
*/
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu_init init0, init1;
struct kvm_vm *vm;
@@ -687,7 +687,7 @@ void run_tests(uint32_t gic_dev_type)
}
}
-int main(int ac, char **av)
+void __main(int argc, char *argv[])
{
int ret;
int pa_bits;
@@ -810,7 +810,7 @@ static void help(const char *name)
exit(1);
}
-int main(int argc, char **argv)
+void __main(int argc, char *argv[])
{
uint32_t nr_irqs = 64;
bool default_args = true;
@@ -818,9 +818,6 @@ int main(int argc, char **argv)
int opt;
bool eoi_split = false;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
while ((opt = getopt(argc, argv, "hn:e:l:")) != -1) {
switch (opt) {
case 'n':
@@ -340,7 +340,7 @@ static void help(char *name)
exit(0);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct test_params params = {
.backing_src = DEFAULT_VM_MEM_SRC,
@@ -382,6 +382,4 @@ int main(int argc, char *argv[])
close(page_idle_fd);
for_each_guest_mode(run_test, ¶ms);
-
- return 0;
}
@@ -393,7 +393,7 @@ static void help(char *name)
exit(0);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
struct test_params p = {
@@ -447,18 +447,15 @@ int main(int argc, char *argv[])
}
for_each_guest_mode(run_test, &p);
-
- return 0;
}
#else /* __NR_userfaultfd */
#warning "missing __NR_userfaultfd definition"
-int main(void)
+void __main(int argc, char *argv[])
{
print_skip("__NR_userfaultfd must be present for userfaultfd test");
- return KSFT_SKIP;
}
#endif /* __NR_userfaultfd */
@@ -387,7 +387,7 @@ static void help(char *name)
exit(0);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
struct test_params p = {
@@ -460,6 +460,4 @@ int main(int argc, char *argv[])
pr_info("Test iterations: %"PRIu64"\n", p.iterations);
for_each_guest_mode(run_test, &p);
-
- return 0;
}
@@ -838,7 +838,7 @@ static void help(char *name)
exit(0);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct test_params p = {
.iterations = TEST_HOST_LOOP_N,
@@ -920,6 +920,4 @@ int main(int argc, char *argv[])
host_log_mode = host_log_mode_option;
for_each_guest_mode(run_test, &p);
}
-
- return 0;
}
@@ -151,7 +151,7 @@ void wait_for_child_setup(pid_t pid)
}
}
-int main(int argc, char **argv)
+void __main(int argc, char *argv[])
{
uint32_t i;
int s, r;
@@ -834,4 +834,9 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)
return __vm_enable_cap(vm, KVM_CAP_VM_DISABLE_NX_HUGE_PAGES, 0);
}
+/*
+ * API to be implemented by all the selftests.
+ */
+void __main(int argc, char *argv[]);
+
#endif /* SELFTEST_KVM_UTIL_BASE_H */
@@ -204,7 +204,7 @@ static void vcpu_stats_test(struct kvm_vcpu *vcpu)
* created for testing.
*/
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int i, j;
struct kvm_vcpu **vcpus;
@@ -250,5 +250,4 @@ int main(int argc, char *argv[])
for (i = 0; i < max_vm; ++i)
kvm_vm_free(vms[i]);
free(vms);
- return 0;
}
@@ -37,7 +37,7 @@ void test_vcpu_creation(int first_vcpu_id, int num_vcpus)
kvm_vm_free(vm);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int kvm_max_vcpu_id = kvm_check_cap(KVM_CAP_MAX_VCPU_ID);
int kvm_max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
@@ -89,6 +89,4 @@ int main(int argc, char *argv[])
if (kvm_max_vcpu_id > kvm_max_vcpus)
test_vcpu_creation(
kvm_max_vcpu_id - kvm_max_vcpus, kvm_max_vcpus);
-
- return 0;
}
@@ -438,7 +438,7 @@ static void help(char *name)
puts("");
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
struct test_params p = {
@@ -476,6 +476,4 @@ int main(int argc, char *argv[])
}
for_each_guest_mode(run_test, &p);
-
- return 0;
}
@@ -1979,3 +1979,13 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data,
break;
}
}
+
+int main(int argc, char *argv[])
+{
+ /* Tell stdout not to buffer its content */
+ setbuf(stdout, NULL);
+
+ __main(argc, argv);
+
+ return 0;
+}
@@ -2071,7 +2071,7 @@ uint64_t get64(void)
return (x << 8) | get8();
}
-int main(void)
+void __main(int argc, char *argv[])
{
s = sparsebit_alloc();
for (;;) {
@@ -153,7 +153,7 @@ static void calc_default_nr_vcpus(void)
TEST_ASSERT(nr_vcpus > 0, "Uh, no CPUs?");
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
/*
* Skip the first 4gb and slot0. slot0 maps <1gb and is used to back
@@ -139,7 +139,7 @@ static void help(char *name)
exit(0);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
int opt;
@@ -185,6 +185,4 @@ int main(int argc, char *argv[])
}
for_each_guest_mode(run_test, &p);
-
- return 0;
}
@@ -995,7 +995,7 @@ static bool test_loop(const struct test_data *data,
return true;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct test_args targs = {
.tfirst = 0,
@@ -1007,11 +1007,8 @@ int main(int argc, char *argv[])
struct test_result rbestslottime;
int tctr;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
if (!parse_args(argc, argv, &targs))
- return -1;
+ exit(-1);
rbestslottime.slottimens = 0;
for (tctr = targs.tfirst; tctr <= targs.tlast; tctr++) {
@@ -1042,6 +1039,4 @@ int main(int argc, char *argv[])
pr_info("Best slot setup time for the whole test area was %ld.%.9lds\n",
rbestslottime.slot_runtime.tv_sec,
rbestslottime.slot_runtime.tv_nsec);
-
- return 0;
}
@@ -198,16 +198,13 @@ static void calc_min_max_cpu(void)
"Only one usable CPU, task migration not possible");
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int r, i, snapshot;
struct kvm_vm *vm;
struct kvm_vcpu *vcpu;
u32 cpu, rseq_cpu;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
r = sched_getaffinity(0, sizeof(possible_mask), &possible_mask);
TEST_ASSERT(!r, "sched_getaffinity failed, errno = %d (%s)", errno,
strerror(errno));
@@ -277,6 +274,4 @@ int main(int argc, char *argv[])
kvm_vm_free(vm);
rseq_unregister_current_thread();
-
- return 0;
}
@@ -754,14 +754,12 @@ struct testdef {
},
};
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int extension_cap, idx;
TEST_REQUIRE(kvm_has_cap(KVM_CAP_S390_MEM_OP));
- setbuf(stdout, NULL); /* Tell stdout not to buffer its content */
-
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(testlist));
@@ -291,13 +291,11 @@ struct testdef {
{ "clear", test_clear, true },
};
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
bool has_s390_vcpu_resets = kvm_check_cap(KVM_CAP_S390_VCPU_RESETS);
int idx;
- setbuf(stdout, NULL); /* Tell stdout not to buffer its content */
-
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(testlist));
@@ -223,7 +223,7 @@ struct testdef {
{ "clear kvm_dirty_regs bits", test_clear_kvm_dirty_regs_bits },
};
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -231,9 +231,6 @@ int main(int argc, char *argv[])
TEST_REQUIRE(kvm_has_cap(KVM_CAP_SYNC_REGS));
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(testlist));
@@ -201,7 +201,7 @@ static void guest_code(void)
ksft_test_result_pass("" #stage "\n"); \
})
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -386,15 +386,12 @@ static void test_add_max_memory_regions(void)
kvm_vm_free(vm);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
#ifdef __x86_64__
int i, loops;
#endif
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
#ifdef __x86_64__
/*
* FIXME: the zero-memslot test fails on aarch64 and s390x because
@@ -419,6 +416,4 @@ int main(int argc, char *argv[])
for (i = 0; i < loops; i++)
test_delete_memory_region();
#endif
-
- return 0;
}
@@ -239,7 +239,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu)
}
}
-int main(int ac, char **av)
+void __main(int ac, char *av[])
{
struct kvm_vcpu *vcpus[NR_VCPUS];
struct kvm_vm *vm;
@@ -317,6 +317,4 @@ int main(int ac, char **av)
steal_time_dump(vm, i);
}
}
-
- return 0;
}
@@ -114,7 +114,7 @@ static void enter_guest(struct kvm_vcpu *vcpu)
}
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -294,7 +294,7 @@ void guest_nm_handler(struct ex_regs *regs)
GUEST_SYNC(9);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_regs regs1, regs2;
struct kvm_vcpu *vcpu;
@@ -172,7 +172,7 @@ static void set_cpuid_after_run(struct kvm_vcpu *vcpu)
ent->eax = eax;
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
vm_vaddr_t cpuid_gva;
@@ -47,7 +47,7 @@ static void guest_code(void)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_run *run;
@@ -57,9 +57,6 @@ int main(int argc, char *argv[])
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XSAVE));
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
run = vcpu->run;
@@ -90,5 +87,4 @@ int main(int argc, char *argv[])
done:
kvm_vm_free(vm);
- return 0;
}
@@ -75,7 +75,7 @@ static void vcpu_skip_insn(struct kvm_vcpu *vcpu, int insn_len)
vcpu_regs_set(vcpu, ®s);
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_guest_debug debug;
unsigned long long target_dr6, target_rip;
@@ -209,6 +209,4 @@ int main(void)
TEST_ASSERT(cmd == UCALL_DONE, "UCALL_DONE");
kvm_vm_free(vm);
-
- return 0;
}
@@ -148,7 +148,7 @@ static uint64_t process_ucall(struct kvm_vcpu *vcpu)
return uc.cmd;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -156,9 +156,6 @@ int main(int argc, char *argv[])
uint64_t *hva;
int rc;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
TEST_REQUIRE(kvm_has_cap(KVM_CAP_SMALLER_MAXPHYADDR));
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
@@ -188,6 +185,4 @@ int main(int argc, char *argv[])
TEST_ASSERT(process_ucall(vcpu) == UCALL_DONE, "Expected UCALL_DONE");
kvm_vm_free(vm);
-
- return 0;
}
@@ -196,7 +196,7 @@ static struct kvm_vcpu *save_restore_vm(struct kvm_vm *vm,
return vcpu;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t vmx_pages_gva = 0;
@@ -154,7 +154,7 @@ static void test_fix_hypercall_disabled(void)
enter_guest(vcpu);
}
-int main(void)
+void __main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & KVM_X86_QUIRK_FIX_HYPERCALL_INSN);
@@ -15,7 +15,7 @@
#include "kvm_util.h"
#include "processor.h"
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
const struct kvm_msr_list *feature_list;
int i;
@@ -203,7 +203,7 @@ static void host_check_tsc_msr_rdtsc(struct kvm_vcpu *vcpu)
(t2 - t1) * 100, (r2 - r1) * 1000000000 / tsc_freq);
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -128,15 +128,12 @@ void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu)
" it should have: %d %d", !vcpu ? "KVM" : "vCPU", ret, errno);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vm *vm;
const struct kvm_cpuid2 *hv_cpuid_entries;
struct kvm_vcpu *vcpu;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_CPUID));
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
@@ -172,6 +169,4 @@ int main(int argc, char *argv[])
out:
kvm_vm_free(vm);
-
- return 0;
}
@@ -632,7 +632,7 @@ static void guest_test_hcalls_access(void)
}
}
-int main(void)
+void __main(int argc, char *argv[])
{
pr_info("Testing access to Hyper-V specific MSRs\n");
guest_test_msrs_access();
@@ -117,7 +117,7 @@ static void __attribute__((__flatten__)) guest_code(struct svm_test_data *svm)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t nested_gva = 0;
@@ -171,7 +171,7 @@ static void check_clocksource(void)
fclose(fp);
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
vm_vaddr_t pvti_gva;
@@ -136,7 +136,7 @@ static void enter_guest(struct kvm_vcpu *vcpu)
}
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -11,7 +11,7 @@
#define MAX_VCPU_ID 2
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vm *vm;
int ret;
@@ -40,5 +40,4 @@ int main(int argc, char *argv[])
TEST_ASSERT(ret < 0, "Creating vCPU with ID > MAX_VCPU_ID should fail");
kvm_vm_free(vm);
- return 0;
}
@@ -89,7 +89,7 @@ int get_warnings_count(void)
return warnings;
}
-int main(void)
+void __main(int argc, char *argv[])
{
int warnings_before, warnings_after;
@@ -116,6 +116,4 @@ int main(void)
warnings_after = get_warnings_count();
TEST_ASSERT(warnings_before == warnings_after,
"Warnings found in kernel. Run 'dmesg' to inspect them.");
-
- return 0;
}
@@ -60,7 +60,7 @@ static void guest_code(void)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
uint64_t disabled_quirks;
struct kvm_vcpu *vcpu;
@@ -127,5 +127,4 @@ int main(int argc, char *argv[])
done:
kvm_vm_free(vm);
- return 0;
}
@@ -225,7 +225,7 @@ static void help(char *name)
exit(0);
}
-int main(int argc, char **argv)
+void __main(int argc, char *argv[])
{
int reclaim_period_ms = 0, token = 0, opt;
bool reboot_permissions = false;
@@ -263,7 +263,5 @@ int main(int argc, char **argv)
run_test(reclaim_period_ms, false, reboot_permissions);
run_test(reclaim_period_ms, true, reboot_permissions);
-
- return 0;
}
@@ -66,15 +66,12 @@ static void test_msr_platform_info_disabled(struct kvm_vcpu *vcpu)
exit_reason_str(run->exit_reason));
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
uint64_t msr_platform_info;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
TEST_REQUIRE(kvm_has_cap(KVM_CAP_MSR_PLATFORM_INFO));
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
@@ -87,6 +84,4 @@ int main(int argc, char *argv[])
vcpu_set_msr(vcpu, MSR_PLATFORM_INFO, msr_platform_info);
kvm_vm_free(vm);
-
- return 0;
}
@@ -441,15 +441,12 @@ static bool use_amd_pmu(void)
is_zen3(entry->eax));
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
void (*guest_code)(void);
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
TEST_REQUIRE(kvm_has_cap(KVM_CAP_PMU_EVENT_FILTER));
TEST_REQUIRE(use_intel_pmu() || use_amd_pmu());
@@ -474,6 +471,4 @@ int main(int argc, char *argv[])
kvm_vm_free(vm);
test_pmu_config_disable(guest_code);
-
- return 0;
}
@@ -119,7 +119,7 @@ static void check_set_bsp_busy(void)
kvm_vm_free(vm);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_has_cap(KVM_CAP_SET_BOOT_CPU_ID));
@@ -74,7 +74,7 @@ static uint64_t calc_supported_cr4_feature_bits(void)
return cr4;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_sregs sregs;
struct kvm_vcpu *vcpu;
@@ -82,9 +82,6 @@ int main(int argc, char *argv[])
uint64_t cr4;
int rc;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
/*
* Create a dummy VM, specifically to avoid doing KVM_SET_CPUID2, and
* use it to verify all supported CR4 bits can be set prior to defining
@@ -132,6 +129,4 @@ int main(int argc, char *argv[])
sregs.apic_base);
kvm_vm_free(vm);
-
- return 0;
}
@@ -393,7 +393,7 @@ static void test_sev_move_copy(void)
kvm_vm_free(sev_vm);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_has_cap(KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM));
TEST_REQUIRE(kvm_has_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM));
@@ -417,5 +417,4 @@ int main(int argc, char *argv[])
test_sev_mirror(/* es= */ true);
test_sev_mirror_parameters();
}
- return 0;
}
@@ -126,7 +126,7 @@ void inject_smi(struct kvm_vcpu *vcpu)
vcpu_events_set(vcpu, &events);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t nested_gva = 0;
@@ -151,7 +151,7 @@ static void __attribute__((__flatten__)) guest_code(void *arg)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t nested_gva = 0;
@@ -82,7 +82,7 @@ static void l1_guest_code(struct svm_test_data *svm)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_run *run;
@@ -123,5 +123,4 @@ int main(int argc, char *argv[])
}
done:
kvm_vm_free(vm);
- return 0;
}
@@ -192,11 +192,8 @@ static void run_test(bool is_nmi)
kvm_vm_free(vm);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
TEST_ASSERT(kvm_cpu_has(X86_FEATURE_NRIPS),
@@ -206,6 +203,4 @@ int main(int argc, char *argv[])
run_test(false);
run_test(true);
-
- return 0;
}
@@ -33,7 +33,7 @@ static void l1_guest_code(struct svm_test_data *svm)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
vm_vaddr_t svm_gva;
@@ -70,5 +70,4 @@ int main(int argc, char *argv[])
}
done:
kvm_vm_free(vm);
- return 0;
}
@@ -80,7 +80,7 @@ static void compare_vcpu_events(struct kvm_vcpu_events *left,
#define TEST_SYNC_FIELDS (KVM_SYNC_X86_REGS|KVM_SYNC_X86_SREGS|KVM_SYNC_X86_EVENTS)
#define INVALID_SYNC_FIELD 0x80000000
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -90,9 +90,6 @@ int main(int argc, char *argv[])
struct kvm_vcpu_events events;
int rv, cap;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
cap = kvm_check_cap(KVM_CAP_SYNC_REGS);
TEST_REQUIRE((cap & TEST_SYNC_FIELDS) == TEST_SYNC_FIELDS);
TEST_REQUIRE(!(cap & INVALID_SYNC_FIELD));
@@ -235,6 +232,4 @@ int main(int argc, char *argv[])
regs.rbx);
kvm_vm_free(vm);
-
- return 0;
}
@@ -38,7 +38,7 @@ void l1_guest_code(struct vmx_pages *vmx)
GUEST_DONE();
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_run *run;
@@ -86,7 +86,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu, int stage)
}
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -148,6 +148,4 @@ int main(void)
ASSERT_EQ(rounded_host_rdmsr(MSR_IA32_TSC_ADJUST), val - HOST_ADJUST);
kvm_vm_free(vm);
-
- return 0;
}
@@ -91,7 +91,7 @@ static void *run_vcpu(void *_cpu_nr)
return (void *)failures;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_has_cap(KVM_CAP_VM_TSC_CONTROL));
@@ -114,5 +114,4 @@ int main(int argc, char *argv[])
TEST_ASSERT(!failures, "TSC sync failed");
pthread_spin_destroy(&create_lock);
kvm_vm_free(vm);
- return 0;
}
@@ -275,7 +275,7 @@ static struct kvm_vcpu *create_vcpu_with_mce_cap(struct kvm_vm *vm, uint32_t vcp
return vcpu;
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct thread_params params;
struct kvm_vm *vm;
@@ -48,7 +48,7 @@ static void guest_code(void)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_regs regs;
@@ -56,9 +56,6 @@ int main(int argc, char *argv[])
struct kvm_vm *vm;
struct ucall uc;
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
run = vcpu->run;
@@ -104,5 +101,4 @@ int main(int argc, char *argv[])
}
kvm_vm_free(vm);
- return 0;
}
@@ -733,16 +733,11 @@ static void test_msr_permission_bitmap(void)
kvm_vm_free(vm);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
- /* Tell stdout not to buffer its content */
- setbuf(stdout, NULL);
-
test_msr_filter_allow();
test_msr_filter_deny();
test_msr_permission_bitmap();
-
- return 0;
}
@@ -69,7 +69,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
unsigned long apic_access_addr = ~0ul;
vm_vaddr_t vmx_pages_gva;
@@ -127,5 +127,4 @@ int main(int argc, char *argv[])
}
}
kvm_vm_free(vm);
- return 0;
}
@@ -45,7 +45,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
GUEST_ASSERT(0);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t vmx_pages_gva;
struct kvm_vcpu *vcpu;
@@ -64,7 +64,7 @@ void l1_guest_code(struct vmx_pages *vmx)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t vmx_pages_gva = 0;
struct vmx_pages *vmx;
@@ -106,7 +106,7 @@ static void sigalrm_handler(int sig)
}
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -50,7 +50,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t vmx_pages_gva;
struct kvm_sregs sregs;
@@ -67,7 +67,7 @@ static void vmx_save_restore_msrs_test(struct kvm_vcpu *vcpu)
vmx_fixed1_msr_test(vcpu, MSR_IA32_VMX_VMFUNC, -1ull);
}
-int main(void)
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -137,7 +137,7 @@ static void stable_tsc_check_supported(void)
exit(KSFT_SKIP);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
@@ -227,5 +227,4 @@ int main(int argc, char *argv[])
done:
kvm_vm_free(vm);
- return 0;
}
@@ -51,7 +51,7 @@ static void guest_code(void)
wrmsr(MSR_IA32_PERF_CAPABILITIES, PMU_CAP_LBR_FMT);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
const struct kvm_cpuid_entry2 *entry_a_0;
struct kvm_vm *vm;
@@ -151,7 +151,7 @@ void guest_code(struct vmx_pages *vmx_pages)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t vmx_pages_gva = 0;
@@ -243,7 +243,7 @@ void test_vmx_nested_state(struct kvm_vcpu *vcpu)
free(state);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct kvm_vm *vm;
struct kvm_nested_state state;
@@ -296,5 +296,4 @@ int main(int argc, char *argv[])
test_vmx_nested_state(vcpu);
kvm_vm_free(vm);
- return 0;
}
@@ -122,7 +122,7 @@ static void report(int64_t val)
val, val / TSC_ADJUST_VALUE, val % TSC_ADJUST_VALUE);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
vm_vaddr_t vmx_pages_gva;
struct kvm_vcpu *vcpu;
@@ -161,5 +161,4 @@ int main(int argc, char *argv[])
done:
kvm_vm_free(vm);
- return 0;
}
@@ -391,7 +391,7 @@ void get_cmdline_args(int argc, char *argv[], int *run_secs,
}
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
int r;
int wait_secs;
@@ -490,6 +490,4 @@ int main(int argc, char *argv[])
data->migrations_attempted, data->migrations_completed);
kvm_vm_free(vm);
-
- return 0;
}
@@ -130,7 +130,7 @@ static void test_icr(struct xapic_vcpu *x)
__test_icr(x, -1ull & ~APIC_DM_FIXED_MASK);
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct xapic_vcpu x = {
.vcpu = NULL,
@@ -352,7 +352,7 @@ static void handle_alrm(int sig)
TEST_FAIL("IRQ delivery timed out");
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
struct timespec min_ts, max_ts, vm_ts;
struct kvm_vm *vm;
@@ -876,5 +876,4 @@ int main(int argc, char *argv[])
"runstate times don't add up");
}
kvm_vm_free(vm);
- return 0;
}
@@ -78,7 +78,7 @@ static void guest_code(void)
GUEST_DONE();
}
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
unsigned int xen_caps;
struct kvm_vcpu *vcpu;
@@ -141,5 +141,4 @@ int main(int argc, char *argv[])
}
done:
kvm_vm_free(vm);
- return 0;
}
@@ -14,7 +14,7 @@
#define MSR_BITS 64
-int main(int argc, char *argv[])
+void __main(int argc, char *argv[])
{
bool xss_in_msr_list;
struct kvm_vm *vm;
Consolidate common startup logic in one place by implementing a single main function for all selftests within kvm_util.c. This allows moving logic like: /* Tell stdout not to buffer its content */ setbuf(stdout, NULL); to a single file for all selftests. This will also allow any required setup at entry in future to be done in common main function. More context is discussed at: https://lore.kernel.org/lkml/Ywa9T+jKUpaHLu%2Fl@google.com/ Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Vishal Annapurve <vannapurve@google.com> --- tools/testing/selftests/kvm/aarch64/arch_timer.c | 5 +---- tools/testing/selftests/kvm/aarch64/debug-exceptions.c | 2 +- tools/testing/selftests/kvm/aarch64/get-reg-list.c | 2 +- tools/testing/selftests/kvm/aarch64/hypercalls.c | 4 +--- tools/testing/selftests/kvm/aarch64/psci_test.c | 2 +- .../testing/selftests/kvm/aarch64/vcpu_width_config.c | 2 +- tools/testing/selftests/kvm/aarch64/vgic_init.c | 2 +- tools/testing/selftests/kvm/aarch64/vgic_irq.c | 5 +---- .../testing/selftests/kvm/access_tracking_perf_test.c | 4 +--- tools/testing/selftests/kvm/demand_paging_test.c | 7 ++----- tools/testing/selftests/kvm/dirty_log_perf_test.c | 4 +--- tools/testing/selftests/kvm/dirty_log_test.c | 4 +--- tools/testing/selftests/kvm/hardware_disable_test.c | 2 +- tools/testing/selftests/kvm/include/kvm_util_base.h | 5 +++++ tools/testing/selftests/kvm/kvm_binary_stats_test.c | 3 +-- tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 4 +--- tools/testing/selftests/kvm/kvm_page_table_test.c | 4 +--- tools/testing/selftests/kvm/lib/kvm_util.c | 10 ++++++++++ tools/testing/selftests/kvm/lib/sparsebit.c | 2 +- tools/testing/selftests/kvm/max_guest_memory_test.c | 2 +- .../selftests/kvm/memslot_modification_stress_test.c | 4 +--- tools/testing/selftests/kvm/memslot_perf_test.c | 9 ++------- tools/testing/selftests/kvm/rseq_test.c | 7 +------ tools/testing/selftests/kvm/s390x/memop.c | 4 +--- tools/testing/selftests/kvm/s390x/resets.c | 4 +--- tools/testing/selftests/kvm/s390x/sync_regs_test.c | 5 +---- tools/testing/selftests/kvm/s390x/tprot.c | 2 +- tools/testing/selftests/kvm/set_memory_region_test.c | 7 +------ tools/testing/selftests/kvm/steal_time.c | 4 +--- .../testing/selftests/kvm/system_counter_offset_test.c | 2 +- tools/testing/selftests/kvm/x86_64/amx_test.c | 2 +- tools/testing/selftests/kvm/x86_64/cpuid_test.c | 2 +- .../testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c | 6 +----- tools/testing/selftests/kvm/x86_64/debug_regs.c | 4 +--- .../testing/selftests/kvm/x86_64/emulator_error_test.c | 7 +------ tools/testing/selftests/kvm/x86_64/evmcs_test.c | 2 +- .../testing/selftests/kvm/x86_64/fix_hypercall_test.c | 2 +- .../selftests/kvm/x86_64/get_msr_index_features.c | 2 +- tools/testing/selftests/kvm/x86_64/hyperv_clock.c | 2 +- tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 7 +------ tools/testing/selftests/kvm/x86_64/hyperv_features.c | 2 +- tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c | 2 +- tools/testing/selftests/kvm/x86_64/kvm_clock_test.c | 2 +- tools/testing/selftests/kvm/x86_64/kvm_pv_test.c | 2 +- .../testing/selftests/kvm/x86_64/max_vcpuid_cap_test.c | 3 +-- tools/testing/selftests/kvm/x86_64/mmio_warning_test.c | 4 +--- .../testing/selftests/kvm/x86_64/monitor_mwait_test.c | 3 +-- .../testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 4 +--- .../testing/selftests/kvm/x86_64/platform_info_test.c | 7 +------ .../selftests/kvm/x86_64/pmu_event_filter_test.c | 7 +------ tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c | 2 +- tools/testing/selftests/kvm/x86_64/set_sregs_test.c | 7 +------ tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c | 3 +-- tools/testing/selftests/kvm/x86_64/smm_test.c | 2 +- tools/testing/selftests/kvm/x86_64/state_test.c | 2 +- tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c | 3 +-- .../selftests/kvm/x86_64/svm_nested_soft_inject_test.c | 7 +------ tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c | 3 +-- tools/testing/selftests/kvm/x86_64/sync_regs_test.c | 7 +------ .../selftests/kvm/x86_64/triple_fault_event_test.c | 2 +- tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c | 4 +--- tools/testing/selftests/kvm/x86_64/tsc_scaling_sync.c | 3 +-- .../testing/selftests/kvm/x86_64/ucna_injection_test.c | 2 +- tools/testing/selftests/kvm/x86_64/userspace_io_test.c | 6 +----- .../selftests/kvm/x86_64/userspace_msr_exit_test.c | 7 +------ .../selftests/kvm/x86_64/vmx_apic_access_test.c | 3 +-- .../selftests/kvm/x86_64/vmx_close_while_nested_test.c | 2 +- .../testing/selftests/kvm/x86_64/vmx_dirty_log_test.c | 2 +- .../x86_64/vmx_exception_with_invalid_guest_state.c | 2 +- .../kvm/x86_64/vmx_invalid_nested_guest_state.c | 2 +- tools/testing/selftests/kvm/x86_64/vmx_msrs_test.c | 2 +- .../selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c | 3 +-- tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 2 +- .../selftests/kvm/x86_64/vmx_preemption_timer_test.c | 2 +- .../selftests/kvm/x86_64/vmx_set_nested_state_test.c | 3 +-- .../testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c | 3 +-- tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c | 4 +--- tools/testing/selftests/kvm/x86_64/xapic_state_test.c | 2 +- tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c | 3 +-- tools/testing/selftests/kvm/x86_64/xen_vmcall_test.c | 3 +-- tools/testing/selftests/kvm/x86_64/xss_msr_test.c | 2 +- 81 files changed, 96 insertions(+), 199 deletions(-)