1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright 2022, Athira Rajeev, IBM Corp. 4 */ 5 6 #include <stdio.h> 7 #include "../event.h" 8 #include "../sampling_tests/misc.h" 9 10 /* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L2 */ 11 #define EventCode_1 0x14242 12 /* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L3 */ 13 #define EventCode_2 0x24242 14 15 /* 16 * Testcase for group constraint check for radix_scope_qual 17 * field which is used to program Monitor Mode Control 18 * egister (MMCR1) bit 18. 19 * All events in the group should match radix_scope_qual, 20 * bits otherwise event_open for the group should fail. 21 */ 22 23 static int group_constraint_radix_scope_qual(void) 24 { 25 struct event event, leader; 26 27 /* 28 * Check for platform support for the test. 29 * This test is aplicable on power10 only. 30 */ 31 SKIP_IF(platform_check_for_tests()); 32 SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1)); 33 34 /* Init the events for the group contraint check for radix_scope_qual bits */ 35 event_init(&leader, EventCode_1); 36 FAIL_IF(event_open(&leader)); 37 38 event_init(&event, 0x200fc); 39 40 /* Expected to fail as sibling event doesn't request same radix_scope_qual bits as leader */ 41 FAIL_IF(!event_open_with_group(&event, leader.fd)); 42 43 event_init(&event, EventCode_2); 44 /* Expected to pass as sibling event request same radix_scope_qual bits as leader */ 45 FAIL_IF(event_open_with_group(&event, leader.fd)); 46 47 event_close(&leader); 48 event_close(&event); 49 return 0; 50 } 51 52 int main(void) 53 { 54 return test_harness(group_constraint_radix_scope_qual, 55 "group_constraint_radix_scope_qual"); 56 } 57