]>
git.zerfleddert.de Git - ms2-kexec/blob - idmap.c
1 #include <linux/kernel.h>
4 #include <asm/cputype.h>
5 #include <asm/pgalloc.h>
6 #include <asm/pgtable.h>
8 static void idmap_add_pmd(pud_t
*pud
, unsigned long addr
, unsigned long end
,
11 pmd_t
*pmd
= pmd_offset(pud
, addr
);
13 addr
= (addr
& PMD_MASK
) | prot
;
20 static void idmap_add_pud(pgd_t
*pgd
, unsigned long addr
, unsigned long end
,
23 pud_t
*pud
= pud_offset(pgd
, addr
);
27 next
= pud_addr_end(addr
, end
);
28 idmap_add_pmd(pud
, addr
, next
, prot
);
29 } while (pud
++, addr
= next
, addr
!= end
);
32 void identity_mapping_add(pgd_t
*pgd
, unsigned long addr
, unsigned long end
)
34 unsigned long prot
, next
;
36 prot
= PMD_TYPE_SECT
| PMD_SECT_AP_WRITE
;
38 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ
&& !cpu_is_xscale())
42 pgd
+= pgd_index(addr
);
44 next
= pgd_addr_end(addr
, end
);
45 idmap_add_pud(pgd
, addr
, next
, prot
);
46 } while (pgd
++, addr
= next
, addr
!= end
);
50 static void idmap_del_pmd(pud_t
*pud
, unsigned long addr
, unsigned long end
)
52 pmd_t
*pmd
= pmd_offset(pud
, addr
);
56 static void idmap_del_pud(pgd_t
*pgd
, unsigned long addr
, unsigned long end
)
58 pud_t
*pud
= pud_offset(pgd
, addr
);
62 next
= pud_addr_end(addr
, end
);
63 idmap_del_pmd(pud
, addr
, next
);
64 } while (pud
++, addr
= next
, addr
!= end
);
67 void identity_mapping_del(pgd_t
*pgd
, unsigned long addr
, unsigned long end
)
71 pgd
+= pgd_index(addr
);
73 next
= pgd_addr_end(addr
, end
);
74 idmap_del_pud(pgd
, addr
, next
);
75 } while (pgd
++, addr
= next
, addr
!= end
);
80 * In order to soft-boot, we need to insert a 1:1 mapping in place of
81 * the user-mode pages. This will then ensure that we have predictable
82 * results when turning the mmu off
84 void setup_mm_for_reboot(char mode
)
87 * We need to access to user-mode page tables here. For kernel threads
88 * we don't have any user-mode mappings so we use the context that we
91 identity_mapping_add(current
->active_mm
->pgd
, 0, TASK_SIZE
);
92 my_local_flush_tlb_all();