tlbflush.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  4. */
  5. #ifndef __UM_TLBFLUSH_H
  6. #define __UM_TLBFLUSH_H
  7. #include <linux/mm.h>
  8. /*
  9. * In UML, we need to sync the TLB over by using mmap/munmap syscalls from
  10. * the process handling the MM (which can be the kernel itself).
  11. *
  12. * To track updates, we can hook into set_ptes and flush_tlb_*. With set_ptes
  13. * we catch all PTE transitions where memory that was unusable becomes usable.
  14. * While with flush_tlb_* we can track any memory that becomes unusable and
  15. * even if a higher layer of the page table was modified.
  16. *
  17. * So, we simply track updates using both methods and mark the memory area to
  18. * be synced later on. The only special case is that flush_tlb_kern_* needs to
  19. * be executed immediately as there is no good synchronization point in that
  20. * case. In contrast, in the set_ptes case we can wait for the next kernel
  21. * segfault before we do the synchornization.
  22. *
  23. * - flush_tlb_all() flushes all processes TLBs
  24. * - flush_tlb_mm(mm) flushes the specified mm context TLB's
  25. * - flush_tlb_page(vma, vmaddr) flushes one page
  26. * - flush_tlb_range(vma, start, end) flushes a range of pages
  27. * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
  28. */
  29. extern int um_tlb_sync(struct mm_struct *mm);
  30. extern void flush_tlb_all(void);
  31. extern void flush_tlb_mm(struct mm_struct *mm);
  32. static inline void flush_tlb_page(struct vm_area_struct *vma,
  33. unsigned long address)
  34. {
  35. um_tlb_mark_sync(vma->vm_mm, address, address + PAGE_SIZE);
  36. }
  37. static inline void flush_tlb_range(struct vm_area_struct *vma,
  38. unsigned long start, unsigned long end)
  39. {
  40. um_tlb_mark_sync(vma->vm_mm, start, end);
  41. }
  42. static inline void flush_tlb_kernel_range(unsigned long start,
  43. unsigned long end)
  44. {
  45. um_tlb_mark_sync(&init_mm, start, end);
  46. /* Kernel needs to be synced immediately */
  47. um_tlb_sync(&init_mm);
  48. }
  49. #endif