Minor improvements to the selftest setup logic
v4 cover Minor improvements to the selftest setup logic
This series is posted in context of the discussion at:
https://lore.kernel.org/lkml/Ywa9T+jKUpaHLu%[email protected]/
Major changes:
1) Move common startup logic to a single function in kvm_util.c
2) Introduce following APIs:
kvm_selftest_arch_init: to perform arch specific common startup.
kvm_arch_vm_post_create: to perform arch specific common setup
after VM creation.
Changelog
=========
v4:
* Removed the patch to precompute cpu type, will be introduced as part of a separate series in future.
v3:
* Original series is split into two and this v3 version contains the improvements to selftest and VM setup.
* Planning to upload the second series to execute hypercall instruction according to cpu type separately.
* Addressed comments from David and Sean.
link to v3:
https://lore.kernel.org/lkml/[email protected]/
v2:
* Addressed comments from Andrew and David
* Common function with constructor attribute used to setup initial state
* Changes are split in more logical granules as per feedback
link to v2:
https://lore.kernel.org/all/[email protected]/
Vishal Annapurve (3):
KVM: selftests: move common startup logic to kvm_util.c
KVM: selftests: Add arch specific initialization
KVM: selftests: Add arch specific post vm creation hook
.../selftests/kvm/aarch64/arch_timer.c | 3 --- .../selftests/kvm/aarch64/hypercalls.c | 2 -- .../testing/selftests/kvm/aarch64/vgic_irq.c | 3 --- .../selftests/kvm/include/kvm_util_base.h | 9 ++++++++ .../selftests/kvm/lib/aarch64/processor.c | 18 ++++++++-------- tools/testing/selftests/kvm/lib/kvm_util.c | 21 ++++++++++++++++--- .../selftests/kvm/lib/x86_64/processor.c | 6 ++++++ .../testing/selftests/kvm/memslot_perf_test.c | 3 --- tools/testing/selftests/kvm/rseq_test.c | 3 --- tools/testing/selftests/kvm/s390x/memop.c | 2 -- tools/testing/selftests/kvm/s390x/resets.c | 2 -- .../selftests/kvm/s390x/sync_regs_test.c | 3 --- .../selftests/kvm/set_memory_region_test.c | 3 --- .../kvm/x86_64/cr4_cpuid_sync_test.c | 3 --- .../kvm/x86_64/emulator_error_test.c | 3 --- .../selftests/kvm/x86_64/hyperv_cpuid.c | 3 --- .../selftests/kvm/x86_64/platform_info_test.c | 3 --- .../kvm/x86_64/pmu_event_filter_test.c | 3 --- .../selftests/kvm/x86_64/set_sregs_test.c | 3 --- .../kvm/x86_64/svm_nested_soft_inject_test.c | 3 --- .../selftests/kvm/x86_64/sync_regs_test.c | 3 --- .../selftests/kvm/x86_64/userspace_io_test.c | 3 --- .../kvm/x86_64/userspace_msr_exit_test.c | 3 --- 23 files changed, 42 insertions(+), 66 deletions(-)
Signature · 1 line
2.38.1.431.g37b22c650d-goog
PATCH v4 1/3 KVM: selftests: move common startup logic to kvm_util.c
Consolidate common startup logic in one place by implementing a single setup function with __attribute((constructor)) for all selftests within kvm_util.c.
This allows moving logic like:
/* Tell stdout not to buffer its content */
setbuf(stdout, NULL);to a single file for all selftests.
This will also allow any required setup at entry in future to be done in common main function.
More context is discussed at:
https://lore.kernel.org/lkml/Ywa9T+jKUpaHLu%[email protected]/
--- tools/testing/selftests/kvm/aarch64/arch_timer.c | 3 --- tools/testing/selftests/kvm/aarch64/hypercalls.c | 2 -- tools/testing/selftests/kvm/aarch64/vgic_irq.c | 3 --- tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++++ tools/testing/selftests/kvm/memslot_perf_test.c | 3 --- tools/testing/selftests/kvm/rseq_test.c | 3 --- tools/testing/selftests/kvm/s390x/memop.c | 2 -- tools/testing/selftests/kvm/s390x/resets.c | 2 -- tools/testing/selftests/kvm/s390x/sync_regs_test.c | 3 --- tools/testing/selftests/kvm/set_memory_region_test.c | 3 --- tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c | 3 --- tools/testing/selftests/kvm/x86_64/emulator_error_test.c | 3 --- tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 3 --- tools/testing/selftests/kvm/x86_64/platform_info_test.c | 3 --- tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c | 3 --- tools/testing/selftests/kvm/x86_64/set_sregs_test.c | 3 --- .../selftests/kvm/x86_64/svm_nested_soft_inject_test.c | 3 --- tools/testing/selftests/kvm/x86_64/sync_regs_test.c | 3 --- tools/testing/selftests/kvm/x86_64/userspace_io_test.c | 3 --- .../testing/selftests/kvm/x86_64/userspace_msr_exit_test.c | 3 --- 20 files changed, 6 insertions(+), 54 deletions(-)
tools/testing/selftests/kvm/aarch64/arch_timer.c +0 -3
@@ -462,9 +462,6 @@ int main(int argc, char *argv[]) {struct kvm_vm *vm; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -if (!parse_args (argc, argv))exit (KSFT_SKIP );
tools/testing/selftests/kvm/aarch64/hypercalls.c +0 -2
@@ -306,8 +306,6 @@ static void test_run(void)int main (void ) { -setbuf (stdout,NULL ); -test_run ();return 0 ; }
tools/testing/selftests/kvm/aarch64/vgic_irq.c +0 -3
@@ -818,9 +818,6 @@ int main(int argc, char **argv)int opt;bool eoi_split = false; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -while ((opt =getopt (argc, argv,"hn:e:l:" )) !=-1 ) {switch (opt) {case 'n' :
tools/testing/selftests/kvm/lib/kvm_util.c +6 -0
@@ -2021,3 +2021,9 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data,break ; } } + +void __attribute((constructor))kvm_selftest_init (void ) +{ +/* Tell stdout not to buffer its content. */ +setbuf (stdout,NULL ); +}
tools/testing/selftests/kvm/memslot_perf_test.c +0 -3
@@ -1007,9 +1007,6 @@ int main(int argc, char *argv[])struct test_result rbestslottime;int tctr; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -if (!parse_args (argc, argv, &targs))return -1 ;
tools/testing/selftests/kvm/rseq_test.c +0 -3
@@ -205,9 +205,6 @@ int main(int argc, char *argv[])struct kvm_vcpu *vcpu;u32 cpu, rseq_cpu; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); - r =sched_getaffinity (0 ,sizeof (possible_mask), &possible_mask);TEST_ASSERT (!r,"sched_getaffinity failed, errno = %d (%s)" , errno,strerror (errno));
tools/testing/selftests/kvm/s390x/memop.c +0 -2
@@ -760,8 +760,6 @@ int main(int argc, char *argv[])TEST_REQUIRE (kvm_has_cap (KVM_CAP_S390_MEM_OP )); -setbuf (stdout,NULL );/* Tell stdout not to buffer its content */ -ksft_print_header ();ksft_set_plan (ARRAY_SIZE (testlist));
tools/testing/selftests/kvm/s390x/resets.c +0 -2
@@ -296,8 +296,6 @@ int main(int argc, char *argv[])bool has_s390_vcpu_resets =kvm_check_cap (KVM_CAP_S390_VCPU_RESETS );int idx; -setbuf (stdout,NULL );/* Tell stdout not to buffer its content */ -ksft_print_header ();ksft_set_plan (ARRAY_SIZE (testlist));
tools/testing/selftests/kvm/s390x/sync_regs_test.c +0 -3
@@ -231,9 +231,6 @@ int main(int argc, char *argv[])TEST_REQUIRE (kvm_has_cap (KVM_CAP_SYNC_REGS )); -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -ksft_print_header ();ksft_set_plan (ARRAY_SIZE (testlist));
tools/testing/selftests/kvm/set_memory_region_test.c +0 -3
@@ -392,9 +392,6 @@ int main(int argc, char *argv[])int i, loops;#endif -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -#ifdef __x86_64__/* * FIXME: the zero-memslot test fails on aarch64 and s390x because
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c +0 -3
@@ -57,9 +57,6 @@ int main(int argc, char *argv[])TEST_REQUIRE (kvm_cpu_has (X86_FEATURE_XSAVE )); -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); - vm =vm_create_with_one_vcpu (&vcpu, guest_code); run = vcpu->run;
tools/testing/selftests/kvm/x86_64/emulator_error_test.c +0 -3
@@ -156,9 +156,6 @@ int main(int argc, char *argv[])uint64_t *hva;int rc; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -TEST_REQUIRE (kvm_has_cap (KVM_CAP_SMALLER_MAXPHYADDR )); vm =vm_create_with_one_vcpu (&vcpu, guest_code);
tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +0 -3
@@ -134,9 +134,6 @@ int main(int argc, char *argv[])const struct kvm_cpuid2 *hv_cpuid_entries;struct kvm_vcpu *vcpu; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -TEST_REQUIRE (kvm_has_cap (KVM_CAP_HYPERV_CPUID )); vm =vm_create_with_one_vcpu (&vcpu, guest_code);
tools/testing/selftests/kvm/x86_64/platform_info_test.c +0 -3
@@ -72,9 +72,6 @@ int main(int argc, char *argv[])struct kvm_vm *vm;uint64_t msr_platform_info; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -TEST_REQUIRE (kvm_has_cap (KVM_CAP_MSR_PLATFORM_INFO )); vm =vm_create_with_one_vcpu (&vcpu, guest_code);
tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c +0 -3
@@ -447,9 +447,6 @@ int main(int argc, char *argv[])struct kvm_vcpu *vcpu;struct kvm_vm *vm; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -TEST_REQUIRE (kvm_has_cap (KVM_CAP_PMU_EVENT_FILTER ));TEST_REQUIRE (use_intel_pmu () ||use_amd_pmu ());
tools/testing/selftests/kvm/x86_64/set_sregs_test.c +0 -3
@@ -82,9 +82,6 @@ int main(int argc, char *argv[])uint64_t cr4;int rc; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -/* * Create a dummy VM, specifically to avoid doing KVM_SET_CPUID2, and * use it to verify all supported CR4 bits can be set prior to defining
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c +0 -3
@@ -194,9 +194,6 @@ static void run_test(bool is_nmi)int main (int argc,char *argv[]) { -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -TEST_REQUIRE (kvm_cpu_has (X86_FEATURE_SVM )); TEST_ASSERT(kvm_cpu_has(X86_FEATURE_NRIPS),
tools/testing/selftests/kvm/x86_64/sync_regs_test.c +0 -3
@@ -90,9 +90,6 @@ int main(int argc, char *argv[])struct kvm_vcpu_events events;int rv, cap; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); - cap =kvm_check_cap (KVM_CAP_SYNC_REGS );TEST_REQUIRE ((cap &TEST_SYNC_FIELDS ) ==TEST_SYNC_FIELDS );TEST_REQUIRE (!(cap &INVALID_SYNC_FIELD ));
tools/testing/selftests/kvm/x86_64/userspace_io_test.c +0 -3
@@ -56,9 +56,6 @@ int main(int argc, char *argv[])struct kvm_vm *vm;struct ucall uc; -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); - vm =vm_create_with_one_vcpu (&vcpu, guest_code); run = vcpu->run;
tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c +0 -3
@@ -818,9 +818,6 @@ static void test_user_exit_msr_flags(void)int main (int argc,char *argv[]) { -/* Tell stdout not to buffer its content */ -setbuf (stdout,NULL ); -test_msr_filter_allow ();test_msr_filter_deny ();
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Sean Christopherson
reviewerRe: [V4 PATCH 1/3] KVM: selftests: move common startup logic to kvm_util.c
Quoted 7 lines · Vishal Annapurve
Consolidate common startup logic in one place by implementing a single setup function with __attribute((constructor)) for all selftests within
kvm_util.c.This allows moving logic like:
/* Tell stdout not to buffer its content */ setbuf(stdout, NULL);
Quoted 7 lines
to a single file for all selftests.
This will also allow any required setup at entry in future to be done in common main function.
More context is discussed at:
https://lore.kernel.org/lkml/Ywa9T+jKUpaHLu%[email protected]/
Nit,
is the the "standard" way to convey this information.
Re: [V4 PATCH 1/3] KVM: selftests: move common startup logic to kvm_util.c
Quoted 14 lines · Sean Christopherson
Quoted 12 lines · Vishal Annapurve
Consolidate common startup logic in one place by implementing a single setup function with __attribute((constructor)) for all selftests within
kvm_util.c.This allows moving logic like:
/* Tell stdout not to buffer its content */ setbuf(stdout, NULL);to a single file for all selftests.
This will also allow any required setup at entry in future to be done in common main function.
Quoted 8 lines
Quoted 2 lines
More context is discussed at:
https://lore.kernel.org/lkml/Ywa9T+jKUpaHLu%[email protected]/Nit,
is the the "standard" way to convey this information.
Noted.
PATCH v4 2/3 KVM: selftests: Add arch specific initialization
In reply to Vishal AnnapurveIntroduce arch specific API: kvm_selftest_arch_init to allow each arch to handle initialization before running any selftest logic.
--- .../selftests/kvm/include/kvm_util_base.h | 5 +++++ .../selftests/kvm/lib/aarch64/processor.c | 18 +++++++++--------- tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++++ 3 files changed, 20 insertions(+), 9 deletions(-)
tools/testing/selftests/kvm/include/kvm_util_base.h +5 -0
@@ -838,4 +838,9 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm) return __vm_enable_cap(vm, KVM_CAP_VM_DISABLE_NX_HUGE_PAGES, 0); } +/* +* API to execute architecture specific setup before executing main(). +*/ +void kvm_selftest_arch_init (void ); +#endif /* SELFTEST_KVM_UTIL_BASE_H */
tools/testing/selftests/kvm/lib/aarch64/processor.c +9 -9
@@ -495,15 +495,6 @@ void aarch64_get_supported_page_sizes(uint32_t ipa,close (kvm_fd); } -/* -* arm64 doesn't have a true default mode, so start by computing the -* available IPA space and page sizes early. -*/ -void __attribute__((constructor))init_guest_modes (void ) -{ -guest_modes_append_default (); -} -void smccc_hvc (uint32_t function_id,uint64_t arg0,uint64_t arg1,uint64_t arg2,uint64_t arg3,uint64_t arg4,uint64_t arg5,uint64_t arg6,struct arm_smccc_res *res)
@@ -528,3 +519,12 @@ void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1, [arg4] "r"(arg4), [arg5] "r"(arg5), [arg6] "r"(arg6) : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"); } + +void kvm_selftest_arch_init(void) +{ +/* +* arm64 doesn't have a true default mode, so start by computing the +* available IPA space and page sizes early. +*/ +guest_modes_append_default (); +}
tools/testing/selftests/kvm/lib/kvm_util.c +6 -0
@@ -2022,8 +2022,14 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data, } } +__weak void kvm_selftest_arch_init (void ) +{ +} +void __attribute((constructor))kvm_selftest_init (void ) {/* Tell stdout not to buffer its content. */ setbuf (stdout,NULL ); + +kvm_selftest_arch_init (); }
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Sean Christopherson
reviewerRe: [V4 PATCH 2/3] KVM: selftests: Add arch specific initialization
Quoted 18 lines · Vishal Annapurve
Introduce arch specific API:
kvm_selftest_arch_initto allow each arch to handle initialization before running any selftest logic.Suggested-by Sean Christopherson <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Peter Gonda <[email protected]>Signed-off-by Vishal Annapurve <[email protected]>--- .../selftests/kvm/include/kvm_util_base.h | 5 +++++ .../selftests/kvm/lib/aarch64/processor.c | 18 +++++++++--------- tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++++ 3 files changed, 20 insertions(+), 9 deletions(-)tools/testing/selftests/kvm/include/kvm_util_base.h +0
-0
tools/testing/selftests/kvm/include/kvm_util_base.h static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm) · line 843
Quoted 6 lines
tools/testing/selftests/kvm/include/kvm_util_base.h +3
-0@@ -838,4 +838,9 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)return __vm_enable_cap (vm,KVM_CAP_VM_DISABLE_NX_HUGE_PAGES ,0 ); } +/* +* API to execute architecture specific setup before executing main(). +*/
I find the "API" blurb to be somewhat confusing. When I think of APIs, I think of functions that are provided by a library that are called by users of the library.
An example might also help readers understand what types of setup can/should be done with this hook.
Maybe something like this?
/*
* Arch hook that is invoked via a constructor, i.e. before exeucting main(),
* to allow for arch-specific setup that is common to all tests, e.g. computing
* the default guest "mode".
*/
Re: [V4 PATCH 2/3] KVM: selftests: Add arch specific initialization
Quoted 34 lines · Sean Christopherson
Quoted 18 lines · Vishal Annapurve
Introduce arch specific API:
kvm_selftest_arch_initto allow each arch to handle initialization before running any selftest logic.Suggested-by Sean Christopherson <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Peter Gonda <[email protected]>Signed-off-by Vishal Annapurve <[email protected]>--- .../selftests/kvm/include/kvm_util_base.h | 5 +++++ .../selftests/kvm/lib/aarch64/processor.c | 18 +++++++++--------- tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++++ 3 files changed, 20 insertions(+), 9 deletions(-)tools/testing/selftests/kvm/include/kvm_util_base.h +0
-0tools/testing/selftests/kvm/include/kvm_util_base.h static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm) · line 843
Quoted 6 lines
tools/testing/selftests/kvm/include/kvm_util_base.h +3
-0@@ -838,4 +838,9 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)return __vm_enable_cap (vm,KVM_CAP_VM_DISABLE_NX_HUGE_PAGES ,0 ); } +/* +* API to execute architecture specific setup before executing main(). +*/ I find the "API" blurb to be somewhat confusing. When I think of APIs, I think of functions that are provided by a library that are called by users of the library.
An example might also help readers understand what types of setup can/should be done with this hook.
Quoted 7 lines
Maybe something like this?
/*
* Arch hook that is invoked via a constructor, i.e. before exeuctingmain(),
* to allow for arch-specific setup that is common to all tests, e.g. computing
* the default guest "mode".
*/
Ack, that looks better.
PATCH v4 3/3 KVM: selftests: Add arch specific post vm creation hook
In reply to Vishal AnnapurveAdd arch specific API kvm_arch_vm_post_create to perform any required setup after VM creation.
--- tools/testing/selftests/kvm/include/kvm_util_base.h | 4 ++++ tools/testing/selftests/kvm/lib/kvm_util.c | 9 ++++++--- tools/testing/selftests/kvm/lib/x86_64/processor.c | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-)
tools/testing/selftests/kvm/include/kvm_util_base.h +4 -0
@@ -843,4 +843,8 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)*/ void kvm_selftest_arch_init (void ); +/* +* API to execute architecture specific setup after creating the VM. +*/ +void kvm_arch_vm_post_create (struct kvm_vm *vm);#endif /* SELFTEST_KVM_UTIL_BASE_H */
tools/testing/selftests/kvm/lib/kvm_util.c +6 -3
@@ -340,9 +340,8 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint32_t nr_runnable_vcpus,kvm_vm_elf_load (vm, program_invocation_name); -#ifdef __x86_64__ -vm_create_irqchip (vm); -#endif +kvm_arch_vm_post_create (vm); +return vm; }
@@ -2022,6 +2021,10 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data, } } +__weak void kvm_arch_vm_post_create (struct kvm_vm *vm) +{ +} +__weak void kvm_selftest_arch_init (void ) { }
tools/testing/selftests/kvm/lib/x86_64/processor.c +6 -0
@@ -1327,3 +1327,9 @@ bool vm_is_unrestricted_guest(struct kvm_vm *vm)return get_kvm_intel_param_bool ("unrestricted_guest" ); } + + +void kvm_arch_vm_post_create (struct kvm_vm *vm) +{ +vm_create_irqchip (vm); +}
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Sean Christopherson
reviewerRe: [V4 PATCH 3/3] KVM: selftests: Add arch specific post vm creation hook
Quoted 18 lines · Vishal Annapurve
Add arch specific API
kvm_arch_vm_post_createto perform any required setup after VM creation.Suggested-by Sean Christopherson <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Peter Gonda <[email protected]>Signed-off-by Vishal Annapurve <[email protected]>--- tools/testing/selftests/kvm/include/kvm_util_base.h | 4 ++++ tools/testing/selftests/kvm/lib/kvm_util.c | 9 ++++++--- tools/testing/selftests/kvm/lib/x86_64/processor.c | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-)tools/testing/selftests/kvm/include/kvm_util_base.h +0
-0
tools/testing/selftests/kvm/include/kvm_util_base.h static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm) · line 848
Quoted 6 lines
tools/testing/selftests/kvm/include/kvm_util_base.h +3
-0@@ -843,4 +843,8 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)*/ void kvm_selftest_arch_init (void ); +/* +* API to execute architecture specific setup after creating the VM. +*/
Meh, I think the function name is self-explanatory.
Quoted 34 lines
tools/testing/selftests/kvm/include/kvm_util_base.h +1
-0+void kvm_arch_vm_post_create (struct kvm_vm *vm);#endif /* SELFTEST_KVM_UTIL_BASE_H */ tools/testing/selftests/kvm/lib/kvm_util.c +6
-3@@ -340,9 +340,8 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint32_t nr_runnable_vcpus,kvm_vm_elf_load (vm, program_invocation_name); -#ifdef __x86_64__ -vm_create_irqchip (vm); -#endif +kvm_arch_vm_post_create (vm); +return vm; }@@ -2022,6 +2021,10 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data, } } +__weak void kvm_arch_vm_post_create (struct kvm_vm *vm) +{ +} +__weak void kvm_selftest_arch_init (void ) { }tools/testing/selftests/kvm/lib/x86_64/processor.c +0
-0
tools/testing/selftests/kvm/lib/x86_64/processor.c bool vm_is_unrestricted_guest(struct kvm_vm *vm) · line 1331
Quoted 5 lines
tools/testing/selftests/kvm/lib/x86_64/processor.c +2
-0@@ -1327,3 +1327,9 @@ bool vm_is_unrestricted_guest(struct kvm_vm *vm)return get_kvm_intel_param_bool ("unrestricted_guest" ); } + +
Extra newline.
Quoted 7 lines
tools/testing/selftests/kvm/lib/x86_64/processor.c +4
-0+void kvm_arch_vm_post_create (struct kvm_vm *vm) +{ +vm_create_irqchip (vm); +}Signature · 1 line
2.38.1.431.g37b22c650d-goog
Sean Christopherson
reviewerQuoted 9 lines · Vishal Annapurve
This series is posted in context of the discussion at:
https://lore.kernel.org/lkml/Ywa9T+jKUpaHLu%[email protected]/Major changes:
1) Move common startup logic to a single function inkvm_util.c
2) Introduce following APIs:
kvm_selftest_arch_init: to perform arch specific common startup.
kvm_arch_vm_post_create: to perform arch specific common setup
after VM creation.
Looks good! A few uber nits, but nothing that can't be fixed up when applying.