@@ -327,8 +327,8 @@ uint64_t get_invalid_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr)
327
327
return ftr ;
328
328
}
329
329
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 )
332
332
{
333
333
uint8_t shift = ftr_bits -> shift ;
334
334
uint64_t mask = ftr_bits -> mask ;
@@ -346,6 +346,8 @@ static void test_reg_set_success(struct kvm_vcpu *vcpu, uint64_t reg,
346
346
vcpu_set_reg (vcpu , reg , val );
347
347
vcpu_get_reg (vcpu , reg , & new_val );
348
348
TEST_ASSERT_EQ (new_val , val );
349
+
350
+ return new_val ;
349
351
}
350
352
351
353
static 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,
374
376
TEST_ASSERT_EQ (val , old_val );
375
377
}
376
378
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
+
377
387
static void test_vm_ftr_id_regs (struct kvm_vcpu * vcpu , bool aarch64_only )
378
388
{
379
389
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)
398
408
int idx ;
399
409
400
410
/* 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 );
404
412
405
413
for (int j = 0 ; ftr_bits [j ].type != FTR_END ; j ++ ) {
406
414
/* 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)
414
422
TEST_ASSERT_EQ (masks [idx ] & ftr_bits [j ].mask , ftr_bits [j ].mask );
415
423
416
424
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 ]);
418
428
419
429
ksft_test_result_pass ("%s\n" , ftr_bits [j ].name );
420
430
}
@@ -425,7 +435,6 @@ static void test_guest_reg_read(struct kvm_vcpu *vcpu)
425
435
{
426
436
bool done = false;
427
437
struct ucall uc ;
428
- uint64_t val ;
429
438
430
439
while (!done ) {
431
440
vcpu_run (vcpu );
@@ -436,8 +445,8 @@ static void test_guest_reg_read(struct kvm_vcpu *vcpu)
436
445
break ;
437
446
case UCALL_SYNC :
438
447
/* 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 ]);
441
450
break ;
442
451
case UCALL_DONE :
443
452
done = true;
0 commit comments