bpi.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Contains CPU specific branch predictor invalidation sequences
  3. *
  4. * Copyright (C) 2018 ARM Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/linkage.h>
  19. #include <linux/arm-smccc.h>
  20. .macro ventry target
  21. .rept 31
  22. nop
  23. .endr
  24. b \target
  25. .endm
  26. .macro vectors target
  27. ventry \target + 0x000
  28. ventry \target + 0x080
  29. ventry \target + 0x100
  30. ventry \target + 0x180
  31. ventry \target + 0x200
  32. ventry \target + 0x280
  33. ventry \target + 0x300
  34. ventry \target + 0x380
  35. ventry \target + 0x400
  36. ventry \target + 0x480
  37. ventry \target + 0x500
  38. ventry \target + 0x580
  39. ventry \target + 0x600
  40. ventry \target + 0x680
  41. ventry \target + 0x700
  42. ventry \target + 0x780
  43. .endm
  44. .align 11
  45. ENTRY(__bp_harden_hyp_vecs_start)
  46. .rept 4
  47. vectors __kvm_hyp_vector
  48. .endr
  49. ENTRY(__bp_harden_hyp_vecs_end)
  50. .macro smccc_workaround_1 inst
  51. sub sp, sp, #(8 * 4)
  52. stp x2, x3, [sp, #(8 * 0)]
  53. stp x0, x1, [sp, #(8 * 2)]
  54. mov w0, #ARM_SMCCC_ARCH_WORKAROUND_1
  55. \inst #0
  56. ldp x2, x3, [sp, #(8 * 0)]
  57. ldp x0, x1, [sp, #(8 * 2)]
  58. add sp, sp, #(8 * 4)
  59. .endm
  60. ENTRY(__smccc_workaround_1_smc_start)
  61. smccc_workaround_1 smc
  62. ENTRY(__smccc_workaround_1_smc_end)
  63. ENTRY(__smccc_workaround_1_hvc_start)
  64. smccc_workaround_1 hvc
  65. ENTRY(__smccc_workaround_1_hvc_end)