e5df015b06fd85b92951db4babd499c7b921a5fa
2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
8 #include <arch_helpers.h>
13 static inline void psb_csync(void)
16 * The assembler does not yet understand the psb csync mnemonic
17 * so use the equivalent hint instruction.
19 __asm__
volatile("hint #17");
22 bool spe_supported(void)
26 features
= read_id_aa64dfr0_el1() >> ID_AA64DFR0_PMS_SHIFT
;
27 return (features
& ID_AA64DFR0_PMS_MASK
) == 1U;
30 void spe_enable(bool el2_unused
)
39 * MDCR_EL2.TPMS (ARM v8.2): Do not trap statistical
40 * profiling controls to EL2.
42 * MDCR_EL2.E2PB (ARM v8.2): SPE enabled in Non-secure
43 * state. Accesses to profiling buffer controls at
44 * Non-secure EL1 are not trapped to EL2.
48 v
|= MDCR_EL2_E2PB(MDCR_EL2_E2PB_EL1
);
53 * MDCR_EL2.NSPB (ARM v8.2): SPE enabled in Non-secure state
54 * and disabled in secure state. Accesses to SPE registers at
55 * S-EL1 generate trap exceptions to EL3.
58 v
|= MDCR_NSPB(MDCR_NSPB_EL1
);
62 void spe_disable(void)
69 /* Drain buffered data */
73 /* Disable profiling buffer */
74 v
= read_pmblimitr_el1();
76 write_pmblimitr_el1(v
);
80 static void *spe_drain_buffers_hook(const void *arg
)
85 /* Drain buffered data */
92 SUBSCRIBE_TO_EVENT(cm_entering_secure_world
, spe_drain_buffers_hook
);