wa_cve_2017_5715_bpiall.S 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. .globl wa_cve_2017_5715_bpiall_vbar
  8. vector_base wa_cve_2017_5715_bpiall_vbar
  9. /* We encode the exception entry in the bottom 3 bits of SP */
  10. add sp, sp, #1 /* Reset: 0b111 */
  11. add sp, sp, #1 /* Undef: 0b110 */
  12. add sp, sp, #1 /* Syscall: 0b101 */
  13. add sp, sp, #1 /* Prefetch abort: 0b100 */
  14. add sp, sp, #1 /* Data abort: 0b011 */
  15. add sp, sp, #1 /* Reserved: 0b010 */
  16. add sp, sp, #1 /* IRQ: 0b001 */
  17. nop /* FIQ: 0b000 */
  18. /*
  19. * Invalidate the branch predictor, `r0` is a dummy register
  20. * and is unused.
  21. */
  22. stcopr r0, BPIALL
  23. isb
  24. /*
  25. * As we cannot use any temporary registers and cannot
  26. * clobber SP, we can decode the exception entry using
  27. * an unrolled binary search.
  28. *
  29. * Note, if this code is re-used by other secure payloads,
  30. * the below exception entry vectors must be changed to
  31. * the vectors specific to that secure payload.
  32. */
  33. tst sp, #4
  34. bne 1f
  35. tst sp, #2
  36. bne 3f
  37. /* Expected encoding: 0x1 and 0x0 */
  38. tst sp, #1
  39. /* Restore original value of SP by clearing the bottom 3 bits */
  40. bic sp, sp, #0x7
  41. bne plat_panic_handler /* IRQ */
  42. b sp_min_handle_fiq /* FIQ */
  43. 1:
  44. tst sp, #2
  45. bne 2f
  46. /* Expected encoding: 0x4 and 0x5 */
  47. tst sp, #1
  48. bic sp, sp, #0x7
  49. bne sp_min_handle_smc /* Syscall */
  50. b plat_panic_handler /* Prefetch abort */
  51. 2:
  52. /* Expected encoding: 0x7 and 0x6 */
  53. tst sp, #1
  54. bic sp, sp, #0x7
  55. bne sp_min_entrypoint /* Reset */
  56. b plat_panic_handler /* Undef */
  57. 3:
  58. /* Expected encoding: 0x2 and 0x3 */
  59. tst sp, #1
  60. bic sp, sp, #0x7
  61. bne plat_panic_handler /* Data abort */
  62. b plat_panic_handler /* Reserved */