Skip to content

Commit 5a070fc

Browse files
broonieMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Remove a duplicate register listing in set_id_regs
Currently we list the main set of registers with bits we test three times, once in the test_regs array which is used at runtime, once in the guest code and once in a list of ARRAY_SIZE() operations we use to tell kselftest how many tests we plan to execute. This is needlessly fiddly, when adding new registers as the test_cnt calculation is formatted with two registers per line. Instead count the number of bitfields in the register arrays at runtime. The existing code subtracts ARRAY_SIZE(test_regs) from the number of tests to account for the terminating FTR_REG_END entries in the per register arrays, the new code accounts for this when enumerating. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 75b2fdc commit 5a070fc

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

tools/testing/selftests/kvm/arm64/set_id_regs.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ int main(void)
753753
struct kvm_vm *vm;
754754
bool aarch64_only;
755755
uint64_t val, el0;
756-
int test_cnt;
756+
int test_cnt, i, j;
757757

758758
TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES));
759759
TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_WRITABLE_IMP_ID_REGS));
@@ -772,13 +772,10 @@ int main(void)
772772

773773
ksft_print_header();
774774

775-
test_cnt = ARRAY_SIZE(ftr_id_aa64dfr0_el1) + ARRAY_SIZE(ftr_id_dfr0_el1) +
776-
ARRAY_SIZE(ftr_id_aa64isar0_el1) + ARRAY_SIZE(ftr_id_aa64isar1_el1) +
777-
ARRAY_SIZE(ftr_id_aa64isar2_el1) + ARRAY_SIZE(ftr_id_aa64pfr0_el1) +
778-
ARRAY_SIZE(ftr_id_aa64pfr1_el1) + ARRAY_SIZE(ftr_id_aa64mmfr0_el1) +
779-
ARRAY_SIZE(ftr_id_aa64mmfr1_el1) + ARRAY_SIZE(ftr_id_aa64mmfr2_el1) +
780-
ARRAY_SIZE(ftr_id_aa64mmfr3_el1) + ARRAY_SIZE(ftr_id_aa64zfr0_el1) -
781-
ARRAY_SIZE(test_regs) + 3 + MPAM_IDREG_TEST + MTE_IDREG_TEST;
775+
test_cnt = 3 + MPAM_IDREG_TEST + MTE_IDREG_TEST;
776+
for (i = 0; i < ARRAY_SIZE(test_regs); i++)
777+
for (j = 0; test_regs[i].ftr_bits[j].type != FTR_END; j++)
778+
test_cnt++;
782779

783780
ksft_set_plan(test_cnt);
784781

0 commit comments

Comments
 (0)