Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <ajones@ventanamicro.com>
Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Anup Patel <anup@brainfault.org>

authored by

Haibo Xu and committed by
Anup Patel
c4746771 e8566033

+18 -11
+18 -11
tools/testing/selftests/kvm/get-reg-list.c
··· 50 50 for_each_reg_filtered(i) \ 51 51 if (!find_reg(blessed_reg, blessed_n, reg_list->reg[i])) 52 52 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 + 53 57 static const char *config_name(struct vcpu_reg_list *c) 54 58 { 55 59 struct vcpu_reg_sublist *s; ··· 187 183 return; 188 184 } 189 185 186 + for_each_sublist(c, s) 187 + blessed_n += s->regs_n; 188 + blessed_reg = calloc(blessed_n, sizeof(__u64)); 189 + 190 + n = 0; 191 + for_each_sublist(c, s) { 192 + for (i = 0; i < s->regs_n; ++i) 193 + blessed_reg[n++] = s->regs[i]; 194 + } 195 + 190 196 /* 191 197 * We only test that we can get the register and then write back the 192 198 * same value. Some registers may allow other values to be written ··· 206 192 * be written need to have the other values tested, then we should 207 193 * create a new set of tests for those in a new independent test 208 194 * executable. 195 + * 196 + * Only do the get/set tests on present, blessed list registers, 197 + * since we don't know the capabilities of any new registers. 209 198 */ 210 - for_each_reg(i) { 199 + for_each_present_blessed_reg(i) { 211 200 uint8_t addr[2048 / 8]; 212 201 struct kvm_one_reg reg = { 213 202 .id = reg_list->reg[i], ··· 251 234 ++failed_set; 252 235 } 253 236 } 254 - } 255 - 256 - for_each_sublist(c, s) 257 - blessed_n += s->regs_n; 258 - blessed_reg = calloc(blessed_n, sizeof(__u64)); 259 - 260 - n = 0; 261 - for_each_sublist(c, s) { 262 - for (i = 0; i < s->regs_n; ++i) 263 - blessed_reg[n++] = s->regs[i]; 264 237 } 265 238 266 239 for_each_new_reg(i)