mmu-context.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* MN10300 MMU context allocation and management
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <asm/mmu_context.h>
  14. #include <asm/tlbflush.h>
  15. /*
  16. * list of the MMU contexts last allocated on each CPU
  17. */
  18. unsigned long mmu_context_cache[NR_CPUS] = {
  19. [0 ... NR_CPUS - 1] = MMU_CONTEXT_FIRST_VERSION * 2 - 1,
  20. };
  21. /*
  22. * flush the specified TLB entry
  23. */
  24. void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
  25. {
  26. unsigned long pteu, cnx, flags;
  27. addr &= PAGE_MASK;
  28. /* make sure the context doesn't migrate and defend against
  29. * interference from vmalloc'd regions */
  30. local_irq_save(flags);
  31. cnx = mm_context(vma->vm_mm);
  32. if (cnx != MMU_NO_CONTEXT) {
  33. pteu = addr | (cnx & 0x000000ffUL);
  34. IPTEU = pteu;
  35. DPTEU = pteu;
  36. if (IPTEL & xPTEL_V)
  37. IPTEL = 0;
  38. if (DPTEL & xPTEL_V)
  39. DPTEL = 0;
  40. }
  41. local_irq_restore(flags);
  42. }
  43. /*
  44. * preemptively set a TLB entry
  45. */
  46. void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
  47. {
  48. unsigned long pteu, ptel, cnx, flags;
  49. addr &= PAGE_MASK;
  50. ptel = pte_val(pte) & ~(xPTEL_UNUSED1 | xPTEL_UNUSED2);
  51. /* make sure the context doesn't migrate and defend against
  52. * interference from vmalloc'd regions */
  53. local_irq_save(flags);
  54. cnx = mm_context(vma->vm_mm);
  55. if (cnx != MMU_NO_CONTEXT) {
  56. pteu = addr | (cnx & 0x000000ffUL);
  57. if (!(pte_val(pte) & _PAGE_NX)) {
  58. IPTEU = pteu;
  59. if (IPTEL & xPTEL_V)
  60. IPTEL = ptel;
  61. }
  62. DPTEU = pteu;
  63. if (DPTEL & xPTEL_V)
  64. DPTEL = ptel;
  65. }
  66. local_irq_restore(flags);
  67. }