@@ -327,8 +327,8 @@ uint64_t get_invalid_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
327327 return ftr ;
328328}
329329
330- static void test_reg_set_success (struct kvm_vcpu * vcpu , uint64_t reg ,
331- const struct reg_ftr_bits * ftr_bits )
330+ static uint64_t test_reg_set_success (struct kvm_vcpu * vcpu , uint64_t reg ,
331+ const struct reg_ftr_bits * ftr_bits )
332332{
333333 uint8_t shift = ftr_bits -> shift ;
334334 uint64_t mask = ftr_bits -> mask ;
@@ -346,6 +346,8 @@ static void test_reg_set_success(struct kvm_vcpu *vcpu, uint64_t reg,
346346 vcpu_set_reg (vcpu , reg , val );
347347 vcpu_get_reg (vcpu , reg , & new_val );
348348 TEST_ASSERT_EQ (new_val , val );
349+
350+ return new_val ;
349351}
350352
351353static void test_reg_set_fail (struct kvm_vcpu * vcpu , uint64_t reg ,
@@ -374,6 +376,14 @@ static void test_reg_set_fail(struct kvm_vcpu *vcpu, uint64_t reg,
374376 TEST_ASSERT_EQ (val , old_val );
375377}
376378
379+ static uint64_t test_reg_vals [KVM_ARM_FEATURE_ID_RANGE_SIZE ];
380+
381+ #define encoding_to_range_idx (encoding ) \
382+ KVM_ARM_FEATURE_ID_RANGE_IDX(sys_reg_Op0(encoding), sys_reg_Op1(encoding), \
383+ sys_reg_CRn(encoding), sys_reg_CRm(encoding), \
384+ sys_reg_Op2(encoding))
385+
386+
377387static void test_vm_ftr_id_regs (struct kvm_vcpu * vcpu , bool aarch64_only )
378388{
379389 uint64_t masks [KVM_ARM_FEATURE_ID_RANGE_SIZE ];
@@ -398,9 +408,7 @@ static void test_vm_ftr_id_regs(struct kvm_vcpu *vcpu, bool aarch64_only)
398408 int idx ;
399409
400410 /* Get the index to masks array for the idreg */
401- idx = KVM_ARM_FEATURE_ID_RANGE_IDX (sys_reg_Op0 (reg_id ), sys_reg_Op1 (reg_id ),
402- sys_reg_CRn (reg_id ), sys_reg_CRm (reg_id ),
403- sys_reg_Op2 (reg_id ));
411+ idx = encoding_to_range_idx (reg_id );
404412
405413 for (int j = 0 ; ftr_bits [j ].type != FTR_END ; j ++ ) {
406414 /* Skip aarch32 reg on aarch64 only system, since they are RAZ/WI. */
@@ -414,7 +422,9 @@ static void test_vm_ftr_id_regs(struct kvm_vcpu *vcpu, bool aarch64_only)
414422 TEST_ASSERT_EQ (masks [idx ] & ftr_bits [j ].mask , ftr_bits [j ].mask );
415423
416424 test_reg_set_fail (vcpu , reg , & ftr_bits [j ]);
417- test_reg_set_success (vcpu , reg , & ftr_bits [j ]);
425+
426+ test_reg_vals [idx ] = test_reg_set_success (vcpu , reg ,
427+ & ftr_bits [j ]);
418428
419429 ksft_test_result_pass ("%s\n" , ftr_bits [j ].name );
420430 }
@@ -425,7 +435,6 @@ static void test_guest_reg_read(struct kvm_vcpu *vcpu)
425435{
426436 bool done = false;
427437 struct ucall uc ;
428- uint64_t val ;
429438
430439 while (!done ) {
431440 vcpu_run (vcpu );
@@ -436,8 +445,8 @@ static void test_guest_reg_read(struct kvm_vcpu *vcpu)
436445 break ;
437446 case UCALL_SYNC :
438447 /* Make sure the written values are seen by guest */
439- vcpu_get_reg ( vcpu , KVM_ARM64_SYS_REG (uc .args [2 ]), & val );
440- TEST_ASSERT_EQ ( val , uc .args [3 ]);
448+ TEST_ASSERT_EQ ( test_reg_vals [ encoding_to_range_idx (uc .args [2 ])],
449+ uc .args [3 ]);
441450 break ;
442451 case UCALL_DONE :
443452 done = true;
0 commit comments