@@ -420,12 +420,11 @@ static int debug_version(uint64_t id_aa64dfr0)
420420 return FIELD_GET (ARM64_FEATURE_MASK (ID_AA64DFR0_DEBUGVER ), id_aa64dfr0 );
421421}
422422
423- static void test_guest_debug_exceptions (uint64_t aa64dfr0 )
423+ static void test_guest_debug_exceptions (uint8_t bpn , uint8_t wpn , uint8_t ctx_bpn )
424424{
425425 struct kvm_vcpu * vcpu ;
426426 struct kvm_vm * vm ;
427427 struct ucall uc ;
428- uint8_t brp_num ;
429428
430429 vm = vm_create_with_one_vcpu (& vcpu , guest_code );
431430 ucall_init (vm , NULL );
@@ -444,15 +443,9 @@ static void test_guest_debug_exceptions(uint64_t aa64dfr0)
444443 vm_install_sync_handler (vm , VECTOR_SYNC_CURRENT ,
445444 ESR_EC_SVC64 , guest_svc_handler );
446445
447- /* Number of breakpoints */
448- brp_num = FIELD_GET (ARM64_FEATURE_MASK (ID_AA64DFR0_BRPS ), aa64dfr0 ) + 1 ;
449- __TEST_REQUIRE (brp_num >= 2 , "At least two breakpoints are required" );
450-
451- /*
452- * Run tests with breakpoint#0, watchpoint#0, and the higiest
453- * numbered (context-aware) breakpoint.
454- */
455- vcpu_args_set (vcpu , 3 , 0 , 0 , brp_num - 1 );
446+ /* Specify bpn/wpn/ctx_bpn to be tested */
447+ vcpu_args_set (vcpu , 3 , bpn , wpn , ctx_bpn );
448+ pr_debug ("Use bpn#%d, wpn#%d and ctx_bpn#%d\n" , bpn , wpn , ctx_bpn );
456449
457450 vcpu_run (vcpu );
458451 switch (get_ucall (vcpu , & uc )) {
@@ -535,6 +528,43 @@ void test_single_step_from_userspace(int test_cnt)
535528 kvm_vm_free (vm );
536529}
537530
531+ /*
532+ * Run debug testing using the various breakpoint#, watchpoint# and
533+ * context-aware breakpoint# with the given ID_AA64DFR0_EL1 configuration.
534+ */
535+ void test_guest_debug_exceptions_all (uint64_t aa64dfr0 )
536+ {
537+ uint8_t brp_num , wrp_num , ctx_brp_num , normal_brp_num , ctx_brp_base ;
538+ int b , w , c ;
539+
540+ /* Number of breakpoints */
541+ brp_num = FIELD_GET (ARM64_FEATURE_MASK (ID_AA64DFR0_BRPS ), aa64dfr0 ) + 1 ;
542+ __TEST_REQUIRE (brp_num >= 2 , "At least two breakpoints are required" );
543+
544+ /* Number of watchpoints */
545+ wrp_num = FIELD_GET (ARM64_FEATURE_MASK (ID_AA64DFR0_WRPS ), aa64dfr0 ) + 1 ;
546+
547+ /* Number of context aware breakpoints */
548+ ctx_brp_num = FIELD_GET (ARM64_FEATURE_MASK (ID_AA64DFR0_CTX_CMPS ), aa64dfr0 ) + 1 ;
549+
550+ pr_debug ("%s brp_num:%d, wrp_num:%d, ctx_brp_num:%d\n" , __func__ ,
551+ brp_num , wrp_num , ctx_brp_num );
552+
553+ /* Number of normal (non-context aware) breakpoints */
554+ normal_brp_num = brp_num - ctx_brp_num ;
555+
556+ /* Lowest context aware breakpoint number */
557+ ctx_brp_base = normal_brp_num ;
558+
559+ /* Run tests with all supported breakpoints/watchpoints */
560+ for (c = ctx_brp_base ; c < ctx_brp_base + ctx_brp_num ; c ++ ) {
561+ for (b = 0 ; b < normal_brp_num ; b ++ ) {
562+ for (w = 0 ; w < wrp_num ; w ++ )
563+ test_guest_debug_exceptions (b , w , c );
564+ }
565+ }
566+ }
567+
538568static void help (char * name )
539569{
540570 puts ("" );
@@ -569,7 +599,7 @@ int main(int argc, char *argv[])
569599 }
570600 }
571601
572- test_guest_debug_exceptions (aa64dfr0 );
602+ test_guest_debug_exceptions_all (aa64dfr0 );
573603 test_single_step_from_userspace (ss_iteration );
574604
575605 return 0 ;
0 commit comments