wa_cve_2017_5715_icache_inv.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_icache_inv_vbar
  8. vector_base wa_cve_2017_5715_icache_inv_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 instruction cache, which we assume also
  20. * invalidates the branch predictor. This may depend on
  21. * other CPU specific changes (e.g. an ACTLR setting).
  22. */
  23. stcopr r0, ICIALLU
  24. isb
  25. /*
  26. * As we cannot use any temporary registers and cannot
  27. * clobber SP, we can decode the exception entry using
  28. * an unrolled binary search.
  29. *
  30. * Note, if this code is re-used by other secure payloads,
  31. * the below exception entry vectors must be changed to
  32. * the vectors specific to that secure payload.
  33. */
  34. tst sp, #4
  35. bne 1f
  36. tst sp, #2
  37. bne 3f
  38. /* Expected encoding: 0x1 and 0x0 */
  39. tst sp, #1
  40. /* Restore original value of SP by clearing the bottom 3 bits */
  41. bic sp, sp, #0x7
  42. bne plat_panic_handler /* IRQ */
  43. b sp_min_handle_fiq /* FIQ */
  44. 1:
  45. /* Expected encoding: 0x4 and 0x5 */
  46. tst sp, #2
  47. bne 2f
  48. tst sp, #1
  49. bic sp, sp, #0x7
  50. bne sp_min_handle_smc /* Syscall */
  51. b plat_panic_handler /* Prefetch abort */
  52. 2:
  53. /* Expected encoding: 0x7 and 0x6 */
  54. tst sp, #1
  55. bic sp, sp, #0x7
  56. bne sp_min_entrypoint /* Reset */
  57. b plat_panic_handler /* Undef */
  58. 3:
  59. /* Expected encoding: 0x2 and 0x3 */
  60. tst sp, #1
  61. bic sp, sp, #0x7
  62. bne plat_panic_handler /* Data abort */
  63. b plat_panic_handler /* Reserved */