2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
15 * Test that closing the EBB event clears MMCR0_PMCC, preventing further access
16 * by userspace to the PMU hardware.
19 int close_clears_pmcc(void)
23 SKIP_IF(!ebb_is_supported());
25 event_init_named(&event, 0x1001e, "cycles");
26 event_leader_ebb_init(&event);
28 FAIL_IF(event_open(&event));
30 ebb_enable_pmc_counting(1);
31 setup_ebb_handler(standard_ebb_callee);
33 FAIL_IF(ebb_event_enable(&event));
35 mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
37 while (ebb_state.stats.ebb_count < 1)
38 FAIL_IF(core_busy_loop());
43 FAIL_IF(ebb_state.stats.ebb_count == 0);
45 /* The real test is here, do we take a SIGILL when writing PMU regs now
46 * that we have closed the event. We expect that we will. */
48 FAIL_IF(catch_sigill(write_pmc1));
50 /* We should still be able to read EBB regs though */
60 return test_harness(close_clears_pmcc, "close_clears_pmcc");