mmu_context.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __PPC64_MMU_CONTEXT_H
  2. #define __PPC64_MMU_CONTEXT_H
  3. #include <linux/config.h>
  4. #include <linux/kernel.h>
  5. #include <linux/mm.h>
  6. #include <asm/mmu.h>
  7. #include <asm/cputable.h>
  8. /*
  9. * Copyright (C) 2001 PPC 64 Team, IBM Corp
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. */
  16. /*
  17. * Getting into a kernel thread, there is no valid user segment, mark
  18. * paca->pgdir NULL so that SLB miss on user addresses will fault
  19. */
  20. static inline void enter_lazy_tlb(struct mm_struct *mm,
  21. struct task_struct *tsk)
  22. {
  23. #ifdef CONFIG_PPC_64K_PAGES
  24. get_paca()->pgdir = NULL;
  25. #endif /* CONFIG_PPC_64K_PAGES */
  26. }
  27. #define NO_CONTEXT 0
  28. #define MAX_CONTEXT (0x100000-1)
  29. extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
  30. extern void destroy_context(struct mm_struct *mm);
  31. extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
  32. extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
  33. /*
  34. * switch_mm is the entry point called from the architecture independent
  35. * code in kernel/sched.c
  36. */
  37. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  38. struct task_struct *tsk)
  39. {
  40. if (!cpu_isset(smp_processor_id(), next->cpu_vm_mask))
  41. cpu_set(smp_processor_id(), next->cpu_vm_mask);
  42. /* No need to flush userspace segments if the mm doesnt change */
  43. #ifdef CONFIG_PPC_64K_PAGES
  44. if (prev == next && get_paca()->pgdir == next->pgd)
  45. return;
  46. #else
  47. if (prev == next)
  48. return;
  49. #endif /* CONFIG_PPC_64K_PAGES */
  50. #ifdef CONFIG_ALTIVEC
  51. if (cpu_has_feature(CPU_FTR_ALTIVEC))
  52. asm volatile ("dssall");
  53. #endif /* CONFIG_ALTIVEC */
  54. if (cpu_has_feature(CPU_FTR_SLB))
  55. switch_slb(tsk, next);
  56. else
  57. switch_stab(tsk, next);
  58. }
  59. #define deactivate_mm(tsk,mm) do { } while (0)
  60. /*
  61. * After we have set current->mm to a new value, this activates
  62. * the context for the new mm so we see the new mappings.
  63. */
  64. static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
  65. {
  66. unsigned long flags;
  67. local_irq_save(flags);
  68. switch_mm(prev, next, current);
  69. local_irq_restore(flags);
  70. }
  71. #endif /* __PPC64_MMU_CONTEXT_H */