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