mmu-context.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifdef CONFIG_MN10300_TLB_USE_PIDR
  16. /*
  17. * list of the MMU contexts last allocated on each CPU
  18. */
  19. unsigned long mmu_context_cache[NR_CPUS] = {
  20. [0 ... NR_CPUS - 1] =
  21. MMU_CONTEXT_FIRST_VERSION * 2 - (1 - MMU_CONTEXT_TLBPID_LOCK_NR),
  22. };
  23. #endif /* CONFIG_MN10300_TLB_USE_PIDR */
  24. /*
  25. * preemptively set a TLB entry
  26. */
  27. void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
  28. {
  29. unsigned long pteu, ptel, cnx, flags;
  30. pte_t pte = *ptep;
  31. addr &= PAGE_MASK;
  32. ptel = pte_val(pte) & ~(xPTEL_UNUSED1 | xPTEL_UNUSED2);
  33. /* make sure the context doesn't migrate and defend against
  34. * interference from vmalloc'd regions */
  35. local_irq_save(flags);
  36. cnx = ~MMU_NO_CONTEXT;
  37. #ifdef CONFIG_MN10300_TLB_USE_PIDR
  38. cnx = mm_context(vma->vm_mm);
  39. #endif
  40. if (cnx != MMU_NO_CONTEXT) {
  41. pteu = addr;
  42. #ifdef CONFIG_MN10300_TLB_USE_PIDR
  43. pteu |= cnx & MMU_CONTEXT_TLBPID_MASK;
  44. #endif
  45. if (!(pte_val(pte) & _PAGE_NX)) {
  46. IPTEU = pteu;
  47. if (IPTEL & xPTEL_V)
  48. IPTEL = ptel;
  49. }
  50. DPTEU = pteu;
  51. if (DPTEL & xPTEL_V)
  52. DPTEL = ptel;
  53. }
  54. local_irq_restore(flags);
  55. }