pgtable_32.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/api.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. p4d_t *p4d;
  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. p4d = p4d_offset(pgd, vaddr);
  36. if (p4d_none(*p4d)) {
  37. BUG();
  38. return;
  39. }
  40. pud = pud_offset(p4d, vaddr);
  41. if (pud_none(*pud)) {
  42. BUG();
  43. return;
  44. }
  45. pmd = pmd_offset(pud, vaddr);
  46. if (pmd_none(*pmd)) {
  47. BUG();
  48. return;
  49. }
  50. pte = pte_offset_kernel(pmd, vaddr);
  51. if (!pte_none(pteval))
  52. set_pte_at(&init_mm, vaddr, pte, pteval);
  53. else
  54. pte_clear(&init_mm, vaddr, pte);
  55. /*
  56. * It's enough to flush this one mapping.
  57. * (PGE mappings get flushed as well)
  58. */
  59. __flush_tlb_one(vaddr);
  60. }
  61. unsigned long __FIXADDR_TOP = 0xfffff000;
  62. EXPORT_SYMBOL(__FIXADDR_TOP);
  63. /*
  64. * vmalloc=size forces the vmalloc area to be exactly 'size'
  65. * bytes. This can be used to increase (or decrease) the
  66. * vmalloc area - the default is 128m.
  67. */
  68. static int __init parse_vmalloc(char *arg)
  69. {
  70. if (!arg)
  71. return -EINVAL;
  72. /* Add VMALLOC_OFFSET to the parsed value due to vm area guard hole*/
  73. __VMALLOC_RESERVE = memparse(arg, &arg) + VMALLOC_OFFSET;
  74. return 0;
  75. }
  76. early_param("vmalloc", parse_vmalloc);
  77. /*
  78. * reservetop=size reserves a hole at the top of the kernel address space which
  79. * a hypervisor can load into later. Needed for dynamically loaded hypervisors,
  80. * so relocating the fixmap can be done before paging initialization.
  81. */
  82. static int __init parse_reservetop(char *arg)
  83. {
  84. unsigned long address;
  85. if (!arg)
  86. return -EINVAL;
  87. address = memparse(arg, &arg);
  88. reserve_top_address(address);
  89. early_ioremap_init();
  90. return 0;
  91. }
  92. early_param("reservetop", parse_reservetop);