vm_tlb.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Hexagon Virtual Machine TLB functions
  3. *
  4. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  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 and
  8. * only version 2 as 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, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. /*
  21. * The Hexagon Virtual Machine conceals the real workings of
  22. * the TLB, but there are one or two functions that need to
  23. * be instantiated for it, differently from a native build.
  24. */
  25. #include <linux/mm.h>
  26. #include <asm/page.h>
  27. #include <asm/hexagon_vm.h>
  28. /*
  29. * Initial VM implementation has only one map active at a time, with
  30. * TLB purgings on changes. So either we're nuking the current map,
  31. * or it's a no-op. This operation is messy on true SMPs where other
  32. * processors must be induced to flush the copies in their local TLBs,
  33. * but Hexagon thread-based virtual processors share the same MMU.
  34. */
  35. void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  36. unsigned long end)
  37. {
  38. struct mm_struct *mm = vma->vm_mm;
  39. if (mm->context.ptbase == current->active_mm->context.ptbase)
  40. __vmclrmap((void *)start, end - start);
  41. }
  42. /*
  43. * Flush a page from the kernel virtual map - used by highmem
  44. */
  45. void flush_tlb_one(unsigned long vaddr)
  46. {
  47. __vmclrmap((void *)vaddr, PAGE_SIZE);
  48. }
  49. /*
  50. * Flush all TLBs across all CPUs, virtual or real.
  51. * A single Hexagon core has 6 thread contexts but
  52. * only one TLB.
  53. */
  54. void tlb_flush_all(void)
  55. {
  56. /* should probably use that fixaddr end or whateve label */
  57. __vmclrmap(0, 0xffff0000);
  58. }
  59. /*
  60. * Flush TLB entries associated with a given mm_struct mapping.
  61. */
  62. void flush_tlb_mm(struct mm_struct *mm)
  63. {
  64. /* Current Virtual Machine has only one map active at a time */
  65. if (current->active_mm->context.ptbase == mm->context.ptbase)
  66. tlb_flush_all();
  67. }
  68. /*
  69. * Flush TLB state associated with a page of a vma.
  70. */
  71. void flush_tlb_page(struct vm_area_struct *vma, unsigned long vaddr)
  72. {
  73. struct mm_struct *mm = vma->vm_mm;
  74. if (mm->context.ptbase == current->active_mm->context.ptbase)
  75. __vmclrmap((void *)vaddr, PAGE_SIZE);
  76. }
  77. /*
  78. * Flush TLB entries associated with a kernel address range.
  79. * Like flush range, but without the check on the vma->vm_mm.
  80. */
  81. void flush_tlb_kernel_range(unsigned long start, unsigned long end)
  82. {
  83. __vmclrmap((void *)start, end - start);
  84. }