]> git.zerfleddert.de Git - ms2-kexec/blob - idmap.c
update offsets to new european GB kernel, set software booting from USB
[ms2-kexec] / idmap.c
1 #include <linux/kernel.h>
2
3 #include "tlbflush.h"
4 #include <asm/cputype.h>
5 #include <asm/pgalloc.h>
6 #include <asm/pgtable.h>
7
8 static void idmap_add_pmd(pud_t *pud, unsigned long addr, unsigned long end,
9 unsigned long prot)
10 {
11 pmd_t *pmd = pmd_offset(pud, addr);
12
13 addr = (addr & PMD_MASK) | prot;
14 pmd[0] = __pmd(addr);
15 addr += SECTION_SIZE;
16 pmd[1] = __pmd(addr);
17 flush_pmd_entry(pmd);
18 }
19
20 static void idmap_add_pud(pgd_t *pgd, unsigned long addr, unsigned long end,
21 unsigned long prot)
22 {
23 pud_t *pud = pud_offset(pgd, addr);
24 unsigned long next;
25
26 do {
27 next = pud_addr_end(addr, end);
28 idmap_add_pmd(pud, addr, next, prot);
29 } while (pud++, addr = next, addr != end);
30 }
31
32 void identity_mapping_add(pgd_t *pgd, unsigned long addr, unsigned long end)
33 {
34 unsigned long prot, next;
35
36 prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE;
37 #if 0
38 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale())
39 prot |= PMD_BIT4;
40 #endif
41
42 pgd += pgd_index(addr);
43 do {
44 next = pgd_addr_end(addr, end);
45 idmap_add_pud(pgd, addr, next, prot);
46 } while (pgd++, addr = next, addr != end);
47 }
48
49 #ifdef CONFIG_SMP
50 static void idmap_del_pmd(pud_t *pud, unsigned long addr, unsigned long end)
51 {
52 pmd_t *pmd = pmd_offset(pud, addr);
53 pmd_clear(pmd);
54 }
55
56 static void idmap_del_pud(pgd_t *pgd, unsigned long addr, unsigned long end)
57 {
58 pud_t *pud = pud_offset(pgd, addr);
59 unsigned long next;
60
61 do {
62 next = pud_addr_end(addr, end);
63 idmap_del_pmd(pud, addr, next);
64 } while (pud++, addr = next, addr != end);
65 }
66
67 void identity_mapping_del(pgd_t *pgd, unsigned long addr, unsigned long end)
68 {
69 unsigned long next;
70
71 pgd += pgd_index(addr);
72 do {
73 next = pgd_addr_end(addr, end);
74 idmap_del_pud(pgd, addr, next);
75 } while (pgd++, addr = next, addr != end);
76 }
77 #endif
78
79 /*
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
83 */
84 void setup_mm_for_reboot(char mode)
85 {
86 /*
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
89 * "borrowed".
90 */
91 identity_mapping_add(current->active_mm->pgd, 0, TASK_SIZE);
92 my_local_flush_tlb_all();
93 }
Impressum, Datenschutz