1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | /* |
3 | * Copyright 2022, Kajol Jain, IBM Corp. |
4 | */ |
5 | |
6 | #include <stdio.h> |
7 | #include <stdlib.h> |
8 | |
9 | #include "../event.h" |
10 | #include "utils.h" |
11 | #include "../sampling_tests/misc.h" |
12 | |
13 | /* All L1 D cache load references counted at finish, gated by reject */ |
14 | #define EventCode_1 0x1100fc |
15 | /* Load Missed L1 */ |
16 | #define EventCode_2 0x23e054 |
17 | /* Load Missed L1 */ |
18 | #define EventCode_3 0x13e054 |
19 | |
20 | /* |
21 | * Testcase for group constraint check of data and instructions |
22 | * cache qualifier bits which is used to program cache select field in |
23 | * Monitor Mode Control Register 1 (MMCR1: 16-17) for l1 cache. |
24 | * All events in the group should match cache select bits otherwise |
25 | * event_open for the group will fail. |
26 | */ |
27 | static int group_constraint_cache(void) |
28 | { |
29 | struct event event, leader; |
30 | |
31 | /* Check for platform support for the test */ |
32 | SKIP_IF(platform_check_for_tests()); |
33 | |
34 | /* Init the events for the group contraint check for l1 cache select bits */ |
35 | event_init(e: &leader, EventCode_1); |
36 | FAIL_IF(event_open(e: &leader)); |
37 | |
38 | event_init(e: &event, EventCode_2); |
39 | |
40 | /* Expected to fail as sibling event doesn't request same l1 cache select bits as leader */ |
41 | FAIL_IF(!event_open_with_group(e: &event, group_fd: leader.fd)); |
42 | |
43 | event_close(e: &event); |
44 | |
45 | /* Init the event for the group contraint l1 cache select test */ |
46 | event_init(e: &event, EventCode_3); |
47 | |
48 | /* Expected to succeed as sibling event request same l1 cache select bits as leader */ |
49 | FAIL_IF(event_open_with_group(e: &event, group_fd: leader.fd)); |
50 | |
51 | event_close(e: &leader); |
52 | event_close(e: &event); |
53 | |
54 | return 0; |
55 | } |
56 | |
57 | int main(void) |
58 | { |
59 | return test_harness(group_constraint_cache, "group_constraint_cache" ); |
60 | } |
61 | |