@@ -457,13 +457,36 @@ static void test_guest_reg_read(struct kvm_vcpu *vcpu)
457
457
}
458
458
}
459
459
460
+ static void test_assert_id_reg_unchanged (struct kvm_vcpu * vcpu , uint32_t encoding )
461
+ {
462
+ size_t idx = encoding_to_range_idx (encoding );
463
+ uint64_t observed ;
464
+
465
+ vcpu_get_reg (vcpu , KVM_ARM64_SYS_REG (encoding ), & observed );
466
+ TEST_ASSERT_EQ (test_reg_vals [idx ], observed );
467
+ }
468
+
469
+ static void test_reset_preserves_id_regs (struct kvm_vcpu * vcpu )
470
+ {
471
+ /*
472
+ * Calls KVM_ARM_VCPU_INIT behind the scenes, which will do an
473
+ * architectural reset of the vCPU.
474
+ */
475
+ aarch64_vcpu_setup (vcpu , NULL );
476
+
477
+ for (int i = 0 ; i < ARRAY_SIZE (test_regs ); i ++ )
478
+ test_assert_id_reg_unchanged (vcpu , test_regs [i ].reg );
479
+
480
+ ksft_test_result_pass ("%s\n" , __func__ );
481
+ }
482
+
460
483
int main (void )
461
484
{
462
485
struct kvm_vcpu * vcpu ;
463
486
struct kvm_vm * vm ;
464
487
bool aarch64_only ;
465
488
uint64_t val , el0 ;
466
- int ftr_cnt ;
489
+ int test_cnt ;
467
490
468
491
TEST_REQUIRE (kvm_has_cap (KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES ));
469
492
@@ -476,18 +499,20 @@ int main(void)
476
499
477
500
ksft_print_header ();
478
501
479
- ftr_cnt = ARRAY_SIZE (ftr_id_aa64dfr0_el1 ) + ARRAY_SIZE (ftr_id_dfr0_el1 ) +
480
- ARRAY_SIZE (ftr_id_aa64isar0_el1 ) + ARRAY_SIZE (ftr_id_aa64isar1_el1 ) +
481
- ARRAY_SIZE (ftr_id_aa64isar2_el1 ) + ARRAY_SIZE (ftr_id_aa64pfr0_el1 ) +
482
- ARRAY_SIZE (ftr_id_aa64mmfr0_el1 ) + ARRAY_SIZE (ftr_id_aa64mmfr1_el1 ) +
483
- ARRAY_SIZE (ftr_id_aa64mmfr2_el1 ) + ARRAY_SIZE (ftr_id_aa64zfr0_el1 ) -
484
- ARRAY_SIZE (test_regs );
502
+ test_cnt = ARRAY_SIZE (ftr_id_aa64dfr0_el1 ) + ARRAY_SIZE (ftr_id_dfr0_el1 ) +
503
+ ARRAY_SIZE (ftr_id_aa64isar0_el1 ) + ARRAY_SIZE (ftr_id_aa64isar1_el1 ) +
504
+ ARRAY_SIZE (ftr_id_aa64isar2_el1 ) + ARRAY_SIZE (ftr_id_aa64pfr0_el1 ) +
505
+ ARRAY_SIZE (ftr_id_aa64mmfr0_el1 ) + ARRAY_SIZE (ftr_id_aa64mmfr1_el1 ) +
506
+ ARRAY_SIZE (ftr_id_aa64mmfr2_el1 ) + ARRAY_SIZE (ftr_id_aa64zfr0_el1 ) -
507
+ ARRAY_SIZE (test_regs ) + 1 ;
485
508
486
- ksft_set_plan (ftr_cnt );
509
+ ksft_set_plan (test_cnt );
487
510
488
511
test_vm_ftr_id_regs (vcpu , aarch64_only );
489
512
test_guest_reg_read (vcpu );
490
513
514
+ test_reset_preserves_id_regs (vcpu );
515
+
491
516
kvm_vm_free (vm );
492
517
493
518
ksft_finished ();
0 commit comments