KVM: selftests: Overhaul APIs, purge VCPU_ID
Subsystems (4)
Sean Christopherson
reviewerRFC PATCH 97/105 KVM: selftests: Convert kvm_binary_stats_test away from VCPU_ID
In reply to Sean Christopherson--- .../testing/selftests/kvm/kvm_binary_stats_test.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
tools/testing/selftests/kvm/kvm_binary_stats_test.c +10 -4
@@ -172,9 +172,9 @@ static void vm_stats_test(struct kvm_vm *vm)TEST_ASSERT (fcntl (stats_fd,F_GETFD ) ==-1 ,"Stats fd not freed" ); } -static void vcpu_stats_test (struct kvm_vm *vm,int vcpu_id) +static void vcpu_stats_test (struct kvm_vcpu *vcpu) { -int stats_fd =vcpu_get_stats_fd (vm, vcpu_id); +int stats_fd =vcpu_get_stats_fd (vcpu->vm, vcpu->id);stats_test (stats_fd);close (stats_fd);
@@ -195,6 +195,7 @@ static void vcpu_stats_test(struct kvm_vm *vm, int vcpu_id)int main (int argc,char *argv[]) {int i, j; +struct kvm_vcpu ***vcpus;struct kvm_vm **vms;int max_vm =DEFAULT_NUM_VM ;int max_vcpu =DEFAULT_NUM_VCPU ;
@@ -220,17 +221,22 @@ int main(int argc, char *argv[])/* Create VMs and VCPUs */ vms =malloc (sizeof (vms[0 ]) * max_vm);TEST_ASSERT (vms,"Allocate memory for storing VM pointers" ); + + vcpus =malloc (sizeof (struct kvm_vcpu *) * max_vm * max_vcpu); +TEST_ASSERT (vcpus,"Allocate memory for storing vCPU pointers" ); +for (i =0 ; i < max_vm; ++i) { vms[i] =vm_create (DEFAULT_GUEST_PHY_PAGES ); +for (j =0 ; j < max_vcpu; ++j) -__vm_vcpu_add (vms[i], j); + vcpus[i][j] =__vm_vcpu_add (vms[i], j); }/* Check stats read for every VM and VCPU */ for (i =0 ; i < max_vm; ++i) {vm_stats_test (vms[i]);for (j =0 ; j < max_vcpu; ++j) -vcpu_stats_test (vms[i], j); +vcpu_stats_test (vcpus[i][j]); }for (i =0 ; i < max_vm; ++i)
Signature · 1 line
2.35.1.723.g4982287a31-goog
Sean Christopherson
reviewerRFC PATCH 98/105 KVM: selftests: Convert get-reg-list away from VCPU_ID
In reply to Sean Christopherson--- tools/testing/selftests/kvm/aarch64/get-reg-list.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
tools/testing/selftests/kvm/aarch64/get-reg-list.c +7 -6
@@ -406,6 +406,7 @@ static void run_test(struct vcpu_config *c)struct kvm_vcpu_init init = { .target =-1 , };int new_regs =0 , missing_regs =0 , i, n;int failed_get =0 , failed_set =0 , failed_reject =0 ; +struct kvm_vcpu *vcpu;struct kvm_vm *vm;struct reg_sublist *s;
@@ -413,10 +414,10 @@ static void run_test(struct vcpu_config *c) vm =vm_create (DEFAULT_GUEST_PHY_PAGES );prepare_vcpu_init (c, &init); -aarch64_vcpu_add (vm,0 , &init,NULL ); -finalize_vcpu (vm,0 , c); + vcpu =aarch64_vcpu_add (vm,0 , &init,NULL ); +finalize_vcpu (vm, vcpu->id, c); - reg_list =vcpu_get_reg_list (vm,0 ); + reg_list =vcpu_get_reg_list (vm, vcpu->id);if (fixup_core_regs)core_reg_fixup ();
@@ -452,7 +453,7 @@ static void run_test(struct vcpu_config *c)bool reject_reg = false;int ret; - ret =__vcpu_ioctl (vm,0 ,KVM_GET_ONE_REG , ®); + ret =__vcpu_ioctl (vm, vcpu->id,KVM_GET_ONE_REG , ®);if (ret) {printf ("%s: Failed to get " ,config_name (c));print_reg (c, reg.id);
@@ -464,7 +465,7 @@ static void run_test(struct vcpu_config *c)for_each_sublist (c, s) {if (s->rejects_set &&find_reg (s->rejects_set, s->rejects_set_n, reg.id)) { reject_reg = true; - ret =__vcpu_ioctl (vm,0 ,KVM_SET_ONE_REG , ®); + ret =__vcpu_ioctl (vm, vcpu->id,KVM_SET_ONE_REG , ®);if (ret !=-1 || errno !=EPERM ) {printf ("%s: Failed to reject (ret=%d, errno=%d) " ,config_name (c), ret, errno);print_reg (c, reg.id);
@@ -476,7 +477,7 @@ static void run_test(struct vcpu_config *c) }if (!reject_reg) { - ret =__vcpu_ioctl (vm,0 ,KVM_SET_ONE_REG , ®); + ret =__vcpu_ioctl (vm, vcpu->id,KVM_SET_ONE_REG , ®);if (ret) {printf ("%s: Failed to set " ,config_name (c));print_reg (c, reg.id);
Signature · 1 line
2.35.1.723.g4982287a31-goog
Sean Christopherson
reviewerRFC PATCH 99/105 KVM: selftests: Stop conflating vCPU index and ID in perf tests
In reply to Sean Christopherson--- .../selftests/kvm/access_tracking_perf_test.c | 81 ++++++++++--------- .../selftests/kvm/demand_paging_test.c | 36 ++++----- .../selftests/kvm/dirty_log_perf_test.c | 39 ++++----- .../selftests/kvm/include/perf_test_util.h | 5 +- .../selftests/kvm/lib/perf_test_util.c | 79 +++++++++--------- .../kvm/memslot_modification_stress_test.c | 10 +-- 6 files changed, 129 insertions(+), 121 deletions(-)
tools/testing/selftests/kvm/access_tracking_perf_test.c +41 -40
@@ -74,7 +74,7 @@ struct test_params {uint64_t vcpu_memory_bytes;/* The number of vCPUs to create in the VM. */ -int vcpus; +int nr_vcpus; };static uint64_t pread_uint64 (int fd,const char *filename,uint64_t index)
@@ -127,10 +127,12 @@ static void mark_page_idle(int page_idle_fd, uint64_t pfn) "Set page_idle bits for PFN 0x%" PRIx64, pfn); } -static void mark_vcpu_memory_idle (struct kvm_vm *vm,int vcpu_id) +static void mark_vcpu_memory_idle (struct kvm_vm *vm, +struct perf_test_vcpu_args *vcpu_args) { -uint64_t base_gva = perf_test_args.vcpu_args[vcpu_id].gva; -uint64_t pages = perf_test_args.vcpu_args[vcpu_id].pages; +int vcpu_idx = vcpu_args->vcpu_idx; +uint64_t base_gva = vcpu_args->gva; +uint64_t pages = vcpu_args->pages;uint64_t page;uint64_t still_idle =0 ;uint64_t no_pfn =0 ;
@@ -138,7 +140,7 @@ static void mark_vcpu_memory_idle(struct kvm_vm *vm, int vcpu_id)int pagemap_fd;/* If vCPUs are using an overlapping region, let vCPU 0 mark it idle. */ -if (overlap_memory_access && vcpu_id) +if (overlap_memory_access && vcpu_idx)return ; page_idle_fd =open ("/sys/kernel/mm/page_idle/bitmap" ,O_RDWR );
@@ -170,7 +172,7 @@ static void mark_vcpu_memory_idle(struct kvm_vm *vm, int vcpu_id)*/ TEST_ASSERT (no_pfn < pages /100 ,"vCPU %d: No PFN for %" PRIu64" out of %" PRIu64" pages." , - vcpu_id, no_pfn, pages); + vcpu_idx, no_pfn, pages);/* * Test that at least 90% of memory has been marked idle (the rest might
@@ -183,17 +185,16 @@ static void mark_vcpu_memory_idle(struct kvm_vm *vm, int vcpu_id)TEST_ASSERT (still_idle < pages /10 ,"vCPU%d: Too many pages still idle (%" PRIu64" out of %" PRIu64").\n" , - vcpu_id, still_idle, pages); + vcpu_idx, still_idle, pages);close (page_idle_fd);close (pagemap_fd); } -static void assert_ucall (struct kvm_vm *vm,uint32_t vcpu_id, -uint64_t expected_ucall) +static void assert_ucall (struct kvm_vcpu *vcpu,uint64_t expected_ucall) {struct ucall uc; -uint64_t actual_ucall =get_ucall (vm, vcpu_id, &uc); +uint64_t actual_ucall =get_ucall (vcpu->vm, vcpu->id, &uc);TEST_ASSERT (expected_ucall == actual_ucall, "Guest exited unexpectedly (expected ucall %" PRIu64
@@ -217,28 +218,29 @@ static bool spin_wait_for_next_iteration(int *current_iteration)static void vcpu_thread_main (struct perf_test_vcpu_args *vcpu_args) { +struct kvm_vcpu *vcpu = vcpu_args->vcpu;struct kvm_vm *vm = perf_test_args.vm; -int vcpu_id = vcpu_args->vcpu_id; +int vcpu_idx = vcpu_args->vcpu_idx;int current_iteration =0 ;while (spin_wait_for_next_iteration (¤t_iteration)) {switch (READ_ONCE (iteration_work)) {case ITERATION_ACCESS_MEMORY : -vcpu_run (vm, vcpu_id); -assert_ucall (vm, vcpu_id,UCALL_SYNC ); +vcpu_run (vm, vcpu->id); +assert_ucall (vcpu,UCALL_SYNC );break ;case ITERATION_MARK_IDLE : -mark_vcpu_memory_idle (vm, vcpu_id); +mark_vcpu_memory_idle (vm, vcpu_args);break ; }; - vcpu_last_completed_iteration[vcpu_id] = current_iteration; + vcpu_last_completed_iteration[vcpu_idx] = current_iteration; } } -static void spin_wait_for_vcpu (int vcpu_id,int target_iteration) +static void spin_wait_for_vcpu (int vcpu_idx,int target_iteration) { -while (READ_ONCE (vcpu_last_completed_iteration[vcpu_id]) != +while (READ_ONCE (vcpu_last_completed_iteration[vcpu_idx]) != target_iteration) {continue ; }
@@ -250,12 +252,11 @@ enum access_type { ACCESS_WRITE, }; -static void run_iteration (struct kvm_vm *vm,int vcpus,const char *description) +static void run_iteration (struct kvm_vm *vm,int nr_vcpus,const char *description) {struct timespec ts_start;struct timespec ts_elapsed; -int next_iteration; -int vcpu_id; +int next_iteration, i;/* Kick off the vCPUs by incrementing iteration. */ next_iteration = ++iteration;
@@ -263,23 +264,23 @@ static void run_iteration(struct kvm_vm *vm, int vcpus, const char *description)clock_gettime (CLOCK_MONOTONIC , &ts_start);/* Wait for all vCPUs to finish the iteration. */ -for (vcpu_id =0 ; vcpu_id < vcpus; vcpu_id++) -spin_wait_for_vcpu (vcpu_id, next_iteration); +for (i =0 ; i < nr_vcpus; i++) +spin_wait_for_vcpu (i, next_iteration); ts_elapsed =timespec_elapsed (ts_start);pr_info ("%-30s: %ld.%09lds\n" , description, ts_elapsed.tv_sec, ts_elapsed.tv_nsec); } -static void access_memory (struct kvm_vm *vm,int vcpus,enum access_type access, -const char *description) +static void access_memory (struct kvm_vm *vm,int nr_vcpus, +enum access_type access,const char *description) {perf_test_set_wr_fract (vm, (access ==ACCESS_READ ) ?INT_MAX :1 ); iteration_work =ITERATION_ACCESS_MEMORY ; -run_iteration (vm, vcpus, description); +run_iteration (vm, nr_vcpus, description); } -static void mark_memory_idle (struct kvm_vm *vm,int vcpus) +static void mark_memory_idle (struct kvm_vm *vm,int nr_vcpus) {/* * Even though this parallelizes the work across vCPUs, this is still a
@@ -289,37 +290,37 @@ static void mark_memory_idle(struct kvm_vm *vm, int vcpus)*/ pr_debug ("Marking VM memory idle (slow)...\n" ); iteration_work =ITERATION_MARK_IDLE ; -run_iteration (vm, vcpus,"Mark memory idle" ); +run_iteration (vm, nr_vcpus,"Mark memory idle" ); }static void run_test (enum vm_guest_mode mode,void *arg) {struct test_params *params = arg;struct kvm_vm *vm; -int vcpus = params->vcpus; +int nr_vcpus = params->nr_vcpus; - vm =perf_test_create_vm (mode, vcpus, params->vcpu_memory_bytes,1 , + vm =perf_test_create_vm (mode, nr_vcpus, params->vcpu_memory_bytes,1 , params->backing_src, !overlap_memory_access); -perf_test_start_vcpu_threads (vcpus, vcpu_thread_main); +perf_test_start_vcpu_threads (nr_vcpus, vcpu_thread_main);pr_info ("\n" ); -access_memory (vm, vcpus,ACCESS_WRITE ,"Populating memory" ); +access_memory (vm, nr_vcpus,ACCESS_WRITE ,"Populating memory" );/* As a control, read and write to the populated memory first. */ -access_memory (vm, vcpus,ACCESS_WRITE ,"Writing to populated memory" ); -access_memory (vm, vcpus,ACCESS_READ ,"Reading from populated memory" ); +access_memory (vm, nr_vcpus,ACCESS_WRITE ,"Writing to populated memory" ); +access_memory (vm, nr_vcpus,ACCESS_READ ,"Reading from populated memory" );/* Repeat on memory that has been marked as idle. */ -mark_memory_idle (vm, vcpus); -access_memory (vm, vcpus,ACCESS_WRITE ,"Writing to idle memory" ); -mark_memory_idle (vm, vcpus); -access_memory (vm, vcpus,ACCESS_READ ,"Reading from idle memory" ); +mark_memory_idle (vm, nr_vcpus); +access_memory (vm, nr_vcpus,ACCESS_WRITE ,"Writing to idle memory" ); +mark_memory_idle (vm, nr_vcpus); +access_memory (vm, nr_vcpus,ACCESS_READ ,"Reading from idle memory" );/* Set done to signal the vCPU threads to exit */ done = true; -perf_test_join_vcpu_threads (vcpus); +perf_test_join_vcpu_threads (nr_vcpus);perf_test_destroy_vm (vm); }
@@ -347,7 +348,7 @@ int main(int argc, char *argv[])struct test_params params = { .backing_src =DEFAULT_VM_MEM_SRC , .vcpu_memory_bytes =DEFAULT_PER_VCPU_MEM_SIZE , - .vcpus =1 , + .nr_vcpus =1 , };int page_idle_fd;int opt;
@@ -363,7 +364,7 @@ int main(int argc, char *argv[]) params.vcpu_memory_bytes =parse_size (optarg);break ;case 'v' : - params.vcpus =atoi (optarg); + params.nr_vcpus =atoi (optarg);break ;case 'o' : overlap_memory_access = true;
tools/testing/selftests/kvm/demand_paging_test.c +17 -19
@@ -44,28 +44,27 @@ static char *guest_data_prototype;static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) { -int ret; -int vcpu_id = vcpu_args->vcpu_id; +struct kvm_vcpu *vcpu = vcpu_args->vcpu;struct kvm_vm *vm = perf_test_args.vm; -struct kvm_run *run; +int vcpu_idx = vcpu_args->vcpu_idx; +struct kvm_run *run = vcpu->run;struct timespec start;struct timespec ts_diff; - - run =vcpu_state (vm, vcpu_id); +int ret;clock_gettime (CLOCK_MONOTONIC , &start);/* Let the guest access its memory */ - ret =_vcpu_run (vm, vcpu_id); + ret =_vcpu_run (vm, vcpu->id);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret); -if (get_ucall (vm, vcpu_id,NULL ) !=UCALL_SYNC ) { +if (get_ucall (vm, vcpu->id,NULL ) !=UCALL_SYNC ) {TEST_ASSERT (false,"Invalid guest sync status: exit_reason=%s\n" ,exit_reason_str (run->exit_reason)); } ts_diff =timespec_elapsed (start); -PER_VCPU_DEBUG ("vCPU %d execution time: %ld.%.9lds\n" , vcpu_id, +PER_VCPU_DEBUG ("vCPU %d execution time: %ld.%.9lds\n" , vcpu_idx, ts_diff.tv_sec, ts_diff.tv_nsec); }
@@ -285,8 +284,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)struct timespec ts_diff;int *pipefds =NULL ;struct kvm_vm *vm; -int vcpu_id; -int r; +int r, i; vm =perf_test_create_vm (mode, nr_vcpus, guest_percpu_mem_size,1 , p->src_type, p->partition_vcpu_memory_access);
@@ -309,12 +307,12 @@ static void run_test(enum vm_guest_mode mode, void *arg) pipefds =malloc (sizeof (int ) * nr_vcpus *2 );TEST_ASSERT (pipefds,"Unable to allocate memory for pipefd" ); -for (vcpu_id =0 ; vcpu_id < nr_vcpus; vcpu_id++) { +for (i =0 ; i < nr_vcpus; i++) {struct perf_test_vcpu_args *vcpu_args;void *vcpu_hva;void *vcpu_alias; - vcpu_args = &perf_test_args.vcpu_args[vcpu_id]; + vcpu_args = &perf_test_args.vcpu_args[i];/* Cache the host addresses of the region */ vcpu_hva =addr_gpa2hva (vm, vcpu_args->gpa);
@@ -324,13 +322,13 @@ static void run_test(enum vm_guest_mode mode, void *arg)* Set up user fault fd to handle demand paging * requests. */ - r =pipe2 (&pipefds[vcpu_id *2 ], + r =pipe2 (&pipefds[i *2 ],O_CLOEXEC |O_NONBLOCK );TEST_ASSERT (!r,"Failed to set up pipefd" ); -setup_demand_paging (vm, &uffd_handler_threads[vcpu_id], - pipefds[vcpu_id *2 ], p->uffd_mode, - p->uffd_delay, &uffd_args[vcpu_id], +setup_demand_paging (vm, &uffd_handler_threads[i], + pipefds[i *2 ], p->uffd_mode, + p->uffd_delay, &uffd_args[i], vcpu_hva, vcpu_alias, vcpu_args->pages * perf_test_args.guest_page_size); }
@@ -350,11 +348,11 @@ static void run_test(enum vm_guest_mode mode, void *arg)char c;/* Tell the user fault fd handler threads to quit */ -for (vcpu_id =0 ; vcpu_id < nr_vcpus; vcpu_id++) { - r =write (pipefds[vcpu_id *2 +1 ], &c,1 ); +for (i =0 ; i < nr_vcpus; i++) { + r =write (pipefds[i *2 +1 ], &c,1 );TEST_ASSERT (r ==1 ,"Unable to write to pipefd" ); -pthread_join (uffd_handler_threads[vcpu_id],NULL ); +pthread_join (uffd_handler_threads[i],NULL ); } }
tools/testing/selftests/kvm/dirty_log_perf_test.c +20 -19
@@ -33,44 +33,45 @@ static int vcpu_last_completed_iteration[KVM_MAX_VCPUS];static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) { -int ret; +struct kvm_vcpu *vcpu = vcpu_args->vcpu;struct kvm_vm *vm = perf_test_args.vm; +int vcpu_idx = vcpu_args->vcpu_idx;uint64_t pages_count =0 ;struct kvm_run *run;struct timespec start;struct timespec ts_diff;struct timespec total = (struct timespec ){0 };struct timespec avg; -int vcpu_id = vcpu_args->vcpu_id; +int ret; - run =vcpu_state (vm, vcpu_id); + run = vcpu->run;while (!READ_ONCE (host_quit)) {int current_iteration =READ_ONCE (iteration);clock_gettime (CLOCK_MONOTONIC , &start); - ret =_vcpu_run (vm, vcpu_id); + ret =_vcpu_run (vm, vcpu->id); ts_diff =timespec_elapsed (start);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret); -TEST_ASSERT (get_ucall (vm, vcpu_id,NULL ) ==UCALL_SYNC , +TEST_ASSERT (get_ucall (vm, vcpu->id,NULL ) ==UCALL_SYNC ,"Invalid guest sync status: exit_reason=%s\n" ,exit_reason_str (run->exit_reason)); -pr_debug ("Got sync event from vCPU %d\n" , vcpu_id); - vcpu_last_completed_iteration[vcpu_id] = current_iteration; +pr_debug ("Got sync event from vCPU %d\n" , vcpu_idx); + vcpu_last_completed_iteration[vcpu_idx] = current_iteration;pr_debug ("vCPU %d updated last completed iteration to %d\n" , - vcpu_id, vcpu_last_completed_iteration[vcpu_id]); + vcpu->id, vcpu_last_completed_iteration[vcpu_idx]);if (current_iteration) { pages_count += vcpu_args->pages; total =timespec_add (total, ts_diff);pr_debug ("vCPU %d iteration %d dirty memory time: %ld.%.9lds\n" , - vcpu_id, current_iteration, ts_diff.tv_sec, + vcpu_idx, current_iteration, ts_diff.tv_sec, ts_diff.tv_nsec); }else {pr_debug ("vCPU %d iteration %d populate memory time: %ld.%.9lds\n" , - vcpu_id, current_iteration, ts_diff.tv_sec, + vcpu_idx, current_iteration, ts_diff.tv_sec, ts_diff.tv_nsec); }
@@ -78,9 +79,9 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args) !READ_ONCE(host_quit)) {} } - avg =timespec_div (total, vcpu_last_completed_iteration[vcpu_id]); + avg =timespec_div (total, vcpu_last_completed_iteration[vcpu_idx]);pr_debug ("\nvCPU %d dirtied 0x%lx pages over %d iterations in %ld.%.9lds. (Avg %ld.%.9lds/iteration)\n" , - vcpu_id, pages_count, vcpu_last_completed_iteration[vcpu_id], + vcpu_idx, pages_count, vcpu_last_completed_iteration[vcpu_idx], total.tv_sec, total.tv_nsec, avg.tv_sec, avg.tv_nsec); }
@@ -172,7 +173,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)uint64_t guest_num_pages;uint64_t host_num_pages;uint64_t pages_per_slot; -int vcpu_id;struct timespec start;struct timespec ts_diff;struct timespec get_dirty_log_total = (struct timespec ){0 };
@@ -180,6 +180,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)struct timespec avg;struct kvm_enable_cap cap = {};struct timespec clear_dirty_log_total = (struct timespec ){0 }; +int i; vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size, p->slots, p->backing_src,
@@ -205,15 +206,15 @@ static void run_test(enum vm_guest_mode mode, void *arg) host_quit = false;clock_gettime (CLOCK_MONOTONIC , &start); -for (vcpu_id =0 ; vcpu_id < nr_vcpus; vcpu_id++) - vcpu_last_completed_iteration[vcpu_id] =-1 ; +for (i =0 ; i < nr_vcpus; i++) + vcpu_last_completed_iteration[i] =-1 ;perf_test_start_vcpu_threads (nr_vcpus, vcpu_worker);/* Allow the vCPUs to populate memory */ pr_debug ("Starting iteration %d - Populating\n" , iteration); -for (vcpu_id =0 ; vcpu_id < nr_vcpus; vcpu_id++) { -while (READ_ONCE (vcpu_last_completed_iteration[vcpu_id]) != +for (i =0 ; i < nr_vcpus; i++) { +while (READ_ONCE (vcpu_last_completed_iteration[i]) != iteration) ; }
@@ -238,8 +239,8 @@ static void run_test(enum vm_guest_mode mode, void *arg) iteration++;pr_debug ("Starting iteration %d\n" , iteration); -for (vcpu_id =0 ; vcpu_id < nr_vcpus; vcpu_id++) { -while (READ_ONCE (vcpu_last_completed_iteration[vcpu_id]) +for (i =0 ; i < nr_vcpus; i++) { +while (READ_ONCE (vcpu_last_completed_iteration[i]) != iteration) ; }
tools/testing/selftests/kvm/include/perf_test_util.h +3 -2
@@ -25,7 +25,8 @@ struct perf_test_vcpu_args {uint64_t pages;/* Only used by the host userspace part of the vCPU thread */ -int vcpu_id; +struct kvm_vcpu *vcpu; +int vcpu_idx; };struct perf_test_args {
@@ -39,7 +40,7 @@ struct perf_test_args {extern struct perf_test_args perf_test_args; -struct kvm_vm *perf_test_create_vm (enum vm_guest_mode mode,int vcpus, +struct kvm_vm *perf_test_create_vm (enum vm_guest_mode mode,int nr_vcpus,uint64_t vcpu_memory_bytes,int slots,enum vm_mem_backing_src_type backing_src,bool partition_vcpu_memory_access);
tools/testing/selftests/kvm/lib/perf_test_util.c +43 -36
184 lines not on this page · raw message
tools/testing/selftests/kvm/memslot_modification_stress_test.c +5 -5
@@ -38,19 +38,19 @@ static bool run_vcpus = true;static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) { -int ret; -int vcpu_id = vcpu_args->vcpu_id; +struct kvm_vcpu *vcpu = vcpu_args->vcpu;struct kvm_vm *vm = perf_test_args.vm;struct kvm_run *run; +int ret; - run =vcpu_state (vm, vcpu_id); + run = vcpu->run;/* Let the guest access its memory until a stop signal is received */ while (READ_ONCE (run_vcpus)) { - ret =_vcpu_run (vm, vcpu_id); + ret =_vcpu_run (vm, vcpu->id);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret); -if (get_ucall (vm, vcpu_id,NULL ) ==UCALL_SYNC ) +if (get_ucall (vm, vcpu->id,NULL ) ==UCALL_SYNC )continue ; TEST_ASSERT(false,
Signature · 1 line
2.35.1.723.g4982287a31-goog
Sean Christopherson
reviewerRFC PATCH 100/105 KVM: selftests: Remove vcpu_get() usage from dirty_log_test
In reply to Sean Christopherson--- tools/testing/selftests/kvm/dirty_log_test.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tools/testing/selftests/kvm/dirty_log_test.c +4 -6
@@ -668,7 +668,7 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap) } } -static struct kvm_vm *create_vm (enum vm_guest_mode mode,uint32_t vcpuid, +static struct kvm_vm *create_vm (enum vm_guest_mode mode,struct kvm_vcpu **vcpu,uint64_t extra_mem_pages,void *guest_code) {struct kvm_vm *vm;
@@ -682,7 +682,7 @@ static struct kvm_vm *create_vm(enum vm_guest_mode mode, uint32_t vcpuid,vm_create_irqchip (vm);#endif log_mode_create_vm_done (vm); -vm_vcpu_add (vm, vcpuid, guest_code); + *vcpu =vm_vcpu_add (vm,0 , guest_code);return vm; }
@@ -716,10 +716,8 @@ static void run_test(enum vm_guest_mode mode, void *arg)* (e.g., 64K page size guest will need even less memory for * page tables). */ - vm =create_vm (mode,0 , -2ul << (DIRTY_MEM_BITS -PAGE_SHIFT_4K ), - guest_code); - vcpu =vcpu_get (vm,0 ); + vm =create_vm (mode, &vcpu, +2ul << (DIRTY_MEM_BITS -PAGE_SHIFT_4K ), guest_code); guest_page_size =vm_get_page_size (vm);/*
Signature · 1 line
2.35.1.723.g4982287a31-goog
Sean Christopherson
reviewerRFC PATCH 101/105 KVM: selftests: Require vCPU output array when creating VM with vCPUs
In reply to Sean Christopherson--- tools/testing/selftests/kvm/lib/kvm_util.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tools/testing/selftests/kvm/lib/kvm_util.c +4 -6
@@ -311,10 +311,11 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus struct kvm_vcpu *vcpus[]) {uint64_t vcpu_pages, extra_pg_pages, pages; -struct kvm_vcpu *vcpu;struct kvm_vm *vm;int i; +TEST_ASSERT (!nr_vcpus || vcpus,"Must provide vCPU array" ); +/* Force slot0 memory size not small than DEFAULT_GUEST_PHY_PAGES */ if (slot0_mem_pages <DEFAULT_GUEST_PHY_PAGES ) slot0_mem_pages =DEFAULT_GUEST_PHY_PAGES ;
@@ -342,11 +343,8 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpusvm_create_irqchip (vm);#endif -for (i =0 ; i < nr_vcpus; ++i) { - vcpu =vm_vcpu_add (vm, i, guest_code); -if (vcpus) - vcpus[i] = vcpu; - } +for (i =0 ; i < nr_vcpus; ++i) + vcpus[i] =vm_vcpu_add (vm, i, guest_code);return vm; }
Signature · 1 line
2.35.1.723.g4982287a31-goog
Sean Christopherson
reviewerRFC PATCH 102/105 KVM: selftest: Purge vm+vcpu_id == vcpu silliness
In reply to Sean Christopherson--- .../selftests/kvm/aarch64/arch_timer.c | 10 +- .../selftests/kvm/aarch64/debug-exceptions.c | 8 +- .../selftests/kvm/aarch64/get-reg-list.c | 14 +- .../selftests/kvm/aarch64/psci_cpu_on_test.c | 12 +- .../testing/selftests/kvm/aarch64/vgic_init.c | 2 +- .../testing/selftests/kvm/aarch64/vgic_irq.c | 8 +- .../selftests/kvm/access_tracking_perf_test.c | 4 +- .../selftests/kvm/demand_paging_test.c | 5 +- .../selftests/kvm/dirty_log_perf_test.c | 7 +- tools/testing/selftests/kvm/dirty_log_test.c | 10 +- .../selftests/kvm/hardware_disable_test.c | 2 +- .../selftests/kvm/include/aarch64/processor.h | 14 +- .../selftests/kvm/include/kvm_util_base.h | 192 +++++++++--------- .../selftests/kvm/include/riscv/processor.h | 8 +- .../selftests/kvm/include/ucall_common.h | 2 +- .../selftests/kvm/include/x86_64/evmcs.h | 2 +- .../selftests/kvm/include/x86_64/processor.h | 39 ++-- .../selftests/kvm/kvm_binary_stats_test.c | 2 +- .../selftests/kvm/kvm_page_table_test.c | 7 +- .../selftests/kvm/lib/aarch64/processor.c | 45 ++-- .../testing/selftests/kvm/lib/aarch64/ucall.c | 8 +- tools/testing/selftests/kvm/lib/kvm_util.c | 165 ++++----------- .../selftests/kvm/lib/perf_test_util.c | 2 +- .../selftests/kvm/lib/riscv/processor.c | 95 +++++---- tools/testing/selftests/kvm/lib/riscv/ucall.c | 6 +- .../kvm/lib/s390x/diag318_test_handler.c | 2 +- .../selftests/kvm/lib/s390x/processor.c | 22 +- tools/testing/selftests/kvm/lib/s390x/ucall.c | 8 +- .../selftests/kvm/lib/x86_64/processor.c | 103 ++++------ .../testing/selftests/kvm/lib/x86_64/ucall.c | 10 +- tools/testing/selftests/kvm/lib/x86_64/vmx.c | 4 +- .../kvm/memslot_modification_stress_test.c | 5 +- .../testing/selftests/kvm/memslot_perf_test.c | 4 +- tools/testing/selftests/kvm/rseq_test.c | 4 +- tools/testing/selftests/kvm/s390x/memop.c | 24 +-- tools/testing/selftests/kvm/s390x/resets.c | 28 +-- .../selftests/kvm/s390x/sync_regs_test.c | 22 +- .../selftests/kvm/set_memory_region_test.c | 8 +- tools/testing/selftests/kvm/steal_time.c | 20 +- .../kvm/system_counter_offset_test.c | 13 +- tools/testing/selftests/kvm/x86_64/amx_test.c | 22 +- .../testing/selftests/kvm/x86_64/cpuid_test.c | 14 +- .../kvm/x86_64/cr4_cpuid_sync_test.c | 8 +- .../testing/selftests/kvm/x86_64/debug_regs.c | 30 +-- .../kvm/x86_64/emulator_error_test.c | 20 +- .../testing/selftests/kvm/x86_64/evmcs_test.c | 28 +-- .../selftests/kvm/x86_64/hyperv_clock.c | 14 +- .../selftests/kvm/x86_64/hyperv_cpuid.c | 8 +- .../selftests/kvm/x86_64/hyperv_features.c | 28 +-- .../selftests/kvm/x86_64/hyperv_svm_test.c | 8 +- .../selftests/kvm/x86_64/kvm_clock_test.c | 6 +- .../selftests/kvm/x86_64/kvm_pv_test.c | 10 +- .../selftests/kvm/x86_64/mmu_role_test.c | 10 +- .../selftests/kvm/x86_64/platform_info_test.c | 14 +- .../kvm/x86_64/pmu_event_filter_test.c | 6 +- .../selftests/kvm/x86_64/set_boot_cpu_id.c | 4 +- .../selftests/kvm/x86_64/set_sregs_test.c | 16 +- tools/testing/selftests/kvm/x86_64/smm_test.c | 18 +- .../testing/selftests/kvm/x86_64/state_test.c | 18 +- .../selftests/kvm/x86_64/svm_int_ctl_test.c | 8 +- .../selftests/kvm/x86_64/svm_vmcall_test.c | 6 +- .../selftests/kvm/x86_64/sync_regs_test.c | 36 ++-- .../selftests/kvm/x86_64/tsc_msrs_test.c | 14 +- .../selftests/kvm/x86_64/userspace_io_test.c | 8 +- .../kvm/x86_64/userspace_msr_exit_test.c | 22 +- .../kvm/x86_64/vmx_apic_access_test.c | 6 +- .../kvm/x86_64/vmx_close_while_nested_test.c | 6 +- .../selftests/kvm/x86_64/vmx_dirty_log_test.c | 6 +- .../vmx_exception_with_invalid_guest_state.c | 10 +- .../x86_64/vmx_invalid_nested_guest_state.c | 12 +- .../kvm/x86_64/vmx_nested_tsc_scaling_test.c | 11 +- .../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 20 +- .../kvm/x86_64/vmx_preemption_timer_test.c | 18 +- .../kvm/x86_64/vmx_set_nested_state_test.c | 12 +- .../kvm/x86_64/vmx_tsc_adjust_test.c | 6 +- .../selftests/kvm/x86_64/xapic_ipi_test.c | 10 +- .../selftests/kvm/x86_64/xen_shinfo_test.c | 20 +- .../selftests/kvm/x86_64/xen_vmcall_test.c | 6 +- .../selftests/kvm/x86_64/xss_msr_test.c | 6 +- 79 files changed, 676 insertions(+), 795 deletions(-)
tools/testing/selftests/kvm/aarch64/arch_timer.c +5 -5
@@ -218,14 +218,14 @@ static void *test_vcpu_run(void *arg)struct kvm_vm *vm = vcpu->vm;struct test_vcpu_shared_data *shared_data = &vcpu_shared_data[vcpu_idx]; -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);/* Currently, any exit from guest is an indication of completion */ pthread_mutex_lock (&vcpu_done_map_lock);set_bit (vcpu_idx, vcpu_done_map);pthread_mutex_unlock (&vcpu_done_map_lock); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC :case UCALL_DONE :break ;
@@ -345,9 +345,9 @@ static void test_run(struct kvm_vm *vm)static void test_init_timer_irq (struct kvm_vm *vm) {/* Timer initid should be same for all the vCPUs, so query only vCPU-0 */ -vcpu_device_attr_get (vm, vcpus[0 ]->id,KVM_ARM_VCPU_TIMER_CTRL , +vcpu_device_attr_get (vcpus[0 ],KVM_ARM_VCPU_TIMER_CTRL ,KVM_ARM_VCPU_TIMER_IRQ_PTIMER , &ptimer_irq); -vcpu_device_attr_get (vm, vcpus[0 ]->id,KVM_ARM_VCPU_TIMER_CTRL , +vcpu_device_attr_get (vcpus[0 ],KVM_ARM_VCPU_TIMER_CTRL ,KVM_ARM_VCPU_TIMER_IRQ_VTIMER , &vtimer_irq);sync_global_to_guest (vm, ptimer_irq);
@@ -368,7 +368,7 @@ static struct kvm_vm *test_vm_create(void)vm_install_exception_handler (vm,VECTOR_IRQ_CURRENT , guest_irq_handler);for (i =0 ; i < nr_vcpus; i++) -vcpu_init_descriptor_tables (vm, vcpus[i]->id); +vcpu_init_descriptor_tables (vcpus[i]);ucall_init (vm,NULL );test_init_timer_irq (vm);
tools/testing/selftests/kvm/aarch64/debug-exceptions.c +4 -4
@@ -188,7 +188,7 @@ static int debug_version(struct kvm_vcpu *vcpu) {uint64_t id_aa64dfr0; -get_reg (vcpu->vm, vcpu->id,KVM_ARM64_SYS_REG (SYS_ID_AA64DFR0_EL1 ), &id_aa64dfr0); +get_reg (vcpu,KVM_ARM64_SYS_REG (SYS_ID_AA64DFR0_EL1 ), &id_aa64dfr0);return id_aa64dfr0 &0xf ; }
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])ucall_init (vm,NULL );vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);if (debug_version (vcpu) <6 ) {print_skip ("Armv8 debug architecture not supported." );
@@ -223,9 +223,9 @@ int main(int argc, char *argv[]) ESR_EC_SVC64, guest_svc_handler);for (stage =0 ; stage <7 ; stage++) { -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC : TEST_ASSERT(uc.args[1] == stage, "Stage %d: Unexpected sync ucall, got %lx",
tools/testing/selftests/kvm/aarch64/get-reg-list.c +7 -7
@@ -372,7 +372,7 @@ static void prepare_vcpu_init(struct vcpu_config *c, struct kvm_vcpu_init *init) init->features[s->feature /32 ] |=1 << (s->feature %32 ); } -static void finalize_vcpu (struct kvm_vm *vm,uint32_t vcpuid,struct vcpu_config *c) +static void finalize_vcpu (struct kvm_vcpu *vcpu,struct vcpu_config *c) {struct reg_sublist *s;int feature;
@@ -380,7 +380,7 @@ static void finalize_vcpu(struct kvm_vm *vm, uint32_t vcpuid, struct vcpu_configfor_each_sublist (c, s) {if (s->finalize) { feature = s->feature; -vcpu_ioctl (vm, vcpuid,KVM_ARM_VCPU_FINALIZE , &feature); +vcpu_ioctl (vcpu,KVM_ARM_VCPU_FINALIZE , &feature); } } }
@@ -415,9 +415,9 @@ static void run_test(struct vcpu_config *c) vm =vm_create (DEFAULT_GUEST_PHY_PAGES );prepare_vcpu_init (c, &init); vcpu =aarch64_vcpu_add (vm,0 , &init,NULL ); -finalize_vcpu (vm, vcpu->id, c); +finalize_vcpu (vcpu, c); - reg_list =vcpu_get_reg_list (vm, vcpu->id); + reg_list =vcpu_get_reg_list (vcpu);if (fixup_core_regs)core_reg_fixup ();
@@ -453,7 +453,7 @@ static void run_test(struct vcpu_config *c)bool reject_reg = false;int ret; - ret =__vcpu_ioctl (vm, vcpu->id,KVM_GET_ONE_REG , ®); + ret =__vcpu_ioctl (vcpu,KVM_GET_ONE_REG , ®);if (ret) {printf ("%s: Failed to get " ,config_name (c));print_reg (c, reg.id);
@@ -465,7 +465,7 @@ static void run_test(struct vcpu_config *c)for_each_sublist (c, s) {if (s->rejects_set &&find_reg (s->rejects_set, s->rejects_set_n, reg.id)) { reject_reg = true; - ret =__vcpu_ioctl (vm, vcpu->id,KVM_SET_ONE_REG , ®); + ret =__vcpu_ioctl (vcpu,KVM_SET_ONE_REG , ®);if (ret !=-1 || errno !=EPERM ) {printf ("%s: Failed to reject (ret=%d, errno=%d) " ,config_name (c), ret, errno);print_reg (c, reg.id);
@@ -477,7 +477,7 @@ static void run_test(struct vcpu_config *c) }if (!reject_reg) { - ret =__vcpu_ioctl (vm, vcpu->id,KVM_SET_ONE_REG , ®); + ret =__vcpu_ioctl (vcpu,KVM_SET_ONE_REG , ®);if (ret) {printf ("%s: Failed to set " ,config_name (c));print_reg (c, reg.id);
tools/testing/selftests/kvm/aarch64/psci_cpu_on_test.c +6 -6
@@ -89,11 +89,11 @@ int main(void) init.features[0 ] |= (1 <<KVM_ARM_VCPU_POWER_OFF ); vcpu1 =aarch64_vcpu_add (vm,1 , &init, guest_main); -get_reg (vm, vcpu1->id,KVM_ARM64_SYS_REG (SYS_MPIDR_EL1 ), &target_mpidr); -vcpu_args_set (vm, vcpu0->id,1 , target_mpidr &MPIDR_HWID_BITMASK ); -vcpu_run (vm, vcpu0->id); +get_reg (vcpu1,KVM_ARM64_SYS_REG (SYS_MPIDR_EL1 ), &target_mpidr); +vcpu_args_set (vcpu0,1 , target_mpidr &MPIDR_HWID_BITMASK ); +vcpu_run (vcpu0); -switch (get_ucall (vm, vcpu0->id, &uc)) { +switch (get_ucall (vcpu0, &uc)) {case UCALL_DONE :break ;case UCALL_ABORT :
@@ -104,8 +104,8 @@ int main(void)TEST_FAIL ("Unhandled ucall: %lu" , uc.cmd); } -get_reg (vm, vcpu1->id,ARM64_CORE_REG (regs.pc), &obs_pc); -get_reg (vm, vcpu1->id,ARM64_CORE_REG (regs.regs[0 ]), &obs_x0); +get_reg (vcpu1,ARM64_CORE_REG (regs.pc), &obs_pc); +get_reg (vcpu1,ARM64_CORE_REG (regs.regs[0 ]), &obs_x0); TEST_ASSERT(obs_pc == CPU_ON_ENTRY_ADDR, "unexpected target cpu pc: %lx (expected: %lx)",
tools/testing/selftests/kvm/aarch64/vgic_init.c +1 -1
@@ -53,7 +53,7 @@ static int run_vcpu(struct kvm_vcpu *vcpu) {ucall_init (vcpu->vm,NULL ); -return __vcpu_run (vcpu->vm, vcpu->id) ? -errno :0 ; +return __vcpu_run (vcpu) ? -errno :0 ; } static struct vm_gic vm_gic_create_with_vcpus(uint32_t gic_dev_type,
tools/testing/selftests/kvm/aarch64/vgic_irq.c +4 -4
@@ -756,10 +756,10 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)ucall_init (vm,NULL );vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);/* Setup the guest args page (so it gets the args). */ -vcpu_args_set (vm, vcpu->id,1 , args); +vcpu_args_set (vcpu,1 , args); gic_fd =vgic_v3_setup (vm,1 , nr_irqs,GICD_BASE_GPA ,GICR_BASE_GPA );
@@ -768,9 +768,9 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split) guest_irq_handlers[args.eoi_split][args.level_sensitive]);while (1 ) { -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC :kvm_inject_get_call (vm, &uc, &inject_args);run_guest_cmd (vcpu, gic_fd, &inject_args, &args);
tools/testing/selftests/kvm/access_tracking_perf_test.c +2 -2
@@ -194,7 +194,7 @@ static void mark_vcpu_memory_idle(struct kvm_vm *vm,static void assert_ucall (struct kvm_vcpu *vcpu,uint64_t expected_ucall) {struct ucall uc; -uint64_t actual_ucall =get_ucall (vcpu->vm, vcpu->id, &uc); +uint64_t actual_ucall =get_ucall (vcpu, &uc);TEST_ASSERT (expected_ucall == actual_ucall, "Guest exited unexpectedly (expected ucall %" PRIu64
@@ -226,7 +226,7 @@ static void vcpu_thread_main(struct perf_test_vcpu_args *vcpu_args)while (spin_wait_for_next_iteration (¤t_iteration)) {switch (READ_ONCE (iteration_work)) {case ITERATION_ACCESS_MEMORY : -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);assert_ucall (vcpu,UCALL_SYNC );break ;case ITERATION_MARK_IDLE :
tools/testing/selftests/kvm/demand_paging_test.c +2 -3
@@ -45,7 +45,6 @@ static char *guest_data_prototype;static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) {struct kvm_vcpu *vcpu = vcpu_args->vcpu; -struct kvm_vm *vm = perf_test_args.vm;int vcpu_idx = vcpu_args->vcpu_idx;struct kvm_run *run = vcpu->run;struct timespec start;
@@ -55,9 +54,9 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args)clock_gettime (CLOCK_MONOTONIC , &start);/* Let the guest access its memory */ - ret =_vcpu_run (vm, vcpu->id); + ret =_vcpu_run (vcpu);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret); -if (get_ucall (vm, vcpu->id,NULL ) !=UCALL_SYNC ) { +if (get_ucall (vcpu,NULL ) !=UCALL_SYNC ) {TEST_ASSERT (false,"Invalid guest sync status: exit_reason=%s\n" ,exit_reason_str (run->exit_reason));
tools/testing/selftests/kvm/dirty_log_perf_test.c +3 -4
@@ -34,7 +34,6 @@ static int vcpu_last_completed_iteration[KVM_MAX_VCPUS];static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) {struct kvm_vcpu *vcpu = vcpu_args->vcpu; -struct kvm_vm *vm = perf_test_args.vm;int vcpu_idx = vcpu_args->vcpu_idx;uint64_t pages_count =0 ;struct kvm_run *run;
@@ -50,18 +49,18 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args)int current_iteration =READ_ONCE (iteration);clock_gettime (CLOCK_MONOTONIC , &start); - ret =_vcpu_run (vm, vcpu->id); + ret =_vcpu_run (vcpu); ts_diff =timespec_elapsed (start);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret); -TEST_ASSERT (get_ucall (vm, vcpu->id,NULL ) ==UCALL_SYNC , +TEST_ASSERT (get_ucall (vcpu,NULL ) ==UCALL_SYNC ,"Invalid guest sync status: exit_reason=%s\n" ,exit_reason_str (run->exit_reason));pr_debug ("Got sync event from vCPU %d\n" , vcpu_idx); vcpu_last_completed_iteration[vcpu_idx] = current_iteration;pr_debug ("vCPU %d updated last completed iteration to %d\n" , - vcpu->id, vcpu_last_completed_iteration[vcpu_idx]); + vcpu_idx, vcpu_last_completed_iteration[vcpu_idx]);if (current_iteration) { pages_count += vcpu_args->pages;
tools/testing/selftests/kvm/dirty_log_test.c +5 -5
@@ -258,7 +258,7 @@ static void default_after_vcpu_run(struct kvm_vcpu *vcpu, int ret, int err)TEST_ASSERT (ret ==0 || (ret ==-1 && err ==EINTR ),"vcpu run failed: errno=%d" , err); -TEST_ASSERT (get_ucall (vcpu->vm, vcpu->id,NULL ) ==UCALL_SYNC , +TEST_ASSERT (get_ucall (vcpu,NULL ) ==UCALL_SYNC ,"Invalid guest sync status: exit_reason=%s\n" ,exit_reason_str (run->exit_reason));
@@ -349,7 +349,7 @@ static void dirty_ring_collect_dirty_pages(struct kvm_vcpu *vcpu, int slot, }/* Only have one vcpu */ - count =dirty_ring_collect_one (vcpu_map_dirty_ring (vcpu->vm, vcpu->id), + count =dirty_ring_collect_one (vcpu_map_dirty_ring (vcpu), slot, bitmap, num_pages, &fetch_index); cleared =kvm_vm_reset_dirty_ring (vcpu->vm);
@@ -372,7 +372,7 @@ static void dirty_ring_after_vcpu_run(struct kvm_vcpu *vcpu, int ret, int err)struct kvm_run *run = vcpu->run;/* A ucall-sync or ring-full event is allowed */ -if (get_ucall (vcpu->vm, vcpu->id,NULL ) ==UCALL_SYNC ) { +if (get_ucall (vcpu,NULL ) ==UCALL_SYNC ) {/* We should allow this to continue */ ; } else if (run->exit_reason == KVM_EXIT_DIRTY_RING_FULL ||
@@ -524,7 +524,7 @@ static void *vcpu_worker(void *data) sigmask->len =8 ;pthread_sigmask (0 ,NULL , sigset);sigdelset (sigset,SIG_IPI ); -vcpu_ioctl (vm, vcpu->id,KVM_SET_SIGNAL_MASK , sigmask); +vcpu_ioctl (vcpu,KVM_SET_SIGNAL_MASK , sigmask);sigemptyset (sigset);sigaddset (sigset,SIG_IPI );
@@ -536,7 +536,7 @@ static void *vcpu_worker(void *data)generate_random_array (guest_array,TEST_PAGES_PER_LOOP ); pages_count +=TEST_PAGES_PER_LOOP ;/* Let the guest dirty the random pages */ - ret =__vcpu_run (vm, vcpu->id); + ret =__vcpu_run (vcpu);if (ret ==-1 && errno ==EINTR ) {int sig =-1 ;sigwait (sigset, &sig);
tools/testing/selftests/kvm/hardware_disable_test.c +1 -1
@@ -39,7 +39,7 @@ static void *run_vcpu(void *arg)struct kvm_vcpu *vcpu = arg;struct kvm_run *run = vcpu->run; -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu); TEST_ASSERT(false, "%s: exited with reason %d: %s\n", __func__, run->exit_reason,
tools/testing/selftests/kvm/include/aarch64/processor.h +8 -6
@@ -47,23 +47,25 @@#define MPIDR_HWID_BITMASK (0xff00fffffful) -static inline void get_reg (struct kvm_vm *vm,uint32_t vcpuid,uint64_t id,uint64_t *addr) +static inline void get_reg (struct kvm_vcpu *vcpu,uint64_t id,uint64_t *addr) {struct kvm_one_reg reg; + reg.id = id; reg.addr = (uint64_t )addr; -vcpu_ioctl (vm, vcpuid,KVM_GET_ONE_REG , ®); +vcpu_ioctl (vcpu,KVM_GET_ONE_REG , ®); } -static inline void set_reg (struct kvm_vm *vm,uint32_t vcpuid,uint64_t id,uint64_t val) +static inline void set_reg (struct kvm_vcpu *vcpu,uint64_t id,uint64_t val) {struct kvm_one_reg reg; + reg.id = id; reg.addr = (uint64_t )&val; -vcpu_ioctl (vm, vcpuid,KVM_SET_ONE_REG , ®); +vcpu_ioctl (vcpu,KVM_SET_ONE_REG , ®); } -void aarch64_vcpu_setup (struct kvm_vm *vm,uint32_t vcpuid,struct kvm_vcpu_init *init); +void aarch64_vcpu_setup (struct kvm_vcpu *vcpu,struct kvm_vcpu_init *init);struct kvm_vcpu *aarch64_vcpu_add (struct kvm_vm *vm,uint32_t vcpu_id,struct kvm_vcpu_init *init,void *guest_code);
@@ -117,7 +119,7 @@ void aarch64_get_supported_page_sizes(uint32_t ipa, bool *ps4k, bool *ps16k, bool *ps64k);void vm_init_descriptor_tables (struct kvm_vm *vm); -void vcpu_init_descriptor_tables (struct kvm_vm *vm,uint32_t vcpuid); +void vcpu_init_descriptor_tables (struct kvm_vcpu *vcpu);typedef void (*handler_fn )(struct ex_regs *); void vm_install_exception_handler(struct kvm_vm *vm,
tools/testing/selftests/kvm/include/kvm_util_base.h +91 -101
325 lines not on this page · raw message
tools/testing/selftests/kvm/include/riscv/processor.h +4 -4
@@ -38,24 +38,24 @@ static inline uint64_t __kvm_reg_id(uint64_t type, uint64_t idx, KVM_REG_RISCV_TIMER_REG(name), \ KVM_REG_SIZE_U64) -static inline void get_reg (struct kvm_vm *vm,uint32_t vcpuid,uint64_t id, +static inline void get_reg (struct kvm_vcpu *vcpu,uint64_t id,unsigned long *addr) {struct kvm_one_reg reg; reg.id = id; reg.addr = (unsigned long )addr; -vcpu_get_reg (vm, vcpuid, ®); +vcpu_get_reg (vcpu, ®); } -static inline void set_reg (struct kvm_vm *vm,uint32_t vcpuid,uint64_t id, +static inline void set_reg (struct kvm_vcpu *vcpu,uint64_t id,unsigned long val) {struct kvm_one_reg reg; reg.id = id; reg.addr = (unsigned long )&val; -vcpu_set_reg (vm, vcpuid, ®); +vcpu_set_reg (vcpu, ®); }/* L3 index Bit[47:39] */
tools/testing/selftests/kvm/include/ucall_common.h +1 -1
@@ -26,7 +26,7 @@ struct ucall {void ucall_init (struct kvm_vm *vm,void *arg);void ucall_uninit (struct kvm_vm *vm);void ucall (uint64_t cmd,int nargs, ...); -uint64_t get_ucall (struct kvm_vm *vm,uint32_t vcpu_id,struct ucall *uc); +uint64_t get_ucall (struct kvm_vcpu *vcpu,struct ucall *uc);#define GUEST_SYNC_ARGS (stage, arg1, arg2, arg3, arg4) \ ucall(UCALL_SYNC, 6, "hello", stage, arg1, arg2, arg3, arg4)
tools/testing/selftests/kvm/include/x86_64/evmcs.h +1 -1
@@ -241,7 +241,7 @@ struct hv_enlightened_vmcs {extern struct hv_enlightened_vmcs *current_evmcs;extern struct hv_vp_assist_page *current_vp_assist; -int vcpu_enable_evmcs (struct kvm_vm *vm,int vcpu_id); +int vcpu_enable_evmcs (struct kvm_vcpu *vcpu);static inline int enable_vp_assist (uint64_t vp_assist_pa,void *vp_assist) {
tools/testing/selftests/kvm/include/x86_64/processor.h +19 -20
@@ -383,26 +383,25 @@ static inline unsigned int x86_model(unsigned int eax)return ((eax >>12 ) &0xf0 ) | ((eax >>4 ) &0x0f ); } -struct kvm_x86_state *vcpu_save_state (struct kvm_vm *vm,uint32_t vcpuid); -void vcpu_load_state (struct kvm_vm *vm,uint32_t vcpuid, -struct kvm_x86_state *state); +struct kvm_x86_state *vcpu_save_state (struct kvm_vcpu *vcpu); +void vcpu_load_state (struct kvm_vcpu *vcpu,struct kvm_x86_state *state);void kvm_x86_state_cleanup (struct kvm_x86_state *state);struct kvm_msr_list *kvm_get_msr_index_list (void );uint64_t kvm_get_feature_msr (uint64_t msr_index);struct kvm_cpuid2 *kvm_get_supported_cpuid (void ); -struct kvm_cpuid2 *vcpu_get_cpuid (struct kvm_vm *vm,uint32_t vcpuid); +struct kvm_cpuid2 *vcpu_get_cpuid (struct kvm_vcpu *vcpu); -static inline int __vcpu_set_cpuid (struct kvm_vm *vm,uint32_t vcpuid, +static inline int __vcpu_set_cpuid (struct kvm_vcpu *vcpu,struct kvm_cpuid2 *cpuid) { -return __vcpu_ioctl (vm, vcpuid,KVM_SET_CPUID2 , cpuid); +return __vcpu_ioctl (vcpu,KVM_SET_CPUID2 , cpuid); } -static inline void vcpu_set_cpuid (struct kvm_vm *vm,uint32_t vcpuid, +static inline void vcpu_set_cpuid (struct kvm_vcpu *vcpu,struct kvm_cpuid2 *cpuid) { -vcpu_ioctl (vm, vcpuid,KVM_SET_CPUID2 , cpuid); +vcpu_ioctl (vcpu,KVM_SET_CPUID2 , cpuid); } struct kvm_cpuid_entry2 *
@@ -414,14 +413,13 @@ kvm_get_supported_cpuid_entry(uint32_t function)return kvm_get_supported_cpuid_index (function,0 ); } -uint64_t vcpu_get_msr (struct kvm_vm *vm,uint32_t vcpuid,uint64_t msr_index); -int _vcpu_set_msr (struct kvm_vm *vm,uint32_t vcpuid,uint64_t msr_index, -uint64_t msr_value); +uint64_t vcpu_get_msr (struct kvm_vcpu *vcpu,uint64_t msr_index); +int _vcpu_set_msr (struct kvm_vcpu *vcpu,uint64_t msr_index,uint64_t msr_value); -static inline void vcpu_set_msr (struct kvm_vm *vm,uint32_t vcpuid, -uint64_t msr_index,uint64_t msr_value) +static inline void vcpu_set_msr (struct kvm_vcpu *vcpu,uint64_t msr_index, +uint64_t msr_value) { -int r =_vcpu_set_msr (vm, vcpuid, msr_index, msr_value); +int r =_vcpu_set_msr (vcpu, msr_index, msr_value);TEST_ASSERT (r ==1 ,KVM_IOCTL_ERROR (KVM_SET_MSRS , r)); }
@@ -445,13 +443,14 @@ struct ex_regs { };void vm_init_descriptor_tables (struct kvm_vm *vm); -void vcpu_init_descriptor_tables (struct kvm_vm *vm,uint32_t vcpuid); +void vcpu_init_descriptor_tables (struct kvm_vcpu *vcpu);void vm_install_exception_handler (struct kvm_vm *vm,int vector,void (*handler)(struct ex_regs *)); -uint64_t vm_get_page_table_entry (struct kvm_vm *vm,int vcpuid,uint64_t vaddr); -void vm_set_page_table_entry (struct kvm_vm *vm,int vcpuid,uint64_t vaddr, -uint64_t pte); +uint64_t vm_get_page_table_entry (struct kvm_vm *vm,struct kvm_vcpu *vcpu, +uint64_t vaddr); +void vm_set_page_table_entry (struct kvm_vm *vm,struct kvm_vcpu *vcpu, +uint64_t vaddr,uint64_t pte);/* * get_cpuid() - find matching CPUID entry and return pointer to it.
@@ -471,8 +470,8 @@ uint64_t kvm_hypercall(uint64_t nr, uint64_t a0, uint64_t a1, uint64_t a2, uint64_t a3);struct kvm_cpuid2 *kvm_get_supported_hv_cpuid (void ); -void vcpu_set_hv_cpuid (struct kvm_vm *vm,uint32_t vcpuid); -struct kvm_cpuid2 *vcpu_get_supported_hv_cpuid (struct kvm_vm *vm,uint32_t vcpuid); +void vcpu_set_hv_cpuid (struct kvm_vcpu *vcpu); +struct kvm_cpuid2 *vcpu_get_supported_hv_cpuid (struct kvm_vcpu *vcpu);void vm_xsave_req_perm (int bit);enum x86_page_size {
tools/testing/selftests/kvm/kvm_binary_stats_test.c +1 -1
@@ -174,7 +174,7 @@ static void vm_stats_test(struct kvm_vm *vm)static void vcpu_stats_test (struct kvm_vcpu *vcpu) { -int stats_fd =vcpu_get_stats_fd (vcpu->vm, vcpu->id); +int stats_fd =vcpu_get_stats_fd (vcpu);stats_test (stats_fd);close (stats_fd);
tools/testing/selftests/kvm/kvm_page_table_test.c +3 -4
@@ -184,7 +184,6 @@ static void guest_code(bool do_write)static void *vcpu_worker (void *data) { -struct kvm_vm *vm = test_args.vm;struct kvm_vcpu *vcpu = data;bool do_write = !(vcpu->id %2 );struct timespec start;
@@ -192,7 +191,7 @@ static void *vcpu_worker(void *data)enum test_stage stage;int ret; -vcpu_args_set (vm, vcpu->id,1 , do_write); +vcpu_args_set (vcpu,1 , do_write);while (!READ_ONCE (host_quit)) { ret =sem_wait (&test_stage_updated);
@@ -202,11 +201,11 @@ static void *vcpu_worker(void *data)return NULL ;clock_gettime (CLOCK_MONOTONIC_RAW , &start); - ret =_vcpu_run (vm, vcpu->id); + ret =_vcpu_run (vcpu); ts_diff =timespec_elapsed (start);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret); -TEST_ASSERT (get_ucall (vm, vcpu->id,NULL ) ==UCALL_SYNC , +TEST_ASSERT (get_ucall (vcpu,NULL ) ==UCALL_SYNC ,"Invalid guest sync status: exit_reason=%s\n" ,exit_reason_str (vcpu->run->exit_reason));
tools/testing/selftests/kvm/lib/aarch64/processor.c +23 -22
113 lines not on this page · raw message
tools/testing/selftests/kvm/lib/aarch64/ucall.c +4 -4
@@ -88,9 +88,9 @@ void ucall(uint64_t cmd, int nargs, ...) *ucall_exit_mmio_addr = (vm_vaddr_t)&uc; } -uint64_t get_ucall (struct kvm_vm *vm,uint32_t vcpu_id,struct ucall *uc) +uint64_t get_ucall (struct kvm_vcpu *vcpu,struct ucall *uc) { -struct kvm_run *run =vcpu_state (vm, vcpu_id); +struct kvm_run *run = vcpu->run;struct ucall ucall = {};if (uc)
@@ -103,9 +103,9 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)TEST_ASSERT (run->mmio.is_write && run->mmio.len ==8 ,"Unexpected ucall exit mmio address access" );memcpy (&gva, run->mmio.data,sizeof (gva)); -memcpy (&ucall,addr_gva2hva (vm, gva),sizeof (ucall)); +memcpy (&ucall,addr_gva2hva (vcpu->vm, gva),sizeof (ucall)); -vcpu_run_complete_io (vm, vcpu_id); +vcpu_run_complete_io (vcpu);if (uc)memcpy (uc, &ucall,sizeof (ucall)); }
tools/testing/selftests/kvm/lib/kvm_util.c +40 -125
247 lines not on this page · raw message
tools/testing/selftests/kvm/lib/perf_test_util.c +1 -1
@@ -98,7 +98,7 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int nr_vcpus, vcpu_args->gpa = pta->gpa; } -vcpu_args_set (vm, vcpus[i]->id,1 , i); +vcpu_args_set (vcpus[i],1 , i); pr_debug("Added VCPU %d with test mem gpa [%lx, %lx)\n", i, vcpu_args->gpa, vcpu_args->gpa +
tools/testing/selftests/kvm/lib/riscv/processor.c +46 -49
147 lines not on this page · raw message
tools/testing/selftests/kvm/lib/riscv/ucall.c +3 -3
@@ -63,9 +63,9 @@ void ucall(uint64_t cmd, int nargs, ...) 0, 0, 0, 0, 0); } -uint64_t get_ucall (struct kvm_vm *vm,uint32_t vcpu_id,struct ucall *uc) +uint64_t get_ucall (struct kvm_vcpu *vcpu,struct ucall *uc) { -struct kvm_run *run =vcpu_state (vm, vcpu_id); +struct kvm_run *run = vcpu->run;struct ucall ucall = {};if (uc)
@@ -77,7 +77,7 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)memcpy (&ucall,addr_gva2hva (vm, run->riscv_sbi.args[0 ]),sizeof (ucall)); -vcpu_run_complete_io (vm, vcpu_id); +vcpu_run_complete_io (vcpu);if (uc)memcpy (uc, &ucall,sizeof (ucall)); }
tools/testing/selftests/kvm/lib/s390x/diag318_test_handler.c +1 -1
@@ -32,7 +32,7 @@ static uint64_t diag318_handler(void)uint64_t diag318_info; vm =vm_create_with_one_vcpu (&vcpu, guest_code); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu); run = vcpu->run; TEST_ASSERT(run->exit_reason == KVM_EXIT_S390_SIEIC,
tools/testing/selftests/kvm/lib/s390x/processor.c +10 -12
@@ -173,23 +173,23 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id, vcpu =__vm_vcpu_add (vm, vcpu_id);/* Setup guest registers */ -vcpu_regs_get (vm, vcpu_id, ®s); +vcpu_regs_get (vcpu, ®s); regs.gprs[15 ] = stack_vaddr + (DEFAULT_STACK_PGS *getpagesize ()) -160 ; -vcpu_regs_set (vm, vcpu_id, ®s); +vcpu_regs_set (vcpu, ®s); -vcpu_sregs_get (vm, vcpu_id, &sregs); +vcpu_sregs_get (vcpu, &sregs); sregs.crs[0 ] |=0x00040000 ;/* Enable floating point regs */ sregs.crs[1 ] = vm->pgd |0xf ;/* Primary region table */ -vcpu_sregs_set (vm, vcpu_id, &sregs); +vcpu_sregs_set (vcpu, &sregs); - run =vcpu_state (vm, vcpu_id); + run = vcpu->run; run->psw_mask =0x0400000180000000ULL ;/* DAT enabled + 64 bit mode */ run->psw_addr = (uintptr_t )guest_code;return vcpu; } -void vcpu_args_set (struct kvm_vm *vm,uint32_t vcpuid,unsigned int num, ...) +void vcpu_args_set (struct kvm_vcpu *vcpu,unsigned int num, ...) {va_list ap;struct kvm_regs regs;
@@ -200,23 +200,21 @@ void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...) num);va_start (ap, num); -vcpu_regs_get (vm, vcpuid, ®s); +vcpu_regs_get (vcpu, ®s);for (i =0 ; i < num; i++) regs.gprs[i +2 ] =va_arg (ap, uint64_t); -vcpu_regs_set (vm, vcpuid, ®s); +vcpu_regs_set (vcpu, ®s);va_end (ap); } -void vcpu_arch_dump (FILE *stream,struct kvm_vm *vm,uint32_t vcpuid,uint8_t indent) +void vcpu_arch_dump (FILE *stream,struct kvm_vcpu *vcpu,uint8_t indent) { -struct kvm_vcpu *vcpu =vcpu_get (vm, vcpuid); -fprintf (stream,"%*spstate: psw: 0x%.16llx:0x%.16llx\n" , indent,"" , vcpu->run->psw_mask, vcpu->run->psw_addr); } -void assert_on_unhandled_exception (struct kvm_vm *vm,uint32_t vcpuid) +void assert_on_unhandled_exception (struct kvm_vcpu *vcpu) { }
tools/testing/selftests/kvm/lib/s390x/ucall.c +4 -4
@@ -33,9 +33,9 @@ void ucall(uint64_t cmd, int nargs, ...) asmvolatile ("diag 0,%0,0x501" : :"a" (&uc) :"memory" ); } -uint64_t get_ucall (struct kvm_vm *vm,uint32_t vcpu_id,struct ucall *uc) +uint64_t get_ucall (struct kvm_vcpu *vcpu,struct ucall *uc) { -struct kvm_run *run =vcpu_state (vm, vcpu_id); +struct kvm_run *run = vcpu->run;struct ucall ucall = {};if (uc)
@@ -47,10 +47,10 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc) (run->s390_sieic.ipb >> 16) == 0x501) {int reg = run->s390_sieic.ipa &0xf ; -memcpy (&ucall,addr_gva2hva (vm, run->s.regs.gprs[reg]), +memcpy (&ucall,addr_gva2hva (vcpu->vm, run->s.regs.gprs[reg]),sizeof (ucall)); -vcpu_run_complete_io (vm, vcpu_id); +vcpu_run_complete_io (vcpu);if (uc)memcpy (uc, &ucall,sizeof (ucall)); }
tools/testing/selftests/kvm/lib/x86_64/processor.c +44 -59
283 lines not on this page · raw message
tools/testing/selftests/kvm/lib/x86_64/ucall.c +5 -5
@@ -35,9 +35,9 @@ void ucall(uint64_t cmd, int nargs, ...) : : [port] "d" (UCALL_PIO_PORT), "D" (&uc) : "rax", "memory"); } -uint64_t get_ucall (struct kvm_vm *vm,uint32_t vcpu_id,struct ucall *uc) +uint64_t get_ucall (struct kvm_vcpu *vcpu,struct ucall *uc) { -struct kvm_run *run =vcpu_state (vm, vcpu_id); +struct kvm_run *run = vcpu->run;struct ucall ucall = {};if (uc)
@@ -46,11 +46,11 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)if (run->exit_reason ==KVM_EXIT_IO && run->io.port ==UCALL_PIO_PORT ) {struct kvm_regs regs; -vcpu_regs_get (vm, vcpu_id, ®s); -memcpy (&ucall,addr_gva2hva (vm, (vm_vaddr_t )regs.rdi), +vcpu_regs_get (vcpu, ®s); +memcpy (&ucall,addr_gva2hva (vcpu->vm, (vm_vaddr_t )regs.rdi),sizeof (ucall)); -vcpu_run_complete_io (vm, vcpu_id); +vcpu_run_complete_io (vcpu);if (uc)memcpy (uc, &ucall,sizeof (ucall)); }
tools/testing/selftests/kvm/lib/x86_64/vmx.c +2 -2
@@ -42,7 +42,7 @@ struct eptPageTablePointer { uint64_t address:40; uint64_t reserved_63_52:12; }; -int vcpu_enable_evmcs (struct kvm_vm *vm,int vcpu_id) +int vcpu_enable_evmcs (struct kvm_vcpu *vcpu) {uint16_t evmcs_ver;
@@ -51,7 +51,7 @@ int vcpu_enable_evmcs(struct kvm_vm *vm, int vcpu_id) .args[0] = (unsigned long)&evmcs_ver }; -vcpu_ioctl (vm, vcpu_id,KVM_ENABLE_CAP , &enable_evmcs_cap); +vcpu_ioctl (vcpu,KVM_ENABLE_CAP , &enable_evmcs_cap);/* KVM should return supported EVMCS version range */ TEST_ASSERT(((evmcs_ver >> 8) >= (evmcs_ver & 0xff)) &&
tools/testing/selftests/kvm/memslot_modification_stress_test.c +2 -3
@@ -39,7 +39,6 @@ static bool run_vcpus = true;static void vcpu_worker (struct perf_test_vcpu_args *vcpu_args) {struct kvm_vcpu *vcpu = vcpu_args->vcpu; -struct kvm_vm *vm = perf_test_args.vm;struct kvm_run *run;int ret;
@@ -47,10 +46,10 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args)/* Let the guest access its memory until a stop signal is received */ while (READ_ONCE (run_vcpus)) { - ret =_vcpu_run (vm, vcpu->id); + ret =_vcpu_run (vcpu);TEST_ASSERT (ret ==0 ,"vcpu_run failed: %d\n" , ret); -if (get_ucall (vm, vcpu->id,NULL ) ==UCALL_SYNC ) +if (get_ucall (vcpu,NULL ) ==UCALL_SYNC )continue ; TEST_ASSERT(false,
tools/testing/selftests/kvm/memslot_perf_test.c +2 -2
@@ -146,9 +146,9 @@ static void *vcpu_worker(void *__data)struct ucall uc;while (1 ) { -vcpu_run (data->vm, vcpu->id); +vcpu_run (vcpu); -switch (get_ucall (data->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC : TEST_ASSERT(uc.args[1] == 0, "Unexpected sync ucall, got %lx",
tools/testing/selftests/kvm/rseq_test.c +2 -2
@@ -233,8 +233,8 @@ int main(int argc, char *argv[])pthread_create (&migration_thread,NULL , migration_worker,0 );for (i =0 ; !done; i++) { -vcpu_run (vm, vcpu->id); -TEST_ASSERT (get_ucall (vm, vcpu->id,NULL ) ==UCALL_SYNC , +vcpu_run (vcpu); +TEST_ASSERT (get_ucall (vcpu,NULL ) ==UCALL_SYNC ,"Guest failed?" );/*
tools/testing/selftests/kvm/s390x/memop.c +12 -12
@@ -59,10 +59,10 @@ int main(int argc, char *argv[]) ksmo.op =KVM_S390_MEMOP_LOGICAL_WRITE ; ksmo.buf = (uintptr_t )mem1; ksmo.ar =0 ; -vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); +vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);/* Let the guest code copy the first array to the second */ -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu); TEST_ASSERT(run->exit_reason == KVM_EXIT_S390_SIEIC, "Unexpected exit reason: %u (%s)\n", run->exit_reason,
@@ -77,7 +77,7 @@ int main(int argc, char *argv[]) ksmo.op =KVM_S390_MEMOP_LOGICAL_READ ; ksmo.buf = (uintptr_t )mem2; ksmo.ar =0 ; -vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); +vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (!memcmp (mem1, mem2, maxsize),"Memory contents do not match!" );
@@ -89,7 +89,7 @@ int main(int argc, char *argv[]) ksmo.op =KVM_S390_MEMOP_LOGICAL_WRITE ; ksmo.buf = (uintptr_t )mem1; ksmo.ar =0 ; - rv =__vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); + rv =__vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (rv ==-1 && errno ==E2BIG ,"ioctl allows insane sizes" );/* Zero size: */
@@ -99,7 +99,7 @@ int main(int argc, char *argv[]) ksmo.op =KVM_S390_MEMOP_LOGICAL_WRITE ; ksmo.buf = (uintptr_t )mem1; ksmo.ar =0 ; - rv =__vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); + rv =__vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (rv ==-1 && (errno ==EINVAL || errno ==ENOMEM ),"ioctl allows 0 as size" );
@@ -110,7 +110,7 @@ int main(int argc, char *argv[]) ksmo.op =KVM_S390_MEMOP_LOGICAL_WRITE ; ksmo.buf = (uintptr_t )mem1; ksmo.ar =0 ; - rv =__vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); + rv =__vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (rv ==-1 && errno ==EINVAL ,"ioctl allows all flags" );/* Bad operation: */
@@ -120,7 +120,7 @@ int main(int argc, char *argv[]) ksmo.op =-1 ; ksmo.buf = (uintptr_t )mem1; ksmo.ar =0 ; - rv =__vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); + rv =__vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (rv ==-1 && errno ==EINVAL ,"ioctl allows bad operations" );/* Bad guest address: */
@@ -130,7 +130,7 @@ int main(int argc, char *argv[]) ksmo.op =KVM_S390_MEMOP_LOGICAL_WRITE ; ksmo.buf = (uintptr_t )mem1; ksmo.ar =0 ; - rv =__vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); + rv =__vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (rv >0 ,"ioctl does not report bad guest memory access" );/* Bad host address: */
@@ -140,24 +140,24 @@ int main(int argc, char *argv[]) ksmo.op =KVM_S390_MEMOP_LOGICAL_WRITE ; ksmo.buf =0 ; ksmo.ar =0 ; - rv =__vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); + rv =__vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (rv ==-1 && errno ==EFAULT ,"ioctl does not report bad host memory address" );/* Bad access register: */ run->psw_mask &= ~(3UL << (63 -17 )); run->psw_mask |=1UL << (63 -17 );/* Enable AR mode */ -vcpu_run (vm, vcpu->id);/* To sync new state to SIE block */ +vcpu_run (vcpu);/* To sync new state to SIE block */ ksmo.gaddr = (uintptr_t )mem1; ksmo.flags =0 ; ksmo.size = maxsize; ksmo.op =KVM_S390_MEMOP_LOGICAL_WRITE ; ksmo.buf = (uintptr_t )mem1; ksmo.ar =17 ; - rv =__vcpu_ioctl (vm, vcpu->id,KVM_S390_MEM_OP , &ksmo); + rv =__vcpu_ioctl (vcpu,KVM_S390_MEM_OP , &ksmo);TEST_ASSERT (rv ==-1 && errno ==EINVAL ,"ioctl allows ARs > 15" ); run->psw_mask &= ~(3UL << (63 -17 ));/* Disable AR mode */ -vcpu_run (vm, vcpu->id);/* Run to sync new state */ +vcpu_run (vcpu);/* Run to sync new state */ kvm_vm_free (vm);
tools/testing/selftests/kvm/s390x/resets.c +14 -14
@@ -63,7 +63,7 @@ static void test_one_reg(struct kvm_vcpu *vcpu, uint64_t id, uint64_t value) reg.addr = (uintptr_t )&eval_reg; reg.id = id; -vcpu_get_reg (vcpu->vm, vcpu->id, ®); +vcpu_get_reg (vcpu, ®);TEST_ASSERT (eval_reg == value,"value == 0x%lx" , value); }
@@ -74,7 +74,7 @@ static void assert_noirq(struct kvm_vcpu *vcpu) irq_state.len =sizeof (buf); irq_state.buf = (unsigned long )buf; - irqs =__vcpu_ioctl (vcpu->vm, vcpu->id,KVM_S390_GET_IRQ_STATE , &irq_state); + irqs =__vcpu_ioctl (vcpu,KVM_S390_GET_IRQ_STATE , &irq_state);/* * irqs contains the number of retrieved interrupts. Any interrupt * (notably, the emergency call interrupt we have injected) should
@@ -91,13 +91,13 @@ static void assert_clear(struct kvm_vcpu *vcpu)struct kvm_regs regs;struct kvm_fpu fpu; -vcpu_regs_get (vcpu->vm, vcpu->id, ®s); +vcpu_regs_get (vcpu, ®s);TEST_ASSERT (!memcmp (®s.gprs, regs_null,sizeof (regs.gprs)),"grs == 0" ); -vcpu_sregs_get (vcpu->vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs);TEST_ASSERT (!memcmp (&sregs.acrs, regs_null,sizeof (sregs.acrs)),"acrs == 0" ); -vcpu_fpu_get (vcpu->vm, vcpu->id, &fpu); +vcpu_fpu_get (vcpu, &fpu);TEST_ASSERT (!memcmp (&fpu.fprs, regs_null,sizeof (fpu.fprs)),"fprs == 0" );/* sync regs */
@@ -135,7 +135,7 @@ static void assert_initial(struct kvm_vcpu *vcpu)struct kvm_fpu fpu;/* KVM_GET_SREGS */ -vcpu_sregs_get (vcpu->vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs);TEST_ASSERT (sregs.crs[0 ] ==0xE0UL ,"cr0 == 0xE0 (KVM_GET_SREGS)" );TEST_ASSERT (sregs.crs[14 ] ==0xC2000000UL ,"cr14 == 0xC2000000 (KVM_GET_SREGS)" );
@@ -161,7 +161,7 @@ static void assert_initial(struct kvm_vcpu *vcpu)TEST_ASSERT (vcpu->run->psw_addr ==0 ,"psw_addr == 0 (kvm_run)" );TEST_ASSERT (vcpu->run->psw_mask ==0 ,"psw_mask == 0 (kvm_run)" ); -vcpu_fpu_get (vcpu->vm, vcpu->id, &fpu); +vcpu_fpu_get (vcpu, &fpu);TEST_ASSERT (!fpu.fpc,"fpc == 0" );test_one_reg (vcpu,KVM_REG_S390_GBEA ,1 );
@@ -200,7 +200,7 @@ static void inject_irq(struct kvm_vcpu *vcpu) irq_state.buf = (unsigned long )buf; irq->type =KVM_S390_INT_EMERGENCY ; irq->u.emerg.code = vcpu->id; - irqs =__vcpu_ioctl (vcpu->vm, vcpu->id,KVM_S390_SET_IRQ_STATE , &irq_state); + irqs =__vcpu_ioctl (vcpu,KVM_S390_SET_IRQ_STATE , &irq_state);TEST_ASSERT (irqs >=0 ,"Error injecting EMERGENCY IRQ errno %d\n" , errno); }
@@ -223,11 +223,11 @@ static void test_normal(void)pr_info ("Testing normal reset\n" ); vm =create_vm (&vcpu); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);inject_irq (vcpu); -vcpu_ioctl (vm, vcpu->id,KVM_S390_NORMAL_RESET ,0 ); +vcpu_ioctl (vcpu,KVM_S390_NORMAL_RESET ,0 );/* must clears */ assert_normal (vcpu);
@@ -246,11 +246,11 @@ static void test_initial(void)pr_info ("Testing initial reset\n" ); vm =create_vm (&vcpu); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);inject_irq (vcpu); -vcpu_ioctl (vm, vcpu->id,KVM_S390_INITIAL_RESET ,0 ); +vcpu_ioctl (vcpu,KVM_S390_INITIAL_RESET ,0 );/* must clears */ assert_normal (vcpu);
@@ -269,11 +269,11 @@ static void test_clear(void)pr_info ("Testing clear reset\n" ); vm =create_vm (&vcpu); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);inject_irq (vcpu); -vcpu_ioctl (vm, vcpu->id,KVM_S390_CLEAR_RESET ,0 ); +vcpu_ioctl (vcpu,KVM_S390_CLEAR_RESET ,0 );/* must clears */ assert_normal (vcpu);
tools/testing/selftests/kvm/s390x/sync_regs_test.c +11 -11
@@ -97,14 +97,14 @@ int main(int argc, char *argv[])/* Request reading invalid register set from VCPU. */ run->kvm_valid_regs =INVALID_SYNC_FIELD ; - rv =_vcpu_run (vm, vcpu->id); + rv =_vcpu_run (vcpu);TEST_ASSERT (rv <0 && errno ==EINVAL ,"Invalid kvm_valid_regs did not cause expected KVM_RUN error: %d\n" , rv); run->kvm_valid_regs =0 ; run->kvm_valid_regs =INVALID_SYNC_FIELD |TEST_SYNC_FIELDS ; - rv =_vcpu_run (vm, vcpu->id); + rv =_vcpu_run (vcpu);TEST_ASSERT (rv <0 && errno ==EINVAL ,"Invalid kvm_valid_regs did not cause expected KVM_RUN error: %d\n" , rv);
@@ -112,14 +112,14 @@ int main(int argc, char *argv[])/* Request setting invalid register set into VCPU. */ run->kvm_dirty_regs =INVALID_SYNC_FIELD ; - rv =_vcpu_run (vm, vcpu->id); + rv =_vcpu_run (vcpu);TEST_ASSERT (rv <0 && errno ==EINVAL ,"Invalid kvm_dirty_regs did not cause expected KVM_RUN error: %d\n" , rv); run->kvm_dirty_regs =0 ; run->kvm_dirty_regs =INVALID_SYNC_FIELD |TEST_SYNC_FIELDS ; - rv =_vcpu_run (vm, vcpu->id); + rv =_vcpu_run (vcpu);TEST_ASSERT (rv <0 && errno ==EINVAL ,"Invalid kvm_dirty_regs did not cause expected KVM_RUN error: %d\n" , rv);
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])/* Request and verify all valid register sets. */ run->kvm_valid_regs =TEST_SYNC_FIELDS ; - rv =_vcpu_run (vm, vcpu->id); + rv =_vcpu_run (vcpu);TEST_ASSERT (rv ==0 ,"vcpu_run failed: %d\n" , rv); TEST_ASSERT(run->exit_reason == KVM_EXIT_S390_SIEIC, "Unexpected exit reason: %u (%s)\n",
@@ -140,10 +140,10 @@ int main(int argc, char *argv[]) run->s390_sieic.icptcode, run->s390_sieic.ipa, run->s390_sieic.ipb); -vcpu_regs_get (vm, vcpu->id, ®s); +vcpu_regs_get (vcpu, ®s);compare_regs (®s, &run->s.regs); -vcpu_sregs_get (vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs);compare_sregs (&sregs, &run->s.regs);/* Set and verify various register values */
@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) run->kvm_dirty_regs |=KVM_SYNC_DIAG318 ; } - rv =_vcpu_run (vm, vcpu->id); + rv =_vcpu_run (vcpu);TEST_ASSERT (rv ==0 ,"vcpu_run failed: %d\n" , rv); TEST_ASSERT(run->exit_reason == KVM_EXIT_S390_SIEIC, "Unexpected exit reason: %u (%s)\n",
@@ -174,10 +174,10 @@ int main(int argc, char *argv[])"diag318 sync regs value incorrect 0x%llx." , run->s.regs.diag318); -vcpu_regs_get (vm, vcpu->id, ®s); +vcpu_regs_get (vcpu, ®s);compare_regs (®s, &run->s.regs); -vcpu_sregs_get (vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs);compare_sregs (&sregs, &run->s.regs);/* Clear kvm_dirty_regs bits, verify new s.regs values are
@@ -187,7 +187,7 @@ int main(int argc, char *argv[]) run->kvm_dirty_regs =0 ; run->s.regs.gprs[11 ] =0xDEADBEEF ; run->s.regs.diag318 =0x4B1D ; - rv =_vcpu_run (vm, vcpu->id); + rv =_vcpu_run (vcpu);TEST_ASSERT (rv ==0 ,"vcpu_run failed: %d\n" , rv); TEST_ASSERT(run->exit_reason == KVM_EXIT_S390_SIEIC, "Unexpected exit reason: %u (%s)\n",
tools/testing/selftests/kvm/set_memory_region_test.c +4 -4
@@ -63,10 +63,10 @@ static void *vcpu_worker(void *data)* has been deleted or while it is being moved . */ while (1 ) { -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu);if (run->exit_reason ==KVM_EXIT_IO ) { - cmd =get_ucall (vcpu->vm, vcpu->id, &uc); + cmd =get_ucall (vcpu, &uc);if (cmd !=UCALL_SYNC )break ;
@@ -291,7 +291,7 @@ static void test_delete_memory_region(void) run->exit_reason ==KVM_EXIT_INTERNAL_ERROR , "Unexpected exit reason = %d", run->exit_reason); -vcpu_regs_get (vm, vcpu->id, ®s); +vcpu_regs_get (vcpu, ®s);/* * On AMD, after KVM_EXIT_SHUTDOWN the VMCB has been reinitialized already,
@@ -318,7 +318,7 @@ static void test_zero_memory_regions(void) vcpu =__vm_vcpu_add (vm,0 );vm_ioctl (vm,KVM_SET_NR_MMU_PAGES , (void *)64ul ); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu); run = vcpu->run; TEST_ASSERT(run->exit_reason == KVM_EXIT_INTERNAL_ERROR,
tools/testing/selftests/kvm/steal_time.c +10 -10
@@ -73,10 +73,10 @@ static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i) st_gva[i] = (void *)(ST_GPA_BASE + i *STEAL_TIME_SIZE );sync_global_to_guest (vcpu->vm, st_gva[i]); - ret =_vcpu_set_msr (vcpu->vm, vcpu->id,MSR_KVM_STEAL_TIME , (ulong )st_gva[i] |KVM_STEAL_RESERVED_MASK ); + ret =_vcpu_set_msr (vcpu,MSR_KVM_STEAL_TIME , (ulong )st_gva[i] |KVM_STEAL_RESERVED_MASK );TEST_ASSERT (ret ==0 ,"Bad GPA didn't fail" ); -vcpu_set_msr (vcpu->vm, vcpu->id,MSR_KVM_STEAL_TIME , (ulong )st_gva[i] |KVM_MSR_ENABLED ); +vcpu_set_msr (vcpu,MSR_KVM_STEAL_TIME , (ulong )st_gva[i] |KVM_MSR_ENABLED ); }static void steal_time_dump (struct kvm_vm *vm,uint32_t vcpu_idx)
@@ -169,7 +169,7 @@ static bool is_steal_time_supported(struct kvm_vcpu *vcpu) .attr = KVM_ARM_VCPU_PVTIME_IPA, }; -return !__vcpu_ioctl (vcpu->vm, vcpu->id,KVM_HAS_DEVICE_ATTR , &dev); +return !__vcpu_ioctl (vcpu,KVM_HAS_DEVICE_ATTR , &dev); }static void steal_time_init (struct kvm_vcpu *vcpu,uint32_t i)
@@ -184,20 +184,20 @@ static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i) .addr = (uint64_t)&st_ipa, }; -vcpu_ioctl (vm, vcpu->id,KVM_HAS_DEVICE_ATTR , &dev); +vcpu_ioctl (vcpu,KVM_HAS_DEVICE_ATTR , &dev);/* ST_GPA_BASE is identity mapped */ st_gva[i] = (void *)(ST_GPA_BASE + i *STEAL_TIME_SIZE );sync_global_to_guest (vm, st_gva[i]); st_ipa = (ulong )st_gva[i] |1 ; - ret =__vcpu_ioctl (vm, vcpu->id,KVM_SET_DEVICE_ATTR , &dev); + ret =__vcpu_ioctl (vcpu,KVM_SET_DEVICE_ATTR , &dev);TEST_ASSERT (ret ==-1 && errno ==EINVAL ,"Bad IPA didn't report EINVAL" ); st_ipa = (ulong )st_gva[i]; -vcpu_ioctl (vm, vcpu->id,KVM_SET_DEVICE_ATTR , &dev); +vcpu_ioctl (vcpu,KVM_SET_DEVICE_ATTR , &dev); - ret =__vcpu_ioctl (vm, vcpu->id,KVM_SET_DEVICE_ATTR , &dev); + ret =__vcpu_ioctl (vcpu,KVM_SET_DEVICE_ATTR , &dev);TEST_ASSERT (ret ==-1 && errno ==EEXIST ,"Set IPA twice without EEXIST" ); }
@@ -233,9 +233,9 @@ static void run_vcpu(struct kvm_vcpu *vcpu) {struct ucall uc; -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu); -switch (get_ucall (vcpu->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC :case UCALL_DONE :break ;
@@ -286,7 +286,7 @@ int main(int ac, char **av)for (i =0 ; i <NR_VCPUS ; ++i) {steal_time_init (vcpus[i], i); -vcpu_args_set (vm, vcpus[i]->id,1 , i); +vcpu_args_set (vcpus[i],1 , i);/* First VCPU run initializes steal-time */ run_vcpu (vcpus[i]);
tools/testing/selftests/kvm/system_counter_offset_test.c +6 -7
@@ -28,8 +28,7 @@ static struct test_case test_cases[] = {static void check_preconditions (struct kvm_vcpu *vcpu) { -if (!__vcpu_has_device_attr (vcpu->vm, vcpu->id,KVM_VCPU_TSC_CTRL , -KVM_VCPU_TSC_OFFSET )) +if (!__vcpu_has_device_attr (vcpu,KVM_VCPU_TSC_CTRL ,KVM_VCPU_TSC_OFFSET ))return ;print_skip ("KVM_VCPU_TSC_OFFSET not supported; skipping test" );
@@ -38,8 +37,8 @@ static void check_preconditions(struct kvm_vcpu *vcpu)static void setup_system_counter (struct kvm_vcpu *vcpu,struct test_case *test) { -vcpu_device_attr_set (vcpu->vm, vcpu->id,KVM_VCPU_TSC_CTRL , -KVM_VCPU_TSC_OFFSET , &test->tsc_offset); +vcpu_device_attr_set (vcpu,KVM_VCPU_TSC_CTRL ,KVM_VCPU_TSC_OFFSET , + &test->tsc_offset); }static uint64_t guest_read_system_counter (struct test_case *test)
@@ -101,10 +100,10 @@ static void enter_guest(struct kvm_vcpu *vcpu)setup_system_counter (vcpu, test); start =host_read_guest_system_counter (test); -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu); end =host_read_guest_system_counter (test); -switch (get_ucall (vcpu->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC :handle_sync (&uc, start, end);break ;
@@ -113,7 +112,7 @@ static void enter_guest(struct kvm_vcpu *vcpu)return ;default :TEST_ASSERT (0 ,"unhandled ucall %ld\n" , -get_ucall (vcpu->vm, vcpu->id, &uc)); +get_ucall (vcpu, &uc)); } } }
tools/testing/selftests/kvm/x86_64/amx_test.c +11 -11
@@ -352,11 +352,11 @@ int main(int argc, char *argv[]) } run = vcpu->run; -vcpu_regs_get (vm, vcpu->id, ®s1); +vcpu_regs_get (vcpu, ®s1);/* Register #NM handler */ vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);vm_install_exception_handler (vm,NM_VECTOR , guest_nm_handler);/* amx cfg for guest_code */
@@ -370,16 +370,16 @@ int main(int argc, char *argv[])/* xsave data for guest_code */ xsavedata =vm_vaddr_alloc_pages (vm,3 );memset (addr_gva2hva (vm, xsavedata),0 ,3 *getpagesize ()); -vcpu_args_set (vm, vcpu->id,3 , amx_cfg, tiledata, xsavedata); +vcpu_args_set (vcpu,3 , amx_cfg, tiledata, xsavedata);for (stage =1 ; ; stage++) { -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Stage %d: unexpected exit reason: %u (%s),\n" , stage, run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_ABORT :TEST_FAIL ("%s at %s:%ld" , (const char *)uc.args[0 ], __FILE__, uc.args[1 ]);
@@ -404,7 +404,7 @@ int main(int argc, char *argv[])* size subtract 8K amx size. */ amx_offset = xsave_restore_size -NUM_TILES *TILE_SIZE ; - state =vcpu_save_state (vm, vcpu->id); + state =vcpu_save_state (vcpu);void *amx_start = (void *)state->xsave + amx_offset;void *tiles_data = (void *)addr_gva2hva (vm, tiledata);/* Only check TMM0 register, 1 tile */
@@ -425,21 +425,21 @@ int main(int argc, char *argv[])TEST_FAIL ("Unknown ucall %lu" , uc.cmd); } - state =vcpu_save_state (vm, vcpu->id); + state =vcpu_save_state (vcpu);memset (®s1,0 ,sizeof (regs1)); -vcpu_regs_get (vm, vcpu->id, ®s1); +vcpu_regs_get (vcpu, ®s1);kvm_vm_release (vm);/* Restore state in a new VM. */ vcpu =vm_recreate_with_one_vcpu (vm); -vcpu_set_cpuid (vm, vcpu->id,kvm_get_supported_cpuid ()); -vcpu_load_state (vm, vcpu->id, state); +vcpu_set_cpuid (vcpu,kvm_get_supported_cpuid ()); +vcpu_load_state (vcpu, state); run = vcpu->run;kvm_x86_state_cleanup (state);memset (®s2,0 ,sizeof (regs2)); -vcpu_regs_get (vm, vcpu->id, ®s2); +vcpu_regs_get (vcpu, ®s2);TEST_ASSERT (!memcmp (®s1, ®s2,sizeof (regs2)),"Unexpected register values after vcpu_load_state; rdi: %lx rsi: %lx" , (ulong ) regs2.rdi, (ulong ) regs2.rsi);
tools/testing/selftests/kvm/x86_64/cpuid_test.c +7 -7
@@ -120,9 +120,9 @@ static void run_vcpu(struct kvm_vcpu *vcpu, int stage) {struct ucall uc; -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu); -switch (get_ucall (vcpu->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC : TEST_ASSERT(!strcmp((const char *)uc.args[0], "hello") && uc.args[1] == stage + 1,
@@ -159,14 +159,14 @@ static void set_cpuid_after_run(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid)u32 eax, ebx, x;/* Setting unmodified CPUID is allowed */ - rc =__vcpu_set_cpuid (vcpu->vm, vcpu->id, cpuid); + rc =__vcpu_set_cpuid (vcpu, cpuid);TEST_ASSERT (!rc,"Setting unmodified CPUID after KVM_RUN failed: %d" , rc);/* Changing CPU features is forbidden */ ent =get_cpuid (cpuid,0x7 ,0 ); ebx = ent->ebx; ent->ebx--; - rc =__vcpu_set_cpuid (vcpu->vm, vcpu->id, cpuid); + rc =__vcpu_set_cpuid (vcpu, cpuid);TEST_ASSERT (rc,"Changing CPU features should fail" ); ent->ebx = ebx;
@@ -175,7 +175,7 @@ static void set_cpuid_after_run(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid) eax = ent->eax; x = eax &0xff ; ent->eax = (eax & ~0xffu ) | (x -1 ); - rc =__vcpu_set_cpuid (vcpu->vm, vcpu->id, cpuid); + rc =__vcpu_set_cpuid (vcpu, cpuid);TEST_ASSERT (rc,"Changing MAXPHYADDR should fail" ); ent->eax = eax; }
@@ -191,13 +191,13 @@ int main(void) vm =vm_create_with_one_vcpu (&vcpu, guest_main); supp_cpuid =kvm_get_supported_cpuid (); - cpuid2 =vcpu_get_cpuid (vm, vcpu->id); + cpuid2 =vcpu_get_cpuid (vcpu);compare_cpuids (supp_cpuid, cpuid2);vcpu_alloc_cpuid (vm, &cpuid_gva, cpuid2); -vcpu_args_set (vm, vcpu->id,1 , cpuid_gva); +vcpu_args_set (vcpu,1 , cpuid_gva);for (stage =0 ; stage <3 ; stage++)run_vcpu (vcpu, stage);
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c +4 -4
@@ -82,19 +82,19 @@ int main(int argc, char *argv[]) run = vcpu->run;while (1 ) { -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Unexpected exit reason: %u (%s),\n" , run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC :/* emulate hypervisor clearing CR4.OSXSAVE */ -vcpu_sregs_get (vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs); sregs.cr4 &= ~X86_CR4_OSXSAVE ; -vcpu_sregs_set (vm, vcpu->id, &sregs); +vcpu_sregs_set (vcpu, &sregs);break ;case UCALL_ABORT :TEST_FAIL ("Guest CR4 bit (OSXSAVE) unsynchronized with CPUID bit." );
tools/testing/selftests/kvm/x86_64/debug_regs.c +15 -15
@@ -70,9 +70,9 @@ static void vcpu_skip_insn(struct kvm_vcpu *vcpu, int insn_len) {struct kvm_regs regs; -vcpu_regs_get (vcpu->vm, vcpu->id, ®s); +vcpu_regs_get (vcpu, ®s); regs.rip += insn_len; -vcpu_regs_set (vcpu->vm, vcpu->id, ®s); +vcpu_regs_set (vcpu, ®s); }int main (void )
@@ -106,8 +106,8 @@ int main(void)/* Test software BPs - int3 */ memset (&debug,0 ,sizeof (debug)); debug.control =KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_USE_SW_BP ; -vcpu_set_guest_debug (vm, vcpu->id, &debug); -vcpu_run (vm, vcpu->id); +vcpu_set_guest_debug (vcpu, &debug); +vcpu_run (vcpu); TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG && run->debug.arch.exception == BP_VECTOR && run->debug.arch.pc == CAST_TO_RIP(sw_bp),
@@ -122,8 +122,8 @@ int main(void) debug.control =KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_USE_HW_BP ; debug.arch.debugreg[i] =CAST_TO_RIP (hw_bp); debug.arch.debugreg[7 ] =0x400 | (1UL << (2 *i+1 )); -vcpu_set_guest_debug (vm, vcpu->id, &debug); -vcpu_run (vm, vcpu->id); +vcpu_set_guest_debug (vcpu, &debug); +vcpu_run (vcpu); target_dr6 =0xffff0ff0 | (1UL << i); TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG && run->debug.arch.exception == DB_VECTOR &&
@@ -145,8 +145,8 @@ int main(void) debug.arch.debugreg[i] =CAST_TO_RIP (guest_value); debug.arch.debugreg[7 ] =0x00000400 | (1UL << (2 *i+1 )) | (0x000d0000UL << (4 *i)); -vcpu_set_guest_debug (vm, vcpu->id, &debug); -vcpu_run (vm, vcpu->id); +vcpu_set_guest_debug (vcpu, &debug); +vcpu_run (vcpu); target_dr6 =0xffff0ff0 | (1UL << i); TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG && run->debug.arch.exception == DB_VECTOR &&
@@ -172,8 +172,8 @@ int main(void) debug.control =KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_SINGLESTEP |KVM_GUESTDBG_BLOCKIRQ ; debug.arch.debugreg[7 ] =0x00000400 ; -vcpu_set_guest_debug (vm, vcpu->id, &debug); -vcpu_run (vm, vcpu->id); +vcpu_set_guest_debug (vcpu, &debug); +vcpu_run (vcpu); TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG && run->debug.arch.exception == DB_VECTOR && run->debug.arch.pc == target_rip &&
@@ -189,8 +189,8 @@ int main(void)memset (&debug,0 ,sizeof (debug)); debug.control =KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_USE_HW_BP ; debug.arch.debugreg[7 ] =0x400 |DR7_GD ; -vcpu_set_guest_debug (vm, vcpu->id, &debug); -vcpu_run (vm, vcpu->id); +vcpu_set_guest_debug (vcpu, &debug); +vcpu_run (vcpu); target_dr6 =0xffff0ff0 |DR6_BD ; TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG && run->debug.arch.exception == DB_VECTOR &&
@@ -204,11 +204,11 @@ int main(void)/* Disable all debug controls, run to the end */ memset (&debug,0 ,sizeof (debug)); -vcpu_set_guest_debug (vm, vcpu->id, &debug); +vcpu_set_guest_debug (vcpu, &debug); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"KVM_EXIT_IO" ); - cmd =get_ucall (vm, vcpu->id, &uc); + cmd =get_ucall (vcpu, &uc);TEST_ASSERT (cmd ==UCALL_DONE ,"UCALL_DONE" );kvm_vm_free (vm);
tools/testing/selftests/kvm/x86_64/emulator_error_test.c +10 -10
@@ -84,9 +84,9 @@ static void process_exit_on_emulation_error(struct kvm_vcpu *vcpu)* contained an flds instruction that is 2-bytes in * length (ie: no prefix, no SIB, no displacement). */ -vcpu_regs_get (vcpu->vm, vcpu->id, ®s); +vcpu_regs_get (vcpu, ®s); regs.rip +=2 ; -vcpu_regs_set (vcpu->vm, vcpu->id, ®s); +vcpu_regs_set (vcpu, ®s); } } }
@@ -102,7 +102,7 @@ static void check_for_guest_assert(struct kvm_vcpu *vcpu)struct ucall uc;if (vcpu->run->exit_reason ==KVM_EXIT_IO && -get_ucall (vcpu->vm, vcpu->id, &uc) ==UCALL_ABORT ) { +get_ucall (vcpu, &uc) ==UCALL_ABORT ) {do_guest_assert (&uc); } }
@@ -119,7 +119,7 @@ static void process_ucall_done(struct kvm_vcpu *vcpu) run->exit_reason, exit_reason_str(run->exit_reason)); -TEST_ASSERT (get_ucall (vcpu->vm, vcpu->id, &uc) ==UCALL_DONE , +TEST_ASSERT (get_ucall (vcpu, &uc) ==UCALL_DONE ,"Unexpected ucall command: %lu, expected UCALL_DONE (%d)" , uc.cmd,UCALL_DONE ); }
@@ -134,7 +134,7 @@ static uint64_t process_ucall(struct kvm_vcpu *vcpu) run->exit_reason, exit_reason_str(run->exit_reason)); -switch (get_ucall (vcpu->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC :break ;case UCALL_ABORT :
@@ -180,7 +180,7 @@ int main(int argc, char *argv[]) entry->eax = (entry->eax &0xffffff00 ) |MAXPHYADDR ;set_cpuid (cpuid, entry); -vcpu_set_cpuid (vm, vcpu->id, cpuid); +vcpu_set_cpuid (vcpu, cpuid); rc =kvm_check_cap (KVM_CAP_EXIT_ON_EMULATION_FAILURE );TEST_ASSERT (rc,"KVM_CAP_EXIT_ON_EMULATION_FAILURE is unavailable" );
@@ -195,12 +195,12 @@ int main(int argc, char *argv[])virt_map (vm,MEM_REGION_GVA ,MEM_REGION_GPA ,1 ); hva =addr_gpa2hva (vm,MEM_REGION_GPA );memset (hva,0 ,PAGE_SIZE ); - pte =vm_get_page_table_entry (vm, vcpu->id,MEM_REGION_GVA ); -vm_set_page_table_entry (vm, vcpu->id,MEM_REGION_GVA , pte | (1ull <<36 )); + pte =vm_get_page_table_entry (vm, vcpu,MEM_REGION_GVA ); +vm_set_page_table_entry (vm, vcpu,MEM_REGION_GVA , pte | (1ull <<36 )); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);process_exit_on_emulation_error (vcpu); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (process_ucall (vcpu) ==UCALL_DONE ,"Expected UCALL_DONE" );
tools/testing/selftests/kvm/x86_64/evmcs_test.c +14 -14
@@ -163,12 +163,12 @@ void inject_nmi(struct kvm_vcpu *vcpu) {struct kvm_vcpu_events events; -vcpu_events_get (vcpu->vm, vcpu->id, &events); +vcpu_events_get (vcpu, &events); events.nmi.pending =1 ; events.flags |=KVM_VCPUEVENT_VALID_NMI_PENDING ; -vcpu_events_set (vcpu->vm, vcpu->id, &events); +vcpu_events_set (vcpu, &events); } static struct kvm_vcpu *save_restore_vm(struct kvm_vm *vm,
@@ -177,21 +177,21 @@ static struct kvm_vcpu *save_restore_vm(struct kvm_vm *vm,struct kvm_regs regs1, regs2;struct kvm_x86_state *state; - state =vcpu_save_state (vm, vcpu->id); + state =vcpu_save_state (vcpu);memset (®s1,0 ,sizeof (regs1)); -vcpu_regs_get (vm, vcpu->id, ®s1); +vcpu_regs_get (vcpu, ®s1);kvm_vm_release (vm);/* Restore state in a new VM. */ vcpu =vm_recreate_with_one_vcpu (vm); -vcpu_set_hv_cpuid (vm, vcpu->id); -vcpu_enable_evmcs (vm, vcpu->id); -vcpu_load_state (vm, vcpu->id, state); +vcpu_set_hv_cpuid (vcpu); +vcpu_enable_evmcs (vcpu); +vcpu_load_state (vcpu, state);kvm_x86_state_cleanup (state);memset (®s2,0 ,sizeof (regs2)); -vcpu_regs_get (vm, vcpu->id, ®s2); +vcpu_regs_get (vcpu, ®s2);TEST_ASSERT (!memcmp (®s1, ®s2,sizeof (regs2)),"Unexpected register values after vcpu_load_state; rdi: %lx rsi: %lx" , (ulong ) regs2.rdi, (ulong ) regs2.rsi);
@@ -217,14 +217,14 @@ int main(int argc, char *argv[])exit (KSFT_SKIP ); } -vcpu_set_hv_cpuid (vm, vcpu->id); -vcpu_enable_evmcs (vm, vcpu->id); +vcpu_set_hv_cpuid (vcpu); +vcpu_enable_evmcs (vcpu);vcpu_alloc_vmx (vm, &vmx_pages_gva); -vcpu_args_set (vm, vcpu->id,1 , vmx_pages_gva); +vcpu_args_set (vcpu,1 , vmx_pages_gva);vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);vm_install_exception_handler (vm,UD_VECTOR , guest_ud_handler);vm_install_exception_handler (vm,NMI_VECTOR , guest_nmi_handler);
@@ -233,13 +233,13 @@ int main(int argc, char *argv[])for (stage =1 ;; stage++) { run = vcpu->run; -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Stage %d: unexpected exit reason: %u (%s),\n" , stage, run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_ABORT :TEST_FAIL ("%s at %s:%ld" , (const char *)uc.args[0 ], __FILE__, uc.args[1 ]);
tools/testing/selftests/kvm/x86_64/hyperv_clock.c +7 -7
@@ -176,15 +176,15 @@ static void host_check_tsc_msr_rdtsc(struct kvm_vcpu *vcpu)u64 tsc_freq, r1, r2, t1, t2;s64 delta_ns; - tsc_freq =vcpu_get_msr (vcpu->vm, vcpu->id,HV_X64_MSR_TSC_FREQUENCY ); + tsc_freq =vcpu_get_msr (vcpu,HV_X64_MSR_TSC_FREQUENCY );TEST_ASSERT (tsc_freq >0 ,"TSC frequency must be nonzero" );/* First, check MSR-based clocksource */ r1 =rdtsc (); - t1 =vcpu_get_msr (vcpu->vm, vcpu->id,HV_X64_MSR_TIME_REF_COUNT ); + t1 =vcpu_get_msr (vcpu,HV_X64_MSR_TIME_REF_COUNT );nop_loop (); r2 =rdtsc (); - t2 =vcpu_get_msr (vcpu->vm, vcpu->id,HV_X64_MSR_TIME_REF_COUNT ); + t2 =vcpu_get_msr (vcpu,HV_X64_MSR_TIME_REF_COUNT );TEST_ASSERT (t2 > t1,"Time reference MSR is not monotonic (%ld <= %ld)" , t1, t2);
@@ -211,24 +211,24 @@ int main(void) vm =vm_create_with_one_vcpu (&vcpu, guest_main); run = vcpu->run; -vcpu_set_hv_cpuid (vm, vcpu->id); +vcpu_set_hv_cpuid (vcpu); tsc_page_gva =vm_vaddr_alloc_page (vm);memset (addr_gva2hva (vm, tsc_page_gva),0x0 ,getpagesize ());TEST_ASSERT ((addr_gva2gpa (vm, tsc_page_gva) & (getpagesize () -1 )) ==0 ,"TSC page has to be page aligned\n" ); -vcpu_args_set (vm, vcpu->id,2 , tsc_page_gva,addr_gva2gpa (vm, tsc_page_gva)); +vcpu_args_set (vcpu,2 , tsc_page_gva,addr_gva2gpa (vm, tsc_page_gva));host_check_tsc_msr_rdtsc (vcpu);for (stage =1 ;; stage++) { -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Stage %d: unexpected exit reason: %u (%s),\n" , stage, run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_ABORT :TEST_FAIL ("%s at %s:%ld" , (const char *)uc.args[0 ], __FILE__, uc.args[1 ]);
tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +4 -4
@@ -119,7 +119,7 @@ void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu)int ret;if (vcpu) - ret =__vcpu_ioctl (vm, vcpu->id,KVM_GET_SUPPORTED_HV_CPUID , &cpuid); + ret =__vcpu_ioctl (vcpu,KVM_GET_SUPPORTED_HV_CPUID , &cpuid);else ret =__kvm_ioctl (vm_get_kvm_fd (vm),KVM_GET_SUPPORTED_HV_CPUID , &cpuid);
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])/* Test vCPU ioctl version */ test_hv_cpuid_e2big (vm, vcpu); - hv_cpuid_entries =vcpu_get_supported_hv_cpuid (vm, vcpu->id); + hv_cpuid_entries =vcpu_get_supported_hv_cpuid (vcpu);test_hv_cpuid (hv_cpuid_entries, false);free (hv_cpuid_entries);
@@ -156,8 +156,8 @@ int main(int argc, char *argv[])print_skip ("Enlightened VMCS is unsupported" ); goto do_sys; } -vcpu_enable_evmcs (vm, vcpu->id); - hv_cpuid_entries =vcpu_get_supported_hv_cpuid (vm, vcpu->id); +vcpu_enable_evmcs (vcpu); + hv_cpuid_entries =vcpu_get_supported_hv_cpuid (vcpu);test_hv_cpuid (hv_cpuid_entries, true);free (hv_cpuid_entries);
tools/testing/selftests/kvm/x86_64/hyperv_features.c +14 -14
@@ -161,7 +161,7 @@ static void hv_set_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid, "failed to set HYPERV_CPUID_ENLIGHTMENT_INFO leaf");TEST_ASSERT (set_cpuid (cpuid, dbg),"failed to set HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES leaf" ); -vcpu_set_cpuid (vcpu->vm, vcpu->id, cpuid); +vcpu_set_cpuid (vcpu, cpuid); }static void guest_test_msrs_access (void )
@@ -195,15 +195,15 @@ static void guest_test_msrs_access(void)memset (addr_gva2hva (vm, msr_gva),0x0 ,getpagesize ()); msr =addr_gva2hva (vm, msr_gva); -vcpu_args_set (vm, vcpu->id,1 , msr_gva); -vcpu_enable_cap (vm, vcpu->id, &cap); +vcpu_args_set (vcpu,1 , msr_gva); +vcpu_enable_cap (vcpu, &cap); -vcpu_set_hv_cpuid (vm, vcpu->id); +vcpu_set_hv_cpuid (vcpu); best =kvm_get_supported_hv_cpuid ();vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);vm_install_exception_handler (vm,GP_VECTOR , guest_gp_handler); run = vcpu->run;
@@ -339,7 +339,7 @@ static void guest_test_msrs_access(void)*/ cap.cap =KVM_CAP_HYPERV_SYNIC2 ; cap.args[0 ] =0 ; -vcpu_enable_cap (vm, vcpu->id, &cap); +vcpu_enable_cap (vcpu, &cap);break ;case 22 : feat.eax |=HV_MSR_SYNIC_AVAILABLE ;
@@ -477,12 +477,12 @@ static void guest_test_msrs_access(void)else pr_debug ("Stage %d: finish\n" , stage); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"unexpected exit reason: %u (%s)" , run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC : TEST_ASSERT(uc.args[1] == 0, "Unexpected stage: %ld (0 expected)\n",
@@ -530,7 +530,7 @@ static void guest_test_hcalls_access(void) vm =vm_create_with_one_vcpu (&vcpu, guest_hcall);vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);vm_install_exception_handler (vm,UD_VECTOR , guest_ud_handler);/* Hypercall input/output */
@@ -541,10 +541,10 @@ static void guest_test_hcalls_access(void) hcall_params =vm_vaddr_alloc_page (vm);memset (addr_gva2hva (vm, hcall_params),0x0 ,getpagesize ()); -vcpu_args_set (vm, vcpu->id,2 ,addr_gva2gpa (vm, hcall_page), hcall_params); -vcpu_enable_cap (vm, vcpu->id, &cap); +vcpu_args_set (vcpu,2 ,addr_gva2gpa (vm, hcall_page), hcall_params); +vcpu_enable_cap (vcpu, &cap); -vcpu_set_hv_cpuid (vm, vcpu->id); +vcpu_set_hv_cpuid (vcpu); best =kvm_get_supported_hv_cpuid ();
@@ -651,12 +651,12 @@ static void guest_test_hcalls_access(void)else pr_debug ("Stage %d: finish\n" , stage); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"unexpected exit reason: %u (%s)" , run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC : TEST_ASSERT(uc.args[1] == 0, "Unexpected stage: %ld (0 expected)\n",
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c +4 -4
@@ -138,19 +138,19 @@ int main(int argc, char *argv[]) }/* Create VM */ vm =vm_create_with_one_vcpu (&vcpu, guest_code); -vcpu_set_hv_cpuid (vm, vcpu->id); +vcpu_set_hv_cpuid (vcpu); run = vcpu->run;vcpu_alloc_svm (vm, &nested_gva); -vcpu_args_set (vm, vcpu->id,1 , nested_gva); +vcpu_args_set (vcpu,1 , nested_gva);for (stage =1 ;; stage++) { -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Stage %d: unexpected exit reason: %u (%s),\n" , stage, run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_ABORT :TEST_FAIL ("%s at %s:%ld" , (const char *)uc.args[0 ], __FILE__, uc.args[1 ]);
tools/testing/selftests/kvm/x86_64/kvm_clock_test.c +3 -3
@@ -116,14 +116,14 @@ static void enter_guest(struct kvm_vcpu *vcpu)vm_ioctl (vm,KVM_GET_CLOCK , &start); -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu);vm_ioctl (vm,KVM_GET_CLOCK , &end);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"unexpected exit reason: %u (%s)" , run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vcpu->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC :handle_sync (&uc, &start, &end);break ;
@@ -193,7 +193,7 @@ int main(void) pvti_gva =vm_vaddr_alloc (vm,getpagesize (),0x10000 ); pvti_gpa =addr_gva2gpa (vm, pvti_gva); -vcpu_args_set (vm, vcpu->id,2 , pvti_gpa, pvti_gva); +vcpu_args_set (vcpu,2 , pvti_gpa, pvti_gva);enter_guest (vcpu);kvm_vm_free (vm);
tools/testing/selftests/kvm/x86_64/kvm_pv_test.c +5 -5
@@ -177,12 +177,12 @@ static void enter_guest(struct kvm_vcpu *vcpu)struct ucall uc;while (true) { -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"unexpected exit reason: %u (%s)" , run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vcpu->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_PR_MSR :pr_msr (&uc);break ;
@@ -214,14 +214,14 @@ int main(void) cap.cap =KVM_CAP_ENFORCE_PV_FEATURE_CPUID ; cap.args[0 ] =1 ; -vcpu_enable_cap (vm, vcpu->id, &cap); +vcpu_enable_cap (vcpu, &cap); best =kvm_get_supported_cpuid ();clear_kvm_cpuid_features (best); -vcpu_set_cpuid (vm, vcpu->id, best); +vcpu_set_cpuid (vcpu, best);vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);vm_install_exception_handler (vm,GP_VECTOR , guest_gp_handler);enter_guest (vcpu);
tools/testing/selftests/kvm/x86_64/mmu_role_test.c +5 -5
@@ -35,7 +35,7 @@ static void mmu_role_test(u32 *cpuid_reg, u32 evil_cpuid_val)/* Map 1gb page without a backing memlot. */ __virt_pg_map (vm,MMIO_GPA ,MMIO_GPA ,X86_PAGE_SIZE_1G ); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);/* Guest access to the 1gb page should trigger MMIO. */ TEST_ASSERT(run->exit_reason == KVM_EXIT_MMIO,
@@ -54,7 +54,7 @@ static void mmu_role_test(u32 *cpuid_reg, u32 evil_cpuid_val)* returns the struct that contains the entry being modified. Eww. */ *cpuid_reg = evil_cpuid_val; -vcpu_set_cpuid (vm, vcpu->id,kvm_get_supported_cpuid ()); +vcpu_set_cpuid (vcpu,kvm_get_supported_cpuid ());/* * Add a dummy memslot to coerce KVM into bumping the MMIO generation.
@@ -67,12 +67,12 @@ static void mmu_role_test(u32 *cpuid_reg, u32 evil_cpuid_val)/* Set up a #PF handler to eat the RSVD #PF and signal all done! */ vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);vm_install_exception_handler (vm,PF_VECTOR , guest_pf_handler); -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu); - cmd =get_ucall (vm, vcpu->id,NULL ); + cmd =get_ucall (vcpu,NULL );TEST_ASSERT (cmd ==UCALL_DONE ,"Unexpected guest exit, exit_reason=%s, ucall.cmd = %lu\n" ,exit_reason_str (run->exit_reason), cmd);
tools/testing/selftests/kvm/x86_64/platform_info_test.c +7 -7
@@ -50,12 +50,12 @@ static void test_msr_platform_info_enabled(struct kvm_vcpu *vcpu)struct ucall uc;set_msr_platform_info_enabled (vcpu->vm, true); -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Exit_reason other than KVM_EXIT_IO: %u (%s),\n" , run->exit_reason,exit_reason_str (run->exit_reason)); -get_ucall (vcpu->vm, vcpu->id, &uc); +get_ucall (vcpu, &uc);TEST_ASSERT (uc.cmd ==UCALL_SYNC ,"Received ucall other than UCALL_SYNC: %lu\n" , uc.cmd); TEST_ASSERT((uc.args[1] & MSR_PLATFORM_INFO_MAX_TURBO_RATIO) ==
@@ -69,7 +69,7 @@ static void test_msr_platform_info_disabled(struct kvm_vcpu *vcpu)struct kvm_run *run = vcpu->run;set_msr_platform_info_enabled (vcpu->vm, false); -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu); TEST_ASSERT(run->exit_reason == KVM_EXIT_SHUTDOWN, "Exit_reason other than KVM_EXIT_SHUTDOWN: %u (%s)\n", run->exit_reason,
@@ -94,12 +94,12 @@ int main(int argc, char *argv[]) vm =vm_create_with_one_vcpu (&vcpu, guest_code); - msr_platform_info =vcpu_get_msr (vm, vcpu->id,MSR_PLATFORM_INFO ); -vcpu_set_msr (vm, vcpu->id,MSR_PLATFORM_INFO , - msr_platform_info |MSR_PLATFORM_INFO_MAX_TURBO_RATIO ); + msr_platform_info =vcpu_get_msr (vcpu,MSR_PLATFORM_INFO ); +vcpu_set_msr (vcpu,MSR_PLATFORM_INFO , + msr_platform_info |MSR_PLATFORM_INFO_MAX_TURBO_RATIO );test_msr_platform_info_enabled (vcpu);test_msr_platform_info_disabled (vcpu); -vcpu_set_msr (vm, vcpu->id,MSR_PLATFORM_INFO , msr_platform_info); +vcpu_set_msr (vcpu,MSR_PLATFORM_INFO , msr_platform_info);kvm_vm_free (vm);
tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c +3 -3
@@ -177,12 +177,12 @@ static uint64_t run_vcpu_to_sync(struct kvm_vcpu *vcpu)struct kvm_run *run = vcpu->run;struct ucall uc; -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Exit_reason other than KVM_EXIT_IO: %u (%s)\n" , run->exit_reason,exit_reason_str (run->exit_reason)); -get_ucall (vcpu->vm, vcpu->id, &uc); +get_ucall (vcpu, &uc);TEST_ASSERT (uc.cmd ==UCALL_SYNC ,"Received ucall other than UCALL_SYNC: %lu" , uc.cmd);return uc.args[1 ];
@@ -415,7 +415,7 @@ int main(int argc, char *argv[]) vm =vm_create_with_one_vcpu (&vcpu, guest_code);vm_init_descriptor_tables (vm); -vcpu_init_descriptor_tables (vm, vcpu->id); +vcpu_init_descriptor_tables (vcpu);if (!sanity_check_pmu (vcpu)) {print_skip ("Guest PMU is not functional" );
tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c +2 -2
@@ -49,9 +49,9 @@ static void run_vcpu(struct kvm_vcpu *vcpu)for (stage =0 ; stage <2 ; stage++) { -vcpu_run (vcpu->vm, vcpu->id); +vcpu_run (vcpu); -switch (get_ucall (vcpu->vm, vcpu->id, &uc)) { +switch (get_ucall (vcpu, &uc)) {case UCALL_SYNC : TEST_ASSERT(!strcmp((const char *)uc.args[0], "hello") && uc.args[1] == stage + 1,
tools/testing/selftests/kvm/x86_64/set_sregs_test.c +8 -8
@@ -35,11 +35,11 @@ static void test_cr4_feature_bit(struct kvm_vcpu *vcpu, struct kvm_sregs *orig,memcpy (&sregs, orig,sizeof (sregs)); sregs.cr4 |= feature_bit; - rc =_vcpu_sregs_set (vcpu->vm, vcpu->id, &sregs); + rc =_vcpu_sregs_set (vcpu, &sregs);TEST_ASSERT (rc,"KVM allowed unsupported CR4 bit (0x%lx)" , feature_bit);/* Sanity check that KVM didn't change anything. */ -vcpu_sregs_get (vcpu->vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs);TEST_ASSERT (!memcmp (&sregs, orig,sizeof (sregs)),"KVM modified sregs" ); }
@@ -97,15 +97,15 @@ int main(int argc, char *argv[]) vm =vm_create (DEFAULT_GUEST_PHY_PAGES ); vcpu =__vm_vcpu_add (vm,0 ); -vcpu_sregs_get (vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs); sregs.cr4 |=calc_cr4_feature_bits (vm); cr4 = sregs.cr4; - rc =_vcpu_sregs_set (vm, vcpu->id, &sregs); + rc =_vcpu_sregs_set (vcpu, &sregs);TEST_ASSERT (!rc,"Failed to set supported CR4 bits (0x%lx)" , cr4); -vcpu_sregs_get (vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs);TEST_ASSERT (sregs.cr4 == cr4,"sregs.CR4 (0x%llx) != CR4 (0x%lx)" , sregs.cr4, cr4);
@@ -125,13 +125,13 @@ int main(int argc, char *argv[])/* Create a "real" VM and verify APIC_BASE can be set. */ vm =vm_create_with_one_vcpu (&vcpu,NULL ); -vcpu_sregs_get (vm, vcpu->id, &sregs); +vcpu_sregs_get (vcpu, &sregs); sregs.apic_base =1 <<10 ; - rc =_vcpu_sregs_set (vm, vcpu->id, &sregs); + rc =_vcpu_sregs_set (vcpu, &sregs);TEST_ASSERT (rc,"Set IA32_APIC_BASE to %llx (invalid)" , sregs.apic_base); sregs.apic_base =1 <<11 ; - rc =_vcpu_sregs_set (vm, vcpu->id, &sregs); + rc =_vcpu_sregs_set (vcpu, &sregs);TEST_ASSERT (!rc,"Couldn't set IA32_APIC_BASE to %llx (valid)" , sregs.apic_base);
tools/testing/selftests/kvm/x86_64/smm_test.c +9 -9
@@ -120,12 +120,12 @@ void inject_smi(struct kvm_vcpu *vcpu) {struct kvm_vcpu_events events; -vcpu_events_get (vcpu->vm, vcpu->id, &events); +vcpu_events_get (vcpu, &events); events.smi.pending =1 ; events.flags |=KVM_VCPUEVENT_VALID_SMM ; -vcpu_events_set (vcpu->vm, vcpu->id, &events); +vcpu_events_set (vcpu, &events); }int main (int argc,char *argv[])
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])memcpy (addr_gpa2hva (vm,SMRAM_GPA ) +0x8000 , smi_handler,sizeof (smi_handler)); -vcpu_set_msr (vm, vcpu->id,MSR_IA32_SMBASE ,SMRAM_GPA ); +vcpu_set_msr (vcpu,MSR_IA32_SMBASE ,SMRAM_GPA );if (kvm_check_cap (KVM_CAP_NESTED_STATE )) {if (nested_svm_supported ())
@@ -165,17 +165,17 @@ int main(int argc, char *argv[])if (!nested_gva)pr_info ("will skip SMM test with VMX enabled\n" ); -vcpu_args_set (vm, vcpu->id,1 , nested_gva); +vcpu_args_set (vcpu,1 , nested_gva);for (stage =1 ;; stage++) { -vcpu_run (vm, vcpu->id); +vcpu_run (vcpu);TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO ,"Stage %d: unexpected exit reason: %u (%s),\n" , stage, run->exit_reason,exit_reason_str (run->exit_reason));memset (®s,0 ,sizeof (regs)); -vcpu_regs_get (vm, vcpu->id, ®s); +vcpu_regs_get (vcpu, ®s); stage_reported = regs.rax &0xff ;
@@ -203,12 +203,12 @@ int main(int argc, char *argv[])if (stage ==10 )inject_smi (vcpu); - state =vcpu_save_state (vm, vcpu->id); + state =vcpu_save_state (vcpu);kvm_vm_release (vm); vcpu =vm_recreate_with_one_vcpu (vm); -vcpu_set_cpuid (vm, vcpu->id,kvm_get_supported_cpuid ()); -vcpu_load_state (vm, vcpu->id, state); +vcpu_set_cpuid (vcpu,kvm_get_supported_cpuid ()); +vcpu_load_state (vcpu, state); run = vcpu->run;kvm_x86_state_cleanup (state); }
tools/testing/selftests/kvm/x86_64/state_test.c +9 -9
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) vm =vm_create_with_one_vcpu (&vcpu, guest_code); run = vcpu->run; -vcpu_regs_get (vm, vcpu->id, ®s1); +vcpu_regs_get (vcpu, ®s1);if (kvm_check_cap (KVM_CAP_NESTED_STATE )) {if (nested_svm_supported ())
@@ -179,16 +179,16 @@ int main(int argc, char *argv[])if (!nested_gva)pr_info ("will skip nested state checks\n" );
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c +4 -4
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c +3 -3
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/sync_regs_test.c +18 -18
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c +7 -7
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/userspace_io_test.c +4 -4
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c +11 -11
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c +3 -3
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c +3 -3
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c +3 -3
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_exception_with_invalid_guest_state.c +5 -5
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_invalid_nested_guest_state.c +6 -6
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c +5 -6
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c +10 -10
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c +9 -9
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c +6 -6
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c +3 -3
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c +5 -5
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c +10 -10
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/xen_vmcall_test.c +3 -3
Lines of this file are not shown. View the raw message.
tools/testing/selftests/kvm/x86_64/xss_msr_test.c +3 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.35.1.723.g4982287a31-goog
Part of the diff is not shown here. View the raw message.
Sean Christopherson
reviewerRFC PATCH 103/105 KVM: selftests: Drop vcpu_get(), rename vcpu_find() => vcpu_exists()
In reply to Sean Christopherson--- .../selftests/kvm/include/kvm_util_base.h | 2 -- tools/testing/selftests/kvm/lib/kvm_util.c | 34 +++++++------------ 2 files changed, 13 insertions(+), 23 deletions(-)
tools/testing/selftests/kvm/include/kvm_util_base.h +0 -2
@@ -93,8 +93,6 @@ struct kvm_vm {continue ; \ else -struct kvm_vcpu *vcpu_get(struct kvm_vm *vm, uint32_t vcpu_id); - struct userspace_mem_region *memslot2region (struct kvm_vm *vm,uint32_t memslot);
tools/testing/selftests/kvm/lib/kvm_util.c +13 -21
@@ -475,26 +475,6 @@ kvm_userspace_memory_region_find(struct kvm_vm *vm, uint64_t start,return ®ion->region; } -static struct kvm_vcpu *vcpu_find (struct kvm_vm *vm,uint32_t vcpu_id) -{ -struct kvm_vcpu *vcpu; - -list_for_each_entry (vcpu, &vm->vcpus, list) { -if (vcpu->id == vcpu_id) -return vcpu; - } - -return NULL ; -} - -struct kvm_vcpu *vcpu_get (struct kvm_vm *vm,uint32_t vcpu_id) -{ -struct kvm_vcpu *vcpu =vcpu_find (vm, vcpu_id); - -TEST_ASSERT (vcpu,"vCPU %d does not exist" , vcpu_id); -return vcpu; -} -/* * VM VCPU Remove *
@@ -1044,6 +1024,18 @@ static int vcpu_mmap_sz(void)return ret; } +static bool vcpu_exists (struct kvm_vm *vm,uint32_t vcpu_id) +{ +struct kvm_vcpu *vcpu; + +list_for_each_entry (vcpu, &vm->vcpus, list) { +if (vcpu->id == vcpu_id) +return true; + } + +return false; +} +/* * Adds a virtual CPU to the VM specified by vm with the ID given by vcpu_id. * No additional vCPU setup is done. Returns the vCPU.
@@ -1053,7 +1045,7 @@ struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id)struct kvm_vcpu *vcpu;/* Confirm a vcpu with the specified id doesn't already exist. */ -TEST_ASSERT (!vcpu_find (vm, vcpu_id),"vCPU%d already exists\n" , vcpu_id); +TEST_ASSERT (!vcpu_exists (vm, vcpu_id),"vCPU%d already exists\n" , vcpu_id);/* Allocate and initialize new vcpu structure. */ vcpu =calloc (1 ,sizeof (*vcpu));
Signature · 1 line
2.35.1.723.g4982287a31-goog
Sean Christopherson
reviewerRFC PATCH 104/105 KVM: selftests: Remove vcpu_state() helper
In reply to Sean Christopherson--- .../selftests/kvm/include/kvm_util_base.h | 1 - tools/testing/selftests/kvm/lib/kvm_util.c | 21 ++----------------- 2 files changed, 2 insertions(+), 20 deletions(-)
tools/testing/selftests/kvm/include/kvm_util_base.h +0 -1
@@ -286,7 +286,6 @@ void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva);vm_paddr_t addr_hva2gpa (struct kvm_vm *vm,void *hva);void *addr_gpa2alias (struct kvm_vm *vm,vm_paddr_t gpa); -struct kvm_run *vcpu_state (struct kvm_vcpu *vcpu);void vcpu_run (struct kvm_vcpu *vcpu);int _vcpu_run (struct kvm_vcpu *vcpu);
tools/testing/selftests/kvm/lib/kvm_util.c +2 -19
@@ -995,19 +995,7 @@ void vm_mem_region_delete(struct kvm_vm *vm, uint32_t slot)__vm_mem_region_delete (vm,memslot2region (vm, slot), true); } -/* -* VCPU mmap Size -* -* Input Args: None -* -* Output Args: None -* -* Return: -* Size of VCPU state -* -* Returns the size of the structure pointed to by the return value -* of vcpu_state(). -*/ +/* Returns the size of a vCPU's kvm_run structure. */ static int vcpu_mmap_sz (void ) {int dev_fd, ret;
@@ -1061,7 +1049,7 @@ struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id) vcpu_mmap_sz(), sizeof(*vcpu->run)); vcpu->run = (struct kvm_run *)mmap (NULL ,vcpu_mmap_sz (),PROT_READ |PROT_WRITE ,MAP_SHARED , vcpu->fd,0 ); -TEST_ASSERT (vcpu->run !=MAP_FAILED ,"mmap vcpu_state failed, " +TEST_ASSERT (vcpu->run !=MAP_FAILED ,"mmap kvm_run page failed, " "vcpu id: %u errno: %i" , vcpu_id, errno);/* Add to linked-list of VCPUs. */
@@ -1390,11 +1378,6 @@ void vm_create_irqchip(struct kvm_vm *vm) vm->has_irqchip = true; } -struct kvm_run *vcpu_state (struct kvm_vcpu *vcpu) -{ -return vcpu->run; -} -int _vcpu_run (struct kvm_vcpu *vcpu) {
Signature · 1 line
2.35.1.723.g4982287a31-goog
Sean Christopherson
reviewerRFC PATCH 105/105 KVM: selftests: Open code and drop kvm_vm accessors
In reply to Sean Christopherson--- .../selftests/kvm/dirty_log_perf_test.c | 2 +- tools/testing/selftests/kvm/dirty_log_test.c | 9 +++---- .../selftests/kvm/include/kvm_util_base.h | 6 ----- .../selftests/kvm/kvm_page_table_test.c | 2 +- tools/testing/selftests/kvm/lib/kvm_util.c | 25 ------------------- .../selftests/kvm/lib/perf_test_util.c | 7 +++--- .../kvm/memslot_modification_stress_test.c | 2 +- .../selftests/kvm/x86_64/hyperv_cpuid.c | 2 +- 8 files changed, 11 insertions(+), 44 deletions(-)
tools/testing/selftests/kvm/dirty_log_perf_test.c +1 -1
@@ -187,7 +187,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)perf_test_set_wr_fract (vm, p->wr_fract); - guest_num_pages = (nr_vcpus * guest_percpu_mem_size) >>vm_get_page_shift (vm); + guest_num_pages = (nr_vcpus * guest_percpu_mem_size) >> vm->page_shift; guest_num_pages =vm_adjust_num_guest_pages (mode, guest_num_pages); host_num_pages =vm_num_host_pages (mode, guest_num_pages); pages_per_slot = host_num_pages / p->slots;
tools/testing/selftests/kvm/dirty_log_test.c +4 -5
@@ -719,21 +719,20 @@ static void run_test(enum vm_guest_mode mode, void *arg) vm =create_vm (mode, &vcpu,2ul << (DIRTY_MEM_BITS -PAGE_SHIFT_4K ), guest_code); - guest_page_size =vm_get_page_size (vm); + guest_page_size = vm->page_size;/* * A little more than 1G of guest page sized pages. Cover the * case where the size is not aligned to 64 pages. */ - guest_num_pages = (1ul << (DIRTY_MEM_BITS - -vm_get_page_shift (vm))) +3 ; + guest_num_pages = (1ul << (DIRTY_MEM_BITS - vm->page_shift)) +3 ; guest_num_pages =vm_adjust_num_guest_pages (mode, guest_num_pages); host_page_size =getpagesize (); host_num_pages =vm_num_host_pages (mode, guest_num_pages);if (!p->phys_offset) { - guest_test_phys_mem = (vm_get_max_gfn (vm) - - guest_num_pages) * guest_page_size; + guest_test_phys_mem = (vm->max_gfn - guest_num_pages) * + guest_page_size; guest_test_phys_mem =align_down (guest_test_phys_mem, host_page_size); }else { guest_test_phys_mem = p->phys_offset;
tools/testing/selftests/kvm/include/kvm_util_base.h +0 -6
@@ -551,13 +551,7 @@ static inline struct kvm_vm *vm_create_with_one_vcpu(struct kvm_vcpu **vcpu,struct kvm_vcpu *vm_recreate_with_one_vcpu (struct kvm_vm *vm); -unsigned int vm_get_page_size (struct kvm_vm *vm); -unsigned int vm_get_page_shift (struct kvm_vm *vm);unsigned long vm_compute_max_gfn (struct kvm_vm *vm); -uint64_t vm_get_max_gfn (struct kvm_vm *vm); -int vm_get_kvm_fd (struct kvm_vm *vm); -int vm_get_fd (struct kvm_vm *vm); -unsigned int vm_calc_num_guest_pages (enum vm_guest_mode mode,size_t size);unsigned int vm_num_host_pages (enum vm_guest_mode mode,unsigned int num_guest_pages);unsigned int vm_num_guest_pages (enum vm_guest_mode mode,unsigned int num_host_pages);
tools/testing/selftests/kvm/kvm_page_table_test.c +1 -1
@@ -260,7 +260,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)/* Align down GPA of the testing memslot */ if (!p->phys_offset) - guest_test_phys_mem = (vm_get_max_gfn (vm) - guest_num_pages) * + guest_test_phys_mem = (vm->max_gfn - guest_num_pages) * guest_page_size;else guest_test_phys_mem = p->phys_offset;
tools/testing/selftests/kvm/lib/kvm_util.c +0 -25
@@ -1814,36 +1814,11 @@ void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva)return addr_gpa2hva (vm,addr_gva2gpa (vm, gva)); } -unsigned int vm_get_page_size (struct kvm_vm *vm) -{ -return vm->page_size; -} - -unsigned int vm_get_page_shift (struct kvm_vm *vm) -{ -return vm->page_shift; -} -unsigned long __attribute__((weak))vm_compute_max_gfn (struct kvm_vm *vm) {return ((1ULL << vm->pa_bits) >> vm->page_shift) -1 ; } -uint64_t vm_get_max_gfn (struct kvm_vm *vm) -{ -return vm->max_gfn; -} - -int vm_get_kvm_fd (struct kvm_vm *vm) -{ -return vm->kvm_fd; -} - -int vm_get_fd (struct kvm_vm *vm) -{ -return vm->fd; -} - static unsigned int vm_calc_num_pages(unsigned int num_pages, unsigned int page_shift, unsigned int new_page_shift,
tools/testing/selftests/kvm/lib/perf_test_util.c +3 -4
@@ -153,14 +153,13 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus,* If there should be more memory in the guest test region than there * can be pages in the guest, it will definitely cause problems. */ -TEST_ASSERT (guest_num_pages <vm_get_max_gfn (vm), +TEST_ASSERT (guest_num_pages < vm->max_gfn,"Requested more guest memory than address space allows.\n" " guest pages: %" PRIx64" max gfn: %" PRIx64" nr_vcpus: %d wss: %" PRIx64"]\n" , - guest_num_pages,vm_get_max_gfn (vm), nr_vcpus, - vcpu_memory_bytes); + guest_num_pages, vm->max_gfn, nr_vcpus, vcpu_memory_bytes); - pta->gpa = (vm_get_max_gfn (vm) - guest_num_pages) * pta->guest_page_size; + pta->gpa = (vm->max_gfn - guest_num_pages) * pta->guest_page_size; pta->gpa =align_down (pta->gpa, backing_src_pagesz);#ifdef __s390x__/* Align to 1M (segment size) */
tools/testing/selftests/kvm/memslot_modification_stress_test.c +1 -1
@@ -75,7 +75,7 @@ static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay,* Add the dummy memslot just below the perf_test_util memslot, which is * at the top of the guest physical address space. */ - gpa = perf_test_args.gpa - pages *vm_get_page_size (vm); + gpa = perf_test_args.gpa - pages * vm->page_size;for (i =0 ; i < nr_modifications; i++) {usleep (delay);
tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +1 -1
@@ -121,7 +121,7 @@ void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu)if (vcpu) ret =__vcpu_ioctl (vcpu,KVM_GET_SUPPORTED_HV_CPUID , &cpuid);else - ret =__kvm_ioctl (vm_get_kvm_fd (vm),KVM_GET_SUPPORTED_HV_CPUID , &cpuid); + ret =__kvm_ioctl (vm->kvm_fd,KVM_GET_SUPPORTED_HV_CPUID , &cpuid);TEST_ASSERT (ret ==-1 && errno ==E2BIG , "%s KVM_GET_SUPPORTED_HV_CPUID didn't fail with -E2BIG when"
Signature · 1 line
2.35.1.723.g4982287a31-goog
Quoted 5 lines · Sean Christopherson
First off, hopefully I didn't just spam you with 106 emails. In theory, unless you're subscribed to LKML, you should see only the cover letter and everything else should be on lore if you want to pull down the mbox (instead of saying "LOL, 105 patches!?!?", or maybe after you say that).
I would not complain at all if next time you cc kvm@ mailing list on all patches too, it would simplify my routine a bit (or just Cc: me if others object).
Quoted 11 lines
This is a (very) early RFC for overhauling KVM's selftests APIs. It's compile tested only (maybe), there are no changelogs, etc...
My end goal with an overhaul is to get to a state where adding new features and writing tests is less painful/disgusting (I feel dirty every time I copy+paste
VCPU_ID). I opted to directly send only the cover letter because most of the individual patches aren't all that interesting, there's still 46 patches even if the per-test conversions are omitted, and it's the final state that I really care about and want to discuss.
Quoted 5 lines
The overarching theme of my take on where to go with selftests is to stop treating tests like second class citizens. Stop hiding vcpu,
kvm_vm, etc... There's no sensitive data/constructs, and the encapsulation has led to really, really bad and difficult to maintain code. E.g. Want to call a vCPUioctl()? Hope you have the VM...
Initially, there was an attempt to make some sort of separation between 'internal' and 'external' APIs in KVM selftests but every new selftest I write proves this separation wrong and I have to either hack-around something or export some previously-internal APIs. My suggestion would be to eliminate this separation and just make everything available to tests.
Another thing is TEST_ASSERT()s inside library routines. Generally, these are helpful as one doesn't need to check the return value. In some cases, however, we'd like to check that something fails and then the usual way seems to be creating a pair of functions like:
int __do_something()
{
int r = try_doing_something();
return r;
}
void do_something()
{
int r = __do_something()
TEST_ASSERT(r == 0, "Doing something failed! %d", r);
}
This works but maybe there's a better way?
FWIW, I've looked at some of the tests which are more familiar to me (evmcs_test, hyperv_features, ...) and the end result looks much better indeed, thanks! I have a couple more new tests in the queue (Hyper-V IPI and TLB flush, see "KVM: x86: hyper-v: Fine-grained TLB flush + Direct TLB flush feature"), we'll have to syncronize one way or another.
Quoted 4 lines
The other theme in the rework is to deduplicate code and try to set us up for success in the future. E.g. provide macros/helpers instead of spamming CTRL-C => CTRL-V (see the -700 LoC).
You'll have to check with test authors that none of them get paid for LoC by their respective employers :-)
Quoted 236 lines
I was hoping to get this into a less shabby state before posting, but I'm I'm going to be OOO for the next few weeks and want to get the ball rolling instead of waiting another month or so.
Based on an older version of kvm/queue. The full thing is also on github:
https://github.com/sean-jc/linux.git x86/selftests_overhaul
Cc Paolo Bonzini <[email protected]>Cc Vitaly Kuznetsov <[email protected]>Cc Wanpeng Li <[email protected]>Cc Jim Mattson <[email protected]>Cc Joerg Roedel <[email protected]>Cc Andrew Jones <[email protected]>Cc Thomas Huth <[email protected]>Cc Janosch Frank <[email protected]>Cc Claudio Imbrenda <[email protected]>Cc David Hildenbrand <[email protected]>Cc David Matlack <[email protected]>Cc Ben Gardon <[email protected]>Cc Oliver Upton <[email protected]>Sean Christopherson (105):
KVM: selftests: Fix buggy check intest_v3_new_redist_regions()
KVM: selftests: Always open VM file descriptors withO_RDWR
KVM: selftest: Add another underscore to inner ioctl helpers
KVM: selftests: Makevcpu_ioctl()a wrapper to pretty print ioctl name
KVM: selftests: Drop @mode from commonvm_create()helper
KVM: selftests: Splitvcpu_set_nested_state()into two helpers
KVM: selftests: Addhyperv_svm_testtest binary to .gitignore
KVM: sefltests: Usevcpu_ioctl()and__vcpu_ioctl()helpers
KVM: selftests: Add__vcpu_run()helper
KVM: selftests: Usevcpu_access_device_attr()in arm64 code
KVM: selftests: Removevcpu_get_fd()
KVM: selftests: Addvcpu_get()to retrieve and assert on vCPU
existence
KVM: selftests: Makevm_ioctl()a wrapper to pretty print ioctl name
KVM: sefltests: Usevm_ioctl()and__vm_ioctl()helpers
KVM: selftests: Makekvm_ioctl()a wrapper to pretty print ioctl name
KVM: selftests: Usekvm_ioctl()helpers
KVM: selftests: Make x86-64's register dump helpers static
KVM: selftests: Get rid ofkvm_util_internal.h
KVM: selftests: UseKVM_IOCTL_ERROR()for one-off arm64 ioctls
KVM: selftests: Drop @test param fromkvm_create_device()
KVM: selftests: MoveKVM_CREATE_DEVICE_TESTcode to separate helper
KVM: selftests: Multiplex return code and fd in__kvm_create_device()
KVM: selftests: RenameKVM_HAS_DEVICE_ATTRhelpers for consistency
KVM: selftests: Drop 'int' return from asserting*_device_has_attr()
KVM: selftests: Split get/setdevice_attrhelpers
KVM: selftests: Add a VM backpointer to 'struct vcpu'
KVM: selftests: Add vm_create_*() variants to expose/return 'struct
vcpu'
KVM: selftests: Rename vcpu.state => vcpu.run
KVM: selftests: Rename 'struct vcpu' to 'structkvm_vcpu'
KVM: selftests: Return the created vCPU fromvm_vcpu_add()
KVM: selftests: Convertmemslot_perf_testaway fromVCPU_ID
KVM: selftests: Convertrseq_testaway fromVCPU_ID
KVM: selftests: Convertxss_msr_testaway fromVCPU_ID
KVM: selftests: Convertvmx_preemption_timer_testaway fromVCPU_ID
KVM: selftests: Convertvmx_pmu_msrs_testaway fromVCPU_ID
KVM: selftests: Convertvmx_set_nested_state_testaway fromVCPU_ID
KVM: selftests: Convertvmx_tsc_adjust_testaway fromVCPU_ID
KVM: selftests: Convertmmu_role_testaway fromVCPU_ID
KVM: selftests: Convertpmu_event_filter_testaway fromVCPU_ID
KVM: selftests: Convertsmm_testaway fromVCPU_ID
KVM: selftests: Convertstate_testaway fromVCPU_ID
KVM: selftests: Convertsvm_int_ctl_testaway fromVCPU_ID
KVM: selftests: Convertsvm_vmcall_testaway fromVCPU_ID
KVM: selftests: Convertsync_regs_testaway fromVCPU_ID
KVM: selftests: Converthyperv_cpuidaway fromVCPU_ID
KVM: selftests: Convertkvm_pv_testaway fromVCPU_ID
KVM: selftests: Convertplatform_info_testaway fromVCPU_ID
KVM: selftests: Convertvmx_nested_tsc_scaling_testaway fromVCPU_ID
KVM: selftests: Convertset_sregs_testaway fromVCPU_ID
KVM: selftests: Convertvmx_dirty_log_testaway fromVCPU_ID
KVM: selftests: Convertvmx_close_while_nested_testaway fromVCPU_ID
KVM: selftests: Convertvmx_apic_access_testaway fromVCPU_ID
KVM: selftests: Convertuserspace_msr_exit_testaway fromVCPU_ID
KVM: selftests: Convertvmx_exception_with_invalid_guest_stateaway
fromVCPU_ID
KVM: selftests: Converttsc_msrs_testaway fromVCPU_ID
KVM: selftests: Convertkvm_clock_testaway fromVCPU_ID
KVM: selftests: Converthyperv_svm_testaway fromVCPU_ID
KVM: selftests: Converthyperv_featuresaway fromVCPU_ID
KVM: selftests: Converthyperv_clockaway fromVCPU_ID
KVM: selftests: Convertevmcs_testaway fromVCPU_ID
KVM: selftests: Convertemulator_error_testaway fromVCPU_ID
KVM: selftests: Convertdebug_regsaway fromVCPU_ID
KVM: selftests: Add proper helper for advancing RIP indebug_regs
KVM: selftests: Convertamx_testaway fromVCPU_ID
KVM: selftests: Convertcr4_cpuid_sync_testaway fromVCPU_ID
KVM: selftests: Convertcpuid_testaway fromVCPU_ID
KVM: selftests: Convertuserspace_io_testaway fromVCPU_ID
KVM: selftests: Convertvmx_invalid_nested_guest_stateaway from
VCPU_ID
KVM: selftests: Convertxen_vmcall_testaway fromVCPU_ID
KVM: selftests: Convertxen_shinfo_testaway fromVCPU_ID
KVM: selftests: Convertdirty_log_testaway fromVCPU_ID
KVM: selftests: Convertset_memory_region_testaway fromVCPU_ID
KVM: selftests: Convertsystem_counter_offset_testaway fromVCPU_ID
KVM: selftests: Convert debug-exceptions away fromVCPU_ID
KVM: selftests: Convertvgic_irq.cinclude/aarch64/vgic.h
lib/aarch64/vgicaway fromVCPU_ID
KVM: selftests: Make arm64'sguest_get_vcpuid()declaration arm64-only
KVM: selftests: Movevm_is_unrestricted_guest()to x86-64
KVM: selftests: Add "arch" to common utils that have arch
implementations
KVM: selftests: Return created vcpu fromvm_vcpu_add_default()
KVM: selftests: Rename vm_vcpu_add* helpers to better show
relationships
KVM: selftests: Convertset_boot_cpu_idaway fromVCPU_ID
KVM: selftests: Convertpsci_cpu_on_testaway fromVCPU_ID
KVM: selftests: Converthardware_disable_testaway fromVCPU_ID
KVM: selftests: Add VM creation helper that "returns" vCPUs
KVM: selftests: Convertsteal_timeaway fromVCPU_ID
KVM: selftests: Convertarch_timeraway fromVCPU_ID
KVM: selftests: Fix typo invgic_inittest
KVM: selftests: Convertvgic_initaway from
vm_create_default_with_vcpus()
KVM: selftests: Convertxapic_ipi_testaway from*_VCPU_ID
KVM: selftests: Convertsync_regs_testaway fromVCPU_ID
KVM: selftests: Convert resets away fromVCPU_ID
KVM: selftests: Convert memop away fromVCPU_ID
KVM: selftests: Convert s390x/diag318_test_handler away fromVCPU_ID
KVM: selftests: Drop vm_create_default* helpers
KVM: selftests: Drop vcpuids param from VM creators
KVM: selftests: Convertkvm_page_table_testaway from reliance on
vcpu_id
KVM: selftests: Convertkvm_binary_stats_testaway fromVCPU_ID
KVM: selftests: Convert get-reg-list away fromVCPU_ID
KVM: selftests: Stop conflating vCPU index and ID in perf tests
KVM: selftests: Removevcpu_get()usage fromdirty_log_test
KVM: selftests: Require vCPU output array when creating VM with vCPUs
KVM: selftest: Purge vm+vcpu_id == vcpu silliness
KVM: selftests: Dropvcpu_get(), renamevcpu_find()=>vcpu_exists()
KVM: selftests: Removevcpu_state()helper
KVM: selftests: Open code and dropkvm_vmaccessorstools/testing/selftests/kvm/.gitignore | 1 + .../selftests/kvm/aarch64/arch_timer.c | 68 +- .../selftests/kvm/aarch64/debug-exceptions.c | 17 +- .../selftests/kvm/aarch64/get-reg-list.c | 19 +- .../selftests/kvm/aarch64/psci_cpu_on_test.c | 22 +- .../testing/selftests/kvm/aarch64/vgic_init.c | 369 +++---- .../testing/selftests/kvm/aarch64/vgic_irq.c | 30 +- .../selftests/kvm/access_tracking_perf_test.c | 81 +- .../selftests/kvm/demand_paging_test.c | 39 +- .../selftests/kvm/dirty_log_perf_test.c | 42 +- tools/testing/selftests/kvm/dirty_log_test.c | 80 +- .../selftests/kvm/hardware_disable_test.c | 27 +- .../selftests/kvm/include/aarch64/processor.h | 20 +- .../selftests/kvm/include/aarch64/vgic.h | 6 +- .../selftests/kvm/include/kvm_util_base.h | 677 ++++++++---- .../selftests/kvm/include/perf_test_util.h | 5 +- .../selftests/kvm/include/riscv/processor.h | 8 +- .../selftests/kvm/include/ucall_common.h | 2 +- .../selftests/kvm/include/x86_64/evmcs.h | 2 +- .../selftests/kvm/include/x86_64/processor.h | 52 +- .../selftests/kvm/kvm_binary_stats_test.c | 27 +- .../selftests/kvm/kvm_create_max_vcpus.c | 4 +- .../selftests/kvm/kvm_page_table_test.c | 66 +- .../selftests/kvm/lib/aarch64/processor.c | 79 +- .../testing/selftests/kvm/lib/aarch64/ucall.c | 9 +- .../testing/selftests/kvm/lib/aarch64/vgic.c | 44 +- tools/testing/selftests/kvm/lib/elf.c | 1 - tools/testing/selftests/kvm/lib/guest_modes.c | 6 +- tools/testing/selftests/kvm/lib/kvm_util.c | 981 +++--------------- .../selftests/kvm/lib/kvm_util_internal.h | 128 --- .../selftests/kvm/lib/perf_test_util.c | 84 +- .../selftests/kvm/lib/riscv/processor.c | 110 +- tools/testing/selftests/kvm/lib/riscv/ucall.c | 7 +- .../kvm/lib/s390x/diag318_test_handler.c | 9 +- .../selftests/kvm/lib/s390x/processor.c | 44 +- tools/testing/selftests/kvm/lib/s390x/ucall.c | 8 +- .../selftests/kvm/lib/x86_64/processor.c | 311 ++---- tools/testing/selftests/kvm/lib/x86_64/svm.c | 1 - .../testing/selftests/kvm/lib/x86_64/ucall.c | 10 +- tools/testing/selftests/kvm/lib/x86_64/vmx.c | 5 +- .../kvm/memslot_modification_stress_test.c | 13 +- .../testing/selftests/kvm/memslot_perf_test.c | 28 +- tools/testing/selftests/kvm/rseq_test.c | 9 +- tools/testing/selftests/kvm/s390x/memop.c | 31 +- tools/testing/selftests/kvm/s390x/resets.c | 137 +-- .../selftests/kvm/s390x/sync_regs_test.c | 37 +- .../selftests/kvm/set_memory_region_test.c | 45 +- tools/testing/selftests/kvm/steal_time.c | 120 +-- .../kvm/system_counter_offset_test.c | 29 +- tools/testing/selftests/kvm/x86_64/amx_test.c | 33 +- .../testing/selftests/kvm/x86_64/cpuid_test.c | 29 +- .../kvm/x86_64/cr4_cpuid_sync_test.c | 17 +- .../testing/selftests/kvm/x86_64/debug_regs.c | 72 +- .../kvm/x86_64/emulator_error_test.c | 65 +- .../testing/selftests/kvm/x86_64/evmcs_test.c | 51 +- .../kvm/x86_64/get_msr_index_features.c | 16 +- .../selftests/kvm/x86_64/hyperv_clock.c | 25 +- .../selftests/kvm/x86_64/hyperv_cpuid.c | 25 +- .../selftests/kvm/x86_64/hyperv_features.c | 51 +- .../selftests/kvm/x86_64/hyperv_svm_test.c | 14 +- .../selftests/kvm/x86_64/kvm_clock_test.c | 23 +- .../selftests/kvm/x86_64/kvm_pv_test.c | 25 +- .../selftests/kvm/x86_64/mmio_warning_test.c | 6 +- .../selftests/kvm/x86_64/mmu_role_test.c | 20 +- .../selftests/kvm/x86_64/platform_info_test.c | 34 +- .../kvm/x86_64/pmu_event_filter_test.c | 60 +- .../selftests/kvm/x86_64/set_boot_cpu_id.c | 87 +- .../selftests/kvm/x86_64/set_sregs_test.c | 47 +- .../selftests/kvm/x86_64/sev_migrate_tests.c | 17 +- tools/testing/selftests/kvm/x86_64/smm_test.c | 37 +- .../testing/selftests/kvm/x86_64/state_test.c | 29 +- .../selftests/kvm/x86_64/svm_int_ctl_test.c | 21 +- .../selftests/kvm/x86_64/svm_vmcall_test.c | 16 +- .../selftests/kvm/x86_64/sync_regs_test.c | 52 +- .../selftests/kvm/x86_64/tsc_msrs_test.c | 35 +- .../selftests/kvm/x86_64/userspace_io_test.c | 18 +- .../kvm/x86_64/userspace_msr_exit_test.c | 165 ++- .../kvm/x86_64/vmx_apic_access_test.c | 18 +- .../kvm/x86_64/vmx_close_while_nested_test.c | 17 +- .../selftests/kvm/x86_64/vmx_dirty_log_test.c | 13 +- .../vmx_exception_with_invalid_guest_state.c | 62 +- .../x86_64/vmx_invalid_nested_guest_state.c | 18 +- .../kvm/x86_64/vmx_nested_tsc_scaling_test.c | 19 +- .../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 25 +- .../kvm/x86_64/vmx_preemption_timer_test.c | 30 +- .../kvm/x86_64/vmx_set_nested_state_test.c | 86 +- .../kvm/x86_64/vmx_tsc_adjust_test.c | 12 +- .../selftests/kvm/x86_64/xapic_ipi_test.c | 48 +- .../selftests/kvm/x86_64/xen_shinfo_test.c | 35 +- .../selftests/kvm/x86_64/xen_vmcall_test.c | 17 +- .../selftests/kvm/x86_64/xss_msr_test.c | 10 +- 91 files changed, 2363 insertions(+), 3087 deletions(-) delete mode 100644 tools/testing/selftests/kvm/lib/kvm_util_internal.hbase-commit:
f6ae04ddb347f526b4620d1053690ecf1f87d77f
Signature · 1 line
Vitaly
Quoted 15 lines · Sean Christopherson
First off, hopefully I didn't just spam you with 106 emails. In theory, unless you're subscribed to LKML, you should see only the cover letter and everything else should be on lore if you want to pull down the mbox (instead of saying "LOL, 105 patches!?!?", or maybe after you say that).
This is a (very) early RFC for overhauling KVM's selftests APIs. It's compile tested only (maybe), there are no changelogs, etc...
My end goal with an overhaul is to get to a state where adding new features and writing tests is less painful/disgusting (I feel dirty every time I copy+paste
VCPU_ID). I opted to directly send only the cover letter because most of the individual patches aren't all that interesting, there's still 46 patches even if the per-test conversions are omitted, and it's the final state that I really care about and want to discuss.
Quoted 5 lines
The overarching theme of my take on where to go with selftests is to stop treating tests like second class citizens. Stop hiding vcpu,
kvm_vm, etc... There's no sensitive data/constructs, and the encapsulation has led to really, really bad and difficult to maintain code. E.g. Want to call a vCPUioctl()? Hope you have the VM...
Ack to dropping the privateness of structs.
Quoted 4 lines
The other theme in the rework is to deduplicate code and try to set us up for success in the future. E.g. provide macros/helpers instead of spamming CTRL-C => CTRL-V (see the -700 LoC).
Ack to more helper functions. I'm not sure what the best way to document or provide examples for the API is though. Currently we mostly rely on test writers to read other tests (I suppose the function headers help a bit, but, IMO, not much). Maybe we need a heavily commented example.c that can help test writers get started, along with better API function descriptions for anything exported from the lib.
Quoted 4 lines
I was hoping to get this into a less shabby state before posting, but I'm I'm going to be OOO for the next few weeks and want to get the ball rolling instead of waiting another month or so.
Ideas look good to me, but I'll wait for the cleaned up series posted to the KVM ML to review it. Also, I see at least patch 1/105 is a fix. It'd be nice to post all fixes separately so they get in sooner than later.
Oh, some of the renaming doesn't look all that important to me, like prefixing with kvm_ or adding _arch_, but I don't have strong preferences on the names. Also, for the _arch_ functions it'd be nice to create common, weak functions which the arch must override. The common function would just assert. That should help people who want to port to other architectures determine what they need to implement first. And, for anything which an arch can optionally adopt a common implementation, *not* naming the common function with _arch_, but still defining it as weak, would make sense to me too.
Thanks,
drew
Quoted 29 lines · Andrew Jones
Quoted 15 lines · Sean Christopherson
First off, hopefully I didn't just spam you with 106 emails. In theory, unless you're subscribed to LKML, you should see only the cover letter and everything else should be on lore if you want to pull down the mbox (instead of saying "LOL, 105 patches!?!?", or maybe after you say that).
This is a (very) early RFC for overhauling KVM's selftests APIs. It's compile tested only (maybe), there are no changelogs, etc...
My end goal with an overhaul is to get to a state where adding new features and writing tests is less painful/disgusting (I feel dirty every time I copy+paste
VCPU_ID). I opted to directly send only the cover letter because most of the individual patches aren't all that interesting, there's still 46 patches even if the per-test conversions are omitted, and it's the final state that I really care about and want to discuss.Quoted 5 lines
The overarching theme of my take on where to go with selftests is to stop treating tests like second class citizens. Stop hiding vcpu,
kvm_vm, etc... There's no sensitive data/constructs, and the encapsulation has led to really, really bad and difficult to maintain code. E.g. Want to call a vCPUioctl()? Hope you have the VM...Ack to dropping the privateness of structs.
Quoted 4 lines
The other theme in the rework is to deduplicate code and try to set us up for success in the future. E.g. provide macros/helpers instead of spamming CTRL-C => CTRL-V (see the -700 LoC).
Quoted 7 lines
Ack to more helper functions. I'm not sure what the best way to document or provide examples for the API is though. Currently we mostly rely on test writers to read other tests (I suppose the function headers help a bit, but, IMO, not much). Maybe we need a heavily commented
example.cthat can help test writers get started, along with better API function descriptions for anything exported from the lib.
+1. Definitely guilty of copy/pasting a test then tweaking to fit the problem I'm trying to solve. A barebones example would be helpful.
Haven't looked at the patches yet, but one of my whines about the selftests is that every test winds up explicitly handling exit reasons that percolate up from the libraries. Perhaps some helpers around ABORTs and the like would be useful (and maybe Sean already did this!)
Quoted 9 lines
Quoted 4 lines
I was hoping to get this into a less shabby state before posting, but I'm I'm going to be OOO for the next few weeks and want to get the ball rolling instead of waiting another month or so.
Ideas look good to me, but I'll wait for the cleaned up series posted to the KVM ML to review it. Also, I see at least patch 1/105 is a fix. It'd be nice to post all fixes separately so they get in sooner than later.
Quoted 9 lines
Oh, some of the renaming doesn't look all that important to me, like prefixing with
kvm_or adding _arch_, but I don't have strong preferences on the names. Also, for the _arch_ functions it'd be nice to create common, weak functions which the arch must override. The common function would just assert. That should help people who want to port to other architectures determine what they need to implement first. And, for anything which an arch can optionally adopt a common implementation, *not* naming the common function with _arch_, but still defining it as weak, would make sense to me too.
I think it may make more sense to only define optional functions as weak and let the compiler do the screaming for the required ones. Only discovering that functions are missing at runtime could be annoying if you're cross-compiling and running on a separate host with a different architecture.
--
Oliver
Quoted 7 lines · Oliver Upton
I think it may make more sense to only define optional functions as weak and let the compiler do the screaming for the required ones. Only discovering that functions are missing at runtime could be annoying if you're cross-compiling and running on a separate host with a different architecture.
Ah, indeed, no reason to push the lack of required arch functions to runtime detection, compile time is much better. And, in those cases, the _arch_ naming will also provide a nice hint that one must implement it in arch specific code.
Thanks,
drew
Sean Christopherson
reviewerQuoted 2 lines · Andrew Jones
Also, I see at least patch 1/105 is a fix. It'd be nice to post all fixes separately so they get in sooner than later.
Yeah, and I'm pretty sure there's at least one other arm64 bug fix buried in the series. I'll get those extracted and posted separately.
Quoted 5 lines · Sean Christopherson
First off, hopefully I didn't just spam you with 106 emails. In theory, unless you're subscribed to LKML, you should see only the cover letter and everything else should be on lore if you want to pull down the mbox (instead of saying "LOL, 105 patches!?!?", or maybe after you say that).
FWIW I'm fine with receiving a large number of patches and it would simplify my workflow for reviewing (even if just at a high level).
Quoted 17 lines
This is a (very) early RFC for overhauling KVM's selftests APIs. It's compile tested only (maybe), there are no changelogs, etc...
My end goal with an overhaul is to get to a state where adding new features and writing tests is less painful/disgusting (I feel dirty every time I copy+paste
VCPU_ID). I opted to directly send only the cover letter because most of the individual patches aren't all that interesting, there's still 46 patches even if the per-test conversions are omitted, and it's the final state that I really care about and want to discuss.The overarching theme of my take on where to go with selftests is to stop treating tests like second class citizens. Stop hiding vcpu,
kvm_vm, etc... There's no sensitive data/constructs, and the encapsulation has led to really, really bad and difficult to maintain code. E.g. Want to call a vCPUioctl()? Hope you have the VM...
Quoted 7 lines
The other theme in the rework is to deduplicate code and try to set us up for success in the future. E.g. provide macros/helpers instead of spamming CTRL-C => CTRL-V (see the -700 LoC).
I was hoping to get this into a less shabby state before posting, but I'm I'm going to be OOO for the next few weeks and want to get the ball rolling instead of waiting another month or so.
Honestly it looks great. Especially "KVM: selftest: Purge vm+vcpu_id == vcpu silliness". I'm sure we can quibble over some specific details in the patches but given the size of the refactor I'd love to get this in so we can start building on top of it. Otherwise it's going to bitrot real fast.
Quoted 235 lines
Based on an older version of kvm/queue. The full thing is also on github:
https://github.com/sean-jc/linux.git x86/selftests_overhaul
Cc Paolo Bonzini <[email protected]>Cc Vitaly Kuznetsov <[email protected]>Cc Wanpeng Li <[email protected]>Cc Jim Mattson <[email protected]>Cc Joerg Roedel <[email protected]>Cc Andrew Jones <[email protected]>Cc Thomas Huth <[email protected]>Cc Janosch Frank <[email protected]>Cc Claudio Imbrenda <[email protected]>Cc David Hildenbrand <[email protected]>Cc David Matlack <[email protected]>Cc Ben Gardon <[email protected]>Cc Oliver Upton <[email protected]>Sean Christopherson (105):
KVM: selftests: Fix buggy check intest_v3_new_redist_regions()
KVM: selftests: Always open VM file descriptors withO_RDWR
KVM: selftest: Add another underscore to inner ioctl helpers
KVM: selftests: Makevcpu_ioctl()a wrapper to pretty print ioctl name
KVM: selftests: Drop @mode from commonvm_create()helper
KVM: selftests: Splitvcpu_set_nested_state()into two helpers
KVM: selftests: Addhyperv_svm_testtest binary to .gitignore
KVM: sefltests: Usevcpu_ioctl()and__vcpu_ioctl()helpers
KVM: selftests: Add__vcpu_run()helper
KVM: selftests: Usevcpu_access_device_attr()in arm64 code
KVM: selftests: Removevcpu_get_fd()
KVM: selftests: Addvcpu_get()to retrieve and assert on vCPU
existence
KVM: selftests: Makevm_ioctl()a wrapper to pretty print ioctl name
KVM: sefltests: Usevm_ioctl()and__vm_ioctl()helpers
KVM: selftests: Makekvm_ioctl()a wrapper to pretty print ioctl name
KVM: selftests: Usekvm_ioctl()helpers
KVM: selftests: Make x86-64's register dump helpers static
KVM: selftests: Get rid ofkvm_util_internal.h
KVM: selftests: UseKVM_IOCTL_ERROR()for one-off arm64 ioctls
KVM: selftests: Drop @test param fromkvm_create_device()
KVM: selftests: MoveKVM_CREATE_DEVICE_TESTcode to separate helper
KVM: selftests: Multiplex return code and fd in__kvm_create_device()
KVM: selftests: RenameKVM_HAS_DEVICE_ATTRhelpers for consistency
KVM: selftests: Drop 'int' return from asserting*_device_has_attr()
KVM: selftests: Split get/setdevice_attrhelpers
KVM: selftests: Add a VM backpointer to 'struct vcpu'
KVM: selftests: Add vm_create_*() variants to expose/return 'struct
vcpu'
KVM: selftests: Rename vcpu.state => vcpu.run
KVM: selftests: Rename 'struct vcpu' to 'structkvm_vcpu'
KVM: selftests: Return the created vCPU fromvm_vcpu_add()
KVM: selftests: Convertmemslot_perf_testaway fromVCPU_ID
KVM: selftests: Convertrseq_testaway fromVCPU_ID
KVM: selftests: Convertxss_msr_testaway fromVCPU_ID
KVM: selftests: Convertvmx_preemption_timer_testaway fromVCPU_ID
KVM: selftests: Convertvmx_pmu_msrs_testaway fromVCPU_ID
KVM: selftests: Convertvmx_set_nested_state_testaway fromVCPU_ID
KVM: selftests: Convertvmx_tsc_adjust_testaway fromVCPU_ID
KVM: selftests: Convertmmu_role_testaway fromVCPU_ID
KVM: selftests: Convertpmu_event_filter_testaway fromVCPU_ID
KVM: selftests: Convertsmm_testaway fromVCPU_ID
KVM: selftests: Convertstate_testaway fromVCPU_ID
KVM: selftests: Convertsvm_int_ctl_testaway fromVCPU_ID
KVM: selftests: Convertsvm_vmcall_testaway fromVCPU_ID
KVM: selftests: Convertsync_regs_testaway fromVCPU_ID
KVM: selftests: Converthyperv_cpuidaway fromVCPU_ID
KVM: selftests: Convertkvm_pv_testaway fromVCPU_ID
KVM: selftests: Convertplatform_info_testaway fromVCPU_ID
KVM: selftests: Convertvmx_nested_tsc_scaling_testaway fromVCPU_ID
KVM: selftests: Convertset_sregs_testaway fromVCPU_ID
KVM: selftests: Convertvmx_dirty_log_testaway fromVCPU_ID
KVM: selftests: Convertvmx_close_while_nested_testaway fromVCPU_ID
KVM: selftests: Convertvmx_apic_access_testaway fromVCPU_ID
KVM: selftests: Convertuserspace_msr_exit_testaway fromVCPU_ID
KVM: selftests: Convertvmx_exception_with_invalid_guest_stateaway
fromVCPU_ID
KVM: selftests: Converttsc_msrs_testaway fromVCPU_ID
KVM: selftests: Convertkvm_clock_testaway fromVCPU_ID
KVM: selftests: Converthyperv_svm_testaway fromVCPU_ID
KVM: selftests: Converthyperv_featuresaway fromVCPU_ID
KVM: selftests: Converthyperv_clockaway fromVCPU_ID
KVM: selftests: Convertevmcs_testaway fromVCPU_ID
KVM: selftests: Convertemulator_error_testaway fromVCPU_ID
KVM: selftests: Convertdebug_regsaway fromVCPU_ID
KVM: selftests: Add proper helper for advancing RIP indebug_regs
KVM: selftests: Convertamx_testaway fromVCPU_ID
KVM: selftests: Convertcr4_cpuid_sync_testaway fromVCPU_ID
KVM: selftests: Convertcpuid_testaway fromVCPU_ID
KVM: selftests: Convertuserspace_io_testaway fromVCPU_ID
KVM: selftests: Convertvmx_invalid_nested_guest_stateaway from
VCPU_ID
KVM: selftests: Convertxen_vmcall_testaway fromVCPU_ID
KVM: selftests: Convertxen_shinfo_testaway fromVCPU_ID
KVM: selftests: Convertdirty_log_testaway fromVCPU_ID
KVM: selftests: Convertset_memory_region_testaway fromVCPU_ID
KVM: selftests: Convertsystem_counter_offset_testaway fromVCPU_ID
KVM: selftests: Convert debug-exceptions away fromVCPU_ID
KVM: selftests: Convertvgic_irq.cinclude/aarch64/vgic.h
lib/aarch64/vgicaway fromVCPU_ID
KVM: selftests: Make arm64'sguest_get_vcpuid()declaration arm64-only
KVM: selftests: Movevm_is_unrestricted_guest()to x86-64
KVM: selftests: Add "arch" to common utils that have arch
implementations
KVM: selftests: Return created vcpu fromvm_vcpu_add_default()
KVM: selftests: Rename vm_vcpu_add* helpers to better show
relationships
KVM: selftests: Convertset_boot_cpu_idaway fromVCPU_ID
KVM: selftests: Convertpsci_cpu_on_testaway fromVCPU_ID
KVM: selftests: Converthardware_disable_testaway fromVCPU_ID
KVM: selftests: Add VM creation helper that "returns" vCPUs
KVM: selftests: Convertsteal_timeaway fromVCPU_ID
KVM: selftests: Convertarch_timeraway fromVCPU_ID
KVM: selftests: Fix typo invgic_inittest
KVM: selftests: Convertvgic_initaway from
vm_create_default_with_vcpus()
KVM: selftests: Convertxapic_ipi_testaway from*_VCPU_ID
KVM: selftests: Convertsync_regs_testaway fromVCPU_ID
KVM: selftests: Convert resets away fromVCPU_ID
KVM: selftests: Convert memop away fromVCPU_ID
KVM: selftests: Convert s390x/diag318_test_handler away fromVCPU_ID
KVM: selftests: Drop vm_create_default* helpers
KVM: selftests: Drop vcpuids param from VM creators
KVM: selftests: Convertkvm_page_table_testaway from reliance on
vcpu_id
KVM: selftests: Convertkvm_binary_stats_testaway fromVCPU_ID
KVM: selftests: Convert get-reg-list away fromVCPU_ID
KVM: selftests: Stop conflating vCPU index and ID in perf tests
KVM: selftests: Removevcpu_get()usage fromdirty_log_test
KVM: selftests: Require vCPU output array when creating VM with vCPUs
KVM: selftest: Purge vm+vcpu_id == vcpu silliness
KVM: selftests: Dropvcpu_get(), renamevcpu_find()=>vcpu_exists()
KVM: selftests: Removevcpu_state()helper
KVM: selftests: Open code and dropkvm_vmaccessorstools/testing/selftests/kvm/.gitignore | 1 + .../selftests/kvm/aarch64/arch_timer.c | 68 +- .../selftests/kvm/aarch64/debug-exceptions.c | 17 +- .../selftests/kvm/aarch64/get-reg-list.c | 19 +- .../selftests/kvm/aarch64/psci_cpu_on_test.c | 22 +- .../testing/selftests/kvm/aarch64/vgic_init.c | 369 +++---- .../testing/selftests/kvm/aarch64/vgic_irq.c | 30 +- .../selftests/kvm/access_tracking_perf_test.c | 81 +- .../selftests/kvm/demand_paging_test.c | 39 +- .../selftests/kvm/dirty_log_perf_test.c | 42 +- tools/testing/selftests/kvm/dirty_log_test.c | 80 +- .../selftests/kvm/hardware_disable_test.c | 27 +- .../selftests/kvm/include/aarch64/processor.h | 20 +- .../selftests/kvm/include/aarch64/vgic.h | 6 +- .../selftests/kvm/include/kvm_util_base.h | 677 ++++++++---- .../selftests/kvm/include/perf_test_util.h | 5 +- .../selftests/kvm/include/riscv/processor.h | 8 +- .../selftests/kvm/include/ucall_common.h | 2 +- .../selftests/kvm/include/x86_64/evmcs.h | 2 +- .../selftests/kvm/include/x86_64/processor.h | 52 +- .../selftests/kvm/kvm_binary_stats_test.c | 27 +- .../selftests/kvm/kvm_create_max_vcpus.c | 4 +- .../selftests/kvm/kvm_page_table_test.c | 66 +- .../selftests/kvm/lib/aarch64/processor.c | 79 +- .../testing/selftests/kvm/lib/aarch64/ucall.c | 9 +- .../testing/selftests/kvm/lib/aarch64/vgic.c | 44 +- tools/testing/selftests/kvm/lib/elf.c | 1 - tools/testing/selftests/kvm/lib/guest_modes.c | 6 +- tools/testing/selftests/kvm/lib/kvm_util.c | 981 +++--------------- .../selftests/kvm/lib/kvm_util_internal.h | 128 --- .../selftests/kvm/lib/perf_test_util.c | 84 +- .../selftests/kvm/lib/riscv/processor.c | 110 +- tools/testing/selftests/kvm/lib/riscv/ucall.c | 7 +- .../kvm/lib/s390x/diag318_test_handler.c | 9 +- .../selftests/kvm/lib/s390x/processor.c | 44 +- tools/testing/selftests/kvm/lib/s390x/ucall.c | 8 +- .../selftests/kvm/lib/x86_64/processor.c | 311 ++---- tools/testing/selftests/kvm/lib/x86_64/svm.c | 1 - .../testing/selftests/kvm/lib/x86_64/ucall.c | 10 +- tools/testing/selftests/kvm/lib/x86_64/vmx.c | 5 +- .../kvm/memslot_modification_stress_test.c | 13 +- .../testing/selftests/kvm/memslot_perf_test.c | 28 +- tools/testing/selftests/kvm/rseq_test.c | 9 +- tools/testing/selftests/kvm/s390x/memop.c | 31 +- tools/testing/selftests/kvm/s390x/resets.c | 137 +-- .../selftests/kvm/s390x/sync_regs_test.c | 37 +- .../selftests/kvm/set_memory_region_test.c | 45 +- tools/testing/selftests/kvm/steal_time.c | 120 +-- .../kvm/system_counter_offset_test.c | 29 +- tools/testing/selftests/kvm/x86_64/amx_test.c | 33 +- .../testing/selftests/kvm/x86_64/cpuid_test.c | 29 +- .../kvm/x86_64/cr4_cpuid_sync_test.c | 17 +- .../testing/selftests/kvm/x86_64/debug_regs.c | 72 +- .../kvm/x86_64/emulator_error_test.c | 65 +- .../testing/selftests/kvm/x86_64/evmcs_test.c | 51 +- .../kvm/x86_64/get_msr_index_features.c | 16 +- .../selftests/kvm/x86_64/hyperv_clock.c | 25 +- .../selftests/kvm/x86_64/hyperv_cpuid.c | 25 +- .../selftests/kvm/x86_64/hyperv_features.c | 51 +- .../selftests/kvm/x86_64/hyperv_svm_test.c | 14 +- .../selftests/kvm/x86_64/kvm_clock_test.c | 23 +- .../selftests/kvm/x86_64/kvm_pv_test.c | 25 +- .../selftests/kvm/x86_64/mmio_warning_test.c | 6 +- .../selftests/kvm/x86_64/mmu_role_test.c | 20 +- .../selftests/kvm/x86_64/platform_info_test.c | 34 +- .../kvm/x86_64/pmu_event_filter_test.c | 60 +- .../selftests/kvm/x86_64/set_boot_cpu_id.c | 87 +- .../selftests/kvm/x86_64/set_sregs_test.c | 47 +- .../selftests/kvm/x86_64/sev_migrate_tests.c | 17 +- tools/testing/selftests/kvm/x86_64/smm_test.c | 37 +- .../testing/selftests/kvm/x86_64/state_test.c | 29 +- .../selftests/kvm/x86_64/svm_int_ctl_test.c | 21 +- .../selftests/kvm/x86_64/svm_vmcall_test.c | 16 +- .../selftests/kvm/x86_64/sync_regs_test.c | 52 +- .../selftests/kvm/x86_64/tsc_msrs_test.c | 35 +- .../selftests/kvm/x86_64/userspace_io_test.c | 18 +- .../kvm/x86_64/userspace_msr_exit_test.c | 165 ++- .../kvm/x86_64/vmx_apic_access_test.c | 18 +- .../kvm/x86_64/vmx_close_while_nested_test.c | 17 +- .../selftests/kvm/x86_64/vmx_dirty_log_test.c | 13 +- .../vmx_exception_with_invalid_guest_state.c | 62 +- .../x86_64/vmx_invalid_nested_guest_state.c | 18 +- .../kvm/x86_64/vmx_nested_tsc_scaling_test.c | 19 +- .../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 25 +- .../kvm/x86_64/vmx_preemption_timer_test.c | 30 +- .../kvm/x86_64/vmx_set_nested_state_test.c | 86 +- .../kvm/x86_64/vmx_tsc_adjust_test.c | 12 +- .../selftests/kvm/x86_64/xapic_ipi_test.c | 48 +- .../selftests/kvm/x86_64/xen_shinfo_test.c | 35 +- .../selftests/kvm/x86_64/xen_vmcall_test.c | 17 +- .../selftests/kvm/x86_64/xss_msr_test.c | 10 +- 91 files changed, 2363 insertions(+), 3087 deletions(-) delete mode 100644 tools/testing/selftests/kvm/lib/kvm_util_internal.hbase-commit:
f6ae04ddb347f526b4620d1053690ecf1f87d77f--
2.35.1.723.g4982287a31-goog