Commit e8566033 authored by Haibo Xu's avatar Haibo Xu Committed by Anup Patel

KVM: arm64: selftests: Move finalize_vcpu back to run_test

No functional changes. Just move the finalize_vcpu call back to
run_test and do weak function trick to prepare for the opration
in riscv.
Suggested-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Signed-off-by: default avatarHaibo Xu <haibo1.xu@intel.com>
Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
parent 90a6bcbc
...@@ -84,6 +84,19 @@ bool check_reject_set(int err) ...@@ -84,6 +84,19 @@ bool check_reject_set(int err)
return err == EPERM; return err == EPERM;
} }
void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c)
{
struct vcpu_reg_sublist *s;
int feature;
for_each_sublist(c, s) {
if (s->finalize) {
feature = s->feature;
vcpu_ioctl(vcpu, KVM_ARM_VCPU_FINALIZE, &feature);
}
}
}
#define REG_MASK (KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_COPROC_MASK) #define REG_MASK (KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_COPROC_MASK)
#define CORE_REGS_XX_NR_WORDS 2 #define CORE_REGS_XX_NR_WORDS 2
......
...@@ -34,9 +34,6 @@ static __u64 *blessed_reg, blessed_n; ...@@ -34,9 +34,6 @@ static __u64 *blessed_reg, blessed_n;
extern struct vcpu_reg_list *vcpu_configs[]; extern struct vcpu_reg_list *vcpu_configs[];
extern int vcpu_configs_n; extern int vcpu_configs_n;
#define for_each_sublist(c, s) \
for ((s) = &(c)->sublists[0]; (s)->regs; ++(s))
#define for_each_reg(i) \ #define for_each_reg(i) \
for ((i) = 0; (i) < reg_list->n; ++(i)) for ((i) = 0; (i) < reg_list->n; ++(i))
...@@ -109,6 +106,10 @@ bool __weak check_reject_set(int err) ...@@ -109,6 +106,10 @@ bool __weak check_reject_set(int err)
return true; return true;
} }
void __weak finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c)
{
}
#ifdef __aarch64__ #ifdef __aarch64__
static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init)
{ {
...@@ -119,19 +120,6 @@ static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *ini ...@@ -119,19 +120,6 @@ static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *ini
init->features[s->feature / 32] |= 1 << (s->feature % 32); init->features[s->feature / 32] |= 1 << (s->feature % 32);
} }
static void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c)
{
struct vcpu_reg_sublist *s;
int feature;
for_each_sublist(c, s) {
if (s->finalize) {
feature = s->feature;
vcpu_ioctl(vcpu, KVM_ARM_VCPU_FINALIZE, &feature);
}
}
}
static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm_vm *vm) static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm_vm *vm)
{ {
struct kvm_vcpu_init init = { .target = -1, }; struct kvm_vcpu_init init = { .target = -1, };
...@@ -140,7 +128,6 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm ...@@ -140,7 +128,6 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm
prepare_vcpu_init(c, &init); prepare_vcpu_init(c, &init);
vcpu = __vm_vcpu_add(vm, 0); vcpu = __vm_vcpu_add(vm, 0);
aarch64_vcpu_setup(vcpu, &init); aarch64_vcpu_setup(vcpu, &init);
finalize_vcpu(vcpu, c);
return vcpu; return vcpu;
} }
...@@ -180,6 +167,7 @@ static void run_test(struct vcpu_reg_list *c) ...@@ -180,6 +167,7 @@ static void run_test(struct vcpu_reg_list *c)
vm = vm_create_barebones(); vm = vm_create_barebones();
vcpu = vcpu_config_get_vcpu(c, vm); vcpu = vcpu_config_get_vcpu(c, vm);
finalize_vcpu(vcpu, c);
reg_list = vcpu_get_reg_list(vcpu); reg_list = vcpu_get_reg_list(vcpu);
......
...@@ -141,6 +141,9 @@ struct vcpu_reg_list { ...@@ -141,6 +141,9 @@ struct vcpu_reg_list {
struct vcpu_reg_sublist sublists[]; struct vcpu_reg_sublist sublists[];
}; };
#define for_each_sublist(c, s) \
for ((s) = &(c)->sublists[0]; (s)->regs; ++(s))
#define kvm_for_each_vcpu(vm, i, vcpu) \ #define kvm_for_each_vcpu(vm, i, vcpu) \
for ((i) = 0; (i) <= (vm)->last_vcpu_id; (i)++) \ for ((i) = 0; (i) <= (vm)->last_vcpu_id; (i)++) \
if (!((vcpu) = vm->vcpus[i])) \ if (!((vcpu) = vm->vcpus[i])) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment