PageRenderTime 105ms CodeModel.GetById 20ms RepoModel.GetById 31ms app.codeStats 0ms

/arch/mn10300/mm/mmu-context.c

https://bitbucket.org/cresqo/cm7-p500-kernel
C | 81 lines | 45 code | 13 blank | 23 comment | 9 complexity | 2e6a8cf5f6164d1c05b36f3fc86288a8 MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
  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 *ptep)
  47. {
  48. unsigned long pteu, ptel, cnx, flags;
  49. pte_t pte = *ptep;
  50. addr &= PAGE_MASK;
  51. ptel = pte_val(pte) & ~(xPTEL_UNUSED1 | xPTEL_UNUSED2);
  52. /* make sure the context doesn't migrate and defend against
  53. * interference from vmalloc'd regions */
  54. local_irq_save(flags);
  55. cnx = mm_context(vma->vm_mm);
  56. if (cnx != MMU_NO_CONTEXT) {
  57. pteu = addr | (cnx & 0x000000ffUL);
  58. if (!(pte_val(pte) & _PAGE_NX)) {
  59. IPTEU = pteu;
  60. if (IPTEL & xPTEL_V)
  61. IPTEL = ptel;
  62. }
  63. DPTEU = pteu;
  64. if (DPTEL & xPTEL_V)
  65. DPTEL = ptel;
  66. }
  67. local_irq_restore(flags);
  68. }