Skip to content

Commit c474677

Browse files
xiaobo55xavpatel
authored andcommitted
KVM: selftests: Only do get/set tests on present blessed list
Only do the get/set tests on present and blessed registers since we don't know the capabilities of any new ones. Suggested-by: Andrew Jones <[email protected]> Signed-off-by: Haibo Xu <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent e856603 commit c474677

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ extern int vcpu_configs_n;
5050
for_each_reg_filtered(i) \
5151
if (!find_reg(blessed_reg, blessed_n, reg_list->reg[i]))
5252

53+
#define for_each_present_blessed_reg(i) \
54+
for_each_reg(i) \
55+
if (find_reg(blessed_reg, blessed_n, reg_list->reg[i]))
56+
5357
static const char *config_name(struct vcpu_reg_list *c)
5458
{
5559
struct vcpu_reg_sublist *s;
@@ -183,6 +187,16 @@ static void run_test(struct vcpu_reg_list *c)
183187
return;
184188
}
185189

190+
for_each_sublist(c, s)
191+
blessed_n += s->regs_n;
192+
blessed_reg = calloc(blessed_n, sizeof(__u64));
193+
194+
n = 0;
195+
for_each_sublist(c, s) {
196+
for (i = 0; i < s->regs_n; ++i)
197+
blessed_reg[n++] = s->regs[i];
198+
}
199+
186200
/*
187201
* We only test that we can get the register and then write back the
188202
* same value. Some registers may allow other values to be written
@@ -192,8 +206,11 @@ static void run_test(struct vcpu_reg_list *c)
192206
* be written need to have the other values tested, then we should
193207
* create a new set of tests for those in a new independent test
194208
* executable.
209+
*
210+
* Only do the get/set tests on present, blessed list registers,
211+
* since we don't know the capabilities of any new registers.
195212
*/
196-
for_each_reg(i) {
213+
for_each_present_blessed_reg(i) {
197214
uint8_t addr[2048 / 8];
198215
struct kvm_one_reg reg = {
199216
.id = reg_list->reg[i],
@@ -236,16 +253,6 @@ static void run_test(struct vcpu_reg_list *c)
236253
}
237254
}
238255

239-
for_each_sublist(c, s)
240-
blessed_n += s->regs_n;
241-
blessed_reg = calloc(blessed_n, sizeof(__u64));
242-
243-
n = 0;
244-
for_each_sublist(c, s) {
245-
for (i = 0; i < s->regs_n; ++i)
246-
blessed_reg[n++] = s->regs[i];
247-
}
248-
249256
for_each_new_reg(i)
250257
++new_regs;
251258

0 commit comments

Comments
 (0)