KVM: selftests: Add arch specific post vm creation hook

Add arch specific API kvm_arch_vm_post_create to perform any required setup
after VM creation.

Suggested-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Reviewed-by: Peter Gonda <pgonda@google.com>
Signed-off-by: Vishal Annapurve <vannapurve@google.com>
Link: https://lore.kernel.org/r/20221115213845.3348210-4-vannapurve@google.com
[sean: place x86's implementation by vm_arch_vcpu_add()]
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
Vishal Annapurve 2022-11-15 21:38:45 +00:00 committed by Sean Christopherson
parent e1ab31245c
commit 2115713cfa
3 changed files with 12 additions and 3 deletions

View File

@ -864,4 +864,6 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm)
*/
void kvm_selftest_arch_init(void);
void kvm_arch_vm_post_create(struct kvm_vm *vm);
#endif /* SELFTEST_KVM_UTIL_BASE_H */

View File

@ -351,9 +351,7 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint32_t nr_runnable_vcpus,
slot0 = memslot2region(vm, 0);
ucall_init(vm, slot0->region.guest_phys_addr + slot0->region.memory_size);
#ifdef __x86_64__
vm_create_irqchip(vm);
#endif
kvm_arch_vm_post_create(vm);
return vm;
}
@ -2087,6 +2085,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)
{
}

View File

@ -586,6 +586,11 @@ void __vm_xsave_require_permission(int bit, const char *name)
bitmask);
}
void kvm_arch_vm_post_create(struct kvm_vm *vm)
{
vm_create_irqchip(vm);
}
struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id,
void *guest_code)
{