pgtable_32.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include <linux/sched.h>
  2. #include <linux/kernel.h>
  3. #include <linux/errno.h>
  4. #include <linux/mm.h>
  5. #include <linux/nmi.h>
  6. #include <linux/swap.h>
  7. #include <linux/smp.h>
  8. #include <linux/highmem.h>
  9. #include <linux/pagemap.h>
  10. #include <linux/spinlock.h>
  11. #include <asm/pgtable.h>
  12. #include <asm/pgalloc.h>
  13. #include <asm/fixmap.h>
  14. #include <asm/e820.h>
  15. #include <asm/tlb.h>
  16. #include <asm/tlbflush.h>
  17. #include <asm/io.h>
  18. unsigned int __VMALLOC_RESERVE = 128 << 20;
  19. /*
  20. * Associate a virtual page frame with a given physical page frame
  21. * and protection flags for that frame.
  22. */
  23. void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
  24. {
  25. pgd_t *pgd;
  26. pud_t *pud;
  27. pmd_t *pmd;
  28. pte_t *pte;
  29. pgd = swapper_pg_dir + pgd_index(vaddr);
  30. if (pgd_none(*pgd)) {
  31. BUG();
  32. return;
  33. }
  34. pud = pud_offset(pgd, vaddr);
  35. if (pud_none(*pud)) {
  36. BUG();
  37. return;
  38. }
  39. pmd = pmd_offset(pud, vaddr);
  40. if (pmd_none(*pmd)) {
  41. BUG();
  42. return;
  43. }
  44. pte = pte_offset_kernel(pmd, vaddr);
  45. if (!pte_none(pteval))
  46. set_pte_at(&init_mm, vaddr, pte, pteval);
  47. else
  48. pte_clear(&init_mm, vaddr, pte);
  49. /*
  50. * It's enough to flush this one mapping.
  51. * (PGE mappings get flushed as well)
  52. */
  53. __flush_tlb_one(vaddr);
  54. }
  55. unsigned long __FIXADDR_TOP = 0xfffff000;
  56. EXPORT_SYMBOL(__FIXADDR_TOP);
  57. /*
  58. * vmalloc=size forces the vmalloc area to be exactly 'size'
  59. * bytes. This can be used to increase (or decrease) the
  60. * vmalloc area - the default is 128m.
  61. */
  62. static int __init parse_vmalloc(char *arg)
  63. {
  64. if (!arg)
  65. return -EINVAL;
  66. /* Add VMALLOC_OFFSET to the parsed value due to vm area guard hole*/
  67. __VMALLOC_RESERVE = memparse(arg, &arg) + VMALLOC_OFFSET;
  68. return 0;
  69. }
  70. early_param("vmalloc", parse_vmalloc);
  71. /*
  72. * reservetop=size reserves a hole at the top of the kernel address space which
  73. * a hypervisor can load into later. Needed for dynamically loaded hypervisors,
  74. * so relocating the fixmap can be done before paging initialization.
  75. */
  76. static int __init parse_reservetop(char *arg)
  77. {
  78. unsigned long address;
  79. if (!arg)
  80. return -EINVAL;
  81. address = memparse(arg, &arg);
  82. reserve_top_address(address);
  83. early_ioremap_init();
  84. return 0;
  85. }
  86. early_param("reservetop", parse_reservetop);