|
189 | 189 | .Lskip_set_cptr_\@:
|
190 | 190 | .endm
|
191 | 191 |
|
| 192 | +/* |
| 193 | + * Configure BRBE to permit recording cycle counts and branch mispredicts. |
| 194 | + * |
| 195 | + * At any EL, to record cycle counts BRBE requires that both BRBCR_EL2.CC=1 and |
| 196 | + * BRBCR_EL1.CC=1. |
| 197 | + * |
| 198 | + * At any EL, to record branch mispredicts BRBE requires that both |
| 199 | + * BRBCR_EL2.MPRED=1 and BRBCR_EL1.MPRED=1. |
| 200 | + * |
| 201 | + * Set {CC,MPRED} in BRBCR_EL2 in case nVHE mode is used and we are |
| 202 | + * executing in EL1. |
| 203 | + */ |
| 204 | +.macro __init_el2_brbe |
| 205 | + mrs x1, id_aa64dfr0_el1 |
| 206 | + ubfx x1, x1, #ID_AA64DFR0_EL1_BRBE_SHIFT, #4 |
| 207 | + cbz x1, .Lskip_brbe_\@ |
| 208 | + |
| 209 | + mov_q x0, BRBCR_ELx_CC | BRBCR_ELx_MPRED |
| 210 | + msr_s SYS_BRBCR_EL2, x0 |
| 211 | +.Lskip_brbe_\@: |
| 212 | +.endm |
| 213 | + |
192 | 214 | /* Disable any fine grained traps */
|
193 | 215 | .macro __init_el2_fgt
|
194 | 216 | mrs x1, id_aa64mmfr0_el1
|
195 | 217 | ubfx x1, x1, #ID_AA64MMFR0_EL1_FGT_SHIFT, #4
|
196 | 218 | cbz x1, .Lskip_fgt_\@
|
197 | 219 |
|
198 | 220 | mov x0, xzr
|
| 221 | + mov x2, xzr |
199 | 222 | mrs x1, id_aa64dfr0_el1
|
200 | 223 | ubfx x1, x1, #ID_AA64DFR0_EL1_PMSVer_SHIFT, #4
|
201 | 224 | cmp x1, #3
|
202 | 225 | b.lt .Lskip_spe_fgt_\@
|
203 | 226 | /* Disable PMSNEVFR_EL1 read and write traps */
|
204 |
| - orr x0, x0, #(1 << 62) |
| 227 | + orr x0, x0, #HDFGRTR_EL2_nPMSNEVFR_EL1_MASK |
| 228 | + orr x2, x2, #HDFGWTR_EL2_nPMSNEVFR_EL1_MASK |
205 | 229 |
|
206 | 230 | .Lskip_spe_fgt_\@:
|
| 231 | + mrs x1, id_aa64dfr0_el1 |
| 232 | + ubfx x1, x1, #ID_AA64DFR0_EL1_BRBE_SHIFT, #4 |
| 233 | + cbz x1, .Lskip_brbe_fgt_\@ |
| 234 | + |
| 235 | + /* |
| 236 | + * Disable read traps for the following registers |
| 237 | + * |
| 238 | + * [BRBSRC|BRBTGT|RBINF]_EL1 |
| 239 | + * [BRBSRCINJ|BRBTGTINJ|BRBINFINJ|BRBTS]_EL1 |
| 240 | + */ |
| 241 | + orr x0, x0, #HDFGRTR_EL2_nBRBDATA_MASK |
| 242 | + |
| 243 | + /* |
| 244 | + * Disable write traps for the following registers |
| 245 | + * |
| 246 | + * [BRBSRCINJ|BRBTGTINJ|BRBINFINJ|BRBTS]_EL1 |
| 247 | + */ |
| 248 | + orr x2, x2, #HDFGWTR_EL2_nBRBDATA_MASK |
| 249 | + |
| 250 | + /* Disable read and write traps for [BRBCR|BRBFCR]_EL1 */ |
| 251 | + orr x0, x0, #HDFGRTR_EL2_nBRBCTL_MASK |
| 252 | + orr x2, x2, #HDFGWTR_EL2_nBRBCTL_MASK |
| 253 | + |
| 254 | + /* Disable read traps for BRBIDR_EL1 */ |
| 255 | + orr x0, x0, #HDFGRTR_EL2_nBRBIDR_MASK |
| 256 | + |
| 257 | +.Lskip_brbe_fgt_\@: |
207 | 258 |
|
208 | 259 | .Lset_debug_fgt_\@:
|
209 | 260 | msr_s SYS_HDFGRTR_EL2, x0
|
210 |
| - msr_s SYS_HDFGWTR_EL2, x0 |
| 261 | + msr_s SYS_HDFGWTR_EL2, x2 |
211 | 262 |
|
212 | 263 | mov x0, xzr
|
| 264 | + mov x2, xzr |
| 265 | + |
| 266 | + mrs x1, id_aa64dfr0_el1 |
| 267 | + ubfx x1, x1, #ID_AA64DFR0_EL1_BRBE_SHIFT, #4 |
| 268 | + cbz x1, .Lskip_brbe_insn_fgt_\@ |
| 269 | + |
| 270 | + /* Disable traps for BRBIALL instruction */ |
| 271 | + orr x2, x2, #HFGITR_EL2_nBRBIALL_MASK |
| 272 | + |
| 273 | + /* Disable traps for BRBINJ instruction */ |
| 274 | + orr x2, x2, #HFGITR_EL2_nBRBINJ_MASK |
| 275 | + |
| 276 | +.Lskip_brbe_insn_fgt_\@: |
213 | 277 | mrs x1, id_aa64pfr1_el1
|
214 | 278 | ubfx x1, x1, #ID_AA64PFR1_EL1_SME_SHIFT, #4
|
215 | 279 | cbz x1, .Lskip_sme_fgt_\@
|
|
250 | 314 | .Lset_fgt_\@:
|
251 | 315 | msr_s SYS_HFGRTR_EL2, x0
|
252 | 316 | msr_s SYS_HFGWTR_EL2, x0
|
253 |
| - msr_s SYS_HFGITR_EL2, xzr |
| 317 | + msr_s SYS_HFGITR_EL2, x2 |
254 | 318 |
|
255 | 319 | mrs x1, id_aa64pfr0_el1 // AMU traps UNDEF without AMU
|
256 | 320 | ubfx x1, x1, #ID_AA64PFR0_EL1_AMU_SHIFT, #4
|
|
300 | 364 | __init_el2_hcrx
|
301 | 365 | __init_el2_timers
|
302 | 366 | __init_el2_debug
|
| 367 | + __init_el2_brbe |
303 | 368 | __init_el2_lor
|
304 | 369 | __init_el2_stage2
|
305 | 370 | __init_el2_gicv3
|
|
0 commit comments