Skip to content

Commit 3279f52

Browse files
jones-drewavpatel
authored andcommitted
KVM: riscv: selftests: Fix get-reg-list print_reg defaults
print_reg() will print everything it knows when it encounters a register ID it's unfamiliar with in the default cases of its decoding switches. Fix several issues with these (until now, never tested) paths; missing newlines in printfs, missing complement operator in mask, and missing return in order to avoid continuing to decode. Fixes: 62d0c45 ("KVM: riscv: selftests: get-reg-list print_reg should never fail") Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Haibo Xu <haibo1.xu@intel.com> Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent a39b6ac commit 3279f52

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,9 @@ void print_reg(const char *prefix, __u64 id)
458458
reg_size = "KVM_REG_SIZE_U128";
459459
break;
460460
default:
461-
printf("\tKVM_REG_RISCV | (%lld << KVM_REG_SIZE_SHIFT) | 0x%llx /* UNKNOWN */,",
462-
(id & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT, id & REG_MASK);
461+
printf("\tKVM_REG_RISCV | (%lld << KVM_REG_SIZE_SHIFT) | 0x%llx /* UNKNOWN */,\n",
462+
(id & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT, id & ~REG_MASK);
463+
return;
463464
}
464465

465466
switch (id & KVM_REG_RISCV_TYPE_MASK) {
@@ -496,8 +497,9 @@ void print_reg(const char *prefix, __u64 id)
496497
reg_size, sbi_ext_id_to_str(prefix, id));
497498
break;
498499
default:
499-
printf("\tKVM_REG_RISCV | %s | 0x%llx /* UNKNOWN */,",
500-
reg_size, id & REG_MASK);
500+
printf("\tKVM_REG_RISCV | %s | 0x%llx /* UNKNOWN */,\n",
501+
reg_size, id & ~REG_MASK);
502+
return;
501503
}
502504
}
503505

0 commit comments

Comments
 (0)