Skip to content

Commit be4c580

Browse files
jones-drewavpatel
authored andcommitted
KVM: arm64: selftests: Finish generalizing get-reg-list
Add some unfortunate #ifdeffery to ensure the common get-reg-list.c can be compiled and run with other architectures. The next architecture to support get-reg-list should now only need to provide $(ARCH_DIR)/get-reg-list.c where arch-specific print_reg() and vcpu_configs[] get defined. Signed-off-by: Andrew Jones <[email protected]> Signed-off-by: Haibo Xu <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent 17da79e commit be4c580

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

tools/testing/selftests/kvm/get-reg-list.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void __weak print_reg(const char *prefix, __u64 id)
104104
printf("\t0x%llx,\n", id);
105105
}
106106

107+
#ifdef __aarch64__
107108
static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init)
108109
{
109110
struct vcpu_reg_sublist *s;
@@ -126,6 +127,25 @@ static void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c)
126127
}
127128
}
128129

130+
static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm_vm *vm)
131+
{
132+
struct kvm_vcpu_init init = { .target = -1, };
133+
struct kvm_vcpu *vcpu;
134+
135+
prepare_vcpu_init(c, &init);
136+
vcpu = __vm_vcpu_add(vm, 0);
137+
aarch64_vcpu_setup(vcpu, &init);
138+
finalize_vcpu(vcpu, c);
139+
140+
return vcpu;
141+
}
142+
#else
143+
static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm_vm *vm)
144+
{
145+
return __vm_vcpu_add(vm, 0);
146+
}
147+
#endif
148+
129149
static void check_supported(struct vcpu_reg_list *c)
130150
{
131151
struct vcpu_reg_sublist *s;
@@ -145,7 +165,6 @@ static bool print_filtered;
145165

146166
static void run_test(struct vcpu_reg_list *c)
147167
{
148-
struct kvm_vcpu_init init = { .target = -1, };
149168
int new_regs = 0, missing_regs = 0, i, n;
150169
int failed_get = 0, failed_set = 0, failed_reject = 0;
151170
struct kvm_vcpu *vcpu;
@@ -155,10 +174,7 @@ static void run_test(struct vcpu_reg_list *c)
155174
check_supported(c);
156175

157176
vm = vm_create_barebones();
158-
prepare_vcpu_init(c, &init);
159-
vcpu = __vm_vcpu_add(vm, 0);
160-
aarch64_vcpu_setup(vcpu, &init);
161-
finalize_vcpu(vcpu, c);
177+
vcpu = vcpu_config_get_vcpu(c, vm);
162178

163179
reg_list = vcpu_get_reg_list(vcpu);
164180

0 commit comments

Comments
 (0)