tlb-v7.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/mm/tlb-v7.S
  4. *
  5. * Copyright (C) 1997-2002 Russell King
  6. * Modified for ARMv7 by Catalin Marinas
  7. *
  8. * ARM architecture version 6 TLB handling functions.
  9. * These assume a split I/D TLB.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/linkage.h>
  13. #include <linux/cfi_types.h>
  14. #include <asm/assembler.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/page.h>
  17. #include <asm/tlbflush.h>
  18. #include "proc-macros.S"
  19. .arch armv7-a
  20. /*
  21. * v7wbi_flush_user_tlb_range(start, end, vma)
  22. *
  23. * Invalidate a range of TLB entries in the specified address space.
  24. *
  25. * - start - start address (may not be aligned)
  26. * - end - end address (exclusive, may not be aligned)
  27. * - vma - vm_area_struct describing address range
  28. *
  29. * It is assumed that:
  30. * - the "Invalidate single entry" instruction will invalidate
  31. * both the I and the D TLBs on Harvard-style TLBs
  32. */
  33. SYM_TYPED_FUNC_START(v7wbi_flush_user_tlb_range)
  34. vma_vm_mm r3, r2 @ get vma->vm_mm
  35. mmid r3, r3 @ get vm_mm->context.id
  36. dsb ish
  37. mov r0, r0, lsr #PAGE_SHIFT @ align address
  38. mov r1, r1, lsr #PAGE_SHIFT
  39. asid r3, r3 @ mask ASID
  40. #ifdef CONFIG_ARM_ERRATA_720789
  41. ALT_SMP(W(mov) r3, #0 )
  42. ALT_UP(W(nop) )
  43. #endif
  44. orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA
  45. mov r1, r1, lsl #PAGE_SHIFT
  46. 1:
  47. #ifdef CONFIG_ARM_ERRATA_720789
  48. ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable)
  49. #else
  50. ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable)
  51. #endif
  52. ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA
  53. add r0, r0, #PAGE_SZ
  54. cmp r0, r1
  55. blo 1b
  56. dsb ish
  57. ret lr
  58. SYM_FUNC_END(v7wbi_flush_user_tlb_range)
  59. /*
  60. * v7wbi_flush_kern_tlb_range(start,end)
  61. *
  62. * Invalidate a range of kernel TLB entries
  63. *
  64. * - start - start address (may not be aligned)
  65. * - end - end address (exclusive, may not be aligned)
  66. */
  67. SYM_TYPED_FUNC_START(v7wbi_flush_kern_tlb_range)
  68. dsb ish
  69. mov r0, r0, lsr #PAGE_SHIFT @ align address
  70. mov r1, r1, lsr #PAGE_SHIFT
  71. mov r0, r0, lsl #PAGE_SHIFT
  72. mov r1, r1, lsl #PAGE_SHIFT
  73. 1:
  74. #ifdef CONFIG_ARM_ERRATA_720789
  75. ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable)
  76. #else
  77. ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable)
  78. #endif
  79. ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA
  80. add r0, r0, #PAGE_SZ
  81. cmp r0, r1
  82. blo 1b
  83. dsb ish
  84. isb
  85. ret lr
  86. SYM_FUNC_END(v7wbi_flush_kern_tlb_range)