Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright 2014, Michael Ellerman, IBM Corp.
0004  */
0005 
0006 #include <stdio.h>
0007 #include <stdlib.h>
0008 #include <setjmp.h>
0009 #include <signal.h>
0010 
0011 #include "ebb.h"
0012 
0013 
0014 /* Test that things work sanely if we have no handler */
0015 
0016 static int no_handler_test(void)
0017 {
0018     struct event event;
0019     u64 val;
0020     int i;
0021 
0022     SKIP_IF(!ebb_is_supported());
0023 
0024     event_init_named(&event, 0x1001e, "cycles");
0025     event_leader_ebb_init(&event);
0026 
0027     event.attr.exclude_kernel = 1;
0028     event.attr.exclude_hv = 1;
0029     event.attr.exclude_idle = 1;
0030 
0031     FAIL_IF(event_open(&event));
0032     FAIL_IF(ebb_event_enable(&event));
0033 
0034     val = mfspr(SPRN_EBBHR);
0035     FAIL_IF(val != 0);
0036 
0037     /* Make sure it overflows quickly */
0038     sample_period = 1000;
0039     mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
0040 
0041     /* Spin to make sure the event has time to overflow */
0042     for (i = 0; i < 1000; i++)
0043         mb();
0044 
0045     dump_ebb_state();
0046 
0047     /* We expect to see the PMU frozen & PMAO set */
0048     val = mfspr(SPRN_MMCR0);
0049     FAIL_IF(val != 0x0000000080000080);
0050 
0051     event_close(&event);
0052 
0053     /* The real test is that we never took an EBB at 0x0 */
0054 
0055     return 0;
0056 }
0057 
0058 int main(void)
0059 {
0060     return test_harness(no_handler_test,"no_handler_test");
0061 }