aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-11-21 06:41:57 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-12-22 06:05:33 -0500
commit614dd0585f376a25c638abbed9c5fbd21d7baece (patch)
tree9bd2c8bb3523632901e3ddc3f9b1eba24e7671ab /arch
parent26bbf0b57a0848932f725076bcb1245ca696e8d3 (diff)
ARM: pgtable: collect up identity mapping functions
We have two places where we create identity mappings - one when we bring secondary CPUs online, and one where we setup some mappings for soft- reboot. Combine these two into a single implementation. Also collect the identity mapping deletion function. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/include/asm/pgtable.h3
-rw-r--r--arch/arm/kernel/smp.c34
-rw-r--r--arch/arm/mm/Makefile4
-rw-r--r--arch/arm/mm/idmap.c51
-rw-r--r--arch/arm/mm/mmu.c35
5 files changed, 56 insertions, 71 deletions
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index e582214b00d..1e31af232a3 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -474,6 +474,9 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
474 474
475#define pgtable_cache_init() do { } while (0) 475#define pgtable_cache_init() do { } while (0)
476 476
477void identity_mapping_add(pgd_t *, unsigned long, unsigned long);
478void identity_mapping_del(pgd_t *, unsigned long, unsigned long);
479
477#endif /* !__ASSEMBLY__ */ 480#endif /* !__ASSEMBLY__ */
478 481
479#endif /* CONFIG_MMU */ 482#endif /* CONFIG_MMU */
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 46313805f43..73cef403352 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -68,40 +68,6 @@ enum ipi_msg_type {
68 IPI_CPU_STOP, 68 IPI_CPU_STOP,
69}; 69};
70 70
71static inline void identity_mapping_add(pgd_t *pgd, unsigned long start,
72 unsigned long end)
73{
74 unsigned long addr, prot;
75 pmd_t *pmd;
76
77 prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE;
78 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale())
79 prot |= PMD_BIT4;
80
81 for (addr = start & PGDIR_MASK; addr < end;) {
82 pmd = pmd_offset(pgd + pgd_index(addr), addr);
83 pmd[0] = __pmd(addr | prot);
84 addr += SECTION_SIZE;
85 pmd[1] = __pmd(addr | prot);
86 addr += SECTION_SIZE;
87 flush_pmd_entry(pmd);
88 }
89}
90
91static inline void identity_mapping_del(pgd_t *pgd, unsigned long start,
92 unsigned long end)
93{
94 unsigned long addr;
95 pmd_t *pmd;
96
97 for (addr = start & PGDIR_MASK; addr < end; addr += PGDIR_SIZE) {
98 pmd = pmd_offset(pgd + pgd_index(addr), addr);
99 pmd[0] = __pmd(0);
100 pmd[1] = __pmd(0);
101 clean_pmd_entry(pmd);
102 }
103}
104
105int __cpuinit __cpu_up(unsigned int cpu) 71int __cpuinit __cpu_up(unsigned int cpu)
106{ 72{
107 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu); 73 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
index d63b6c41375..00d74a04af3 100644
--- a/arch/arm/mm/Makefile
+++ b/arch/arm/mm/Makefile
@@ -5,8 +5,8 @@
5obj-y := dma-mapping.o extable.o fault.o init.o \ 5obj-y := dma-mapping.o extable.o fault.o init.o \
6 iomap.o 6 iomap.o
7 7
8obj-$(CONFIG_MMU) += fault-armv.o flush.o ioremap.o mmap.o \ 8obj-$(CONFIG_MMU) += fault-armv.o flush.o idmap.o ioremap.o \
9 pgd.o mmu.o vmregion.o 9 mmap.o pgd.o mmu.o vmregion.o
10 10
11ifneq ($(CONFIG_MMU),y) 11ifneq ($(CONFIG_MMU),y)
12obj-y += nommu.o 12obj-y += nommu.o
diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c
new file mode 100644
index 00000000000..034124d1272
--- /dev/null
+++ b/arch/arm/mm/idmap.c
@@ -0,0 +1,51 @@
1#include <linux/kernel.h>
2
3#include <asm/cputype.h>
4#include <asm/pgalloc.h>
5#include <asm/pgtable.h>
6
7void identity_mapping_add(pgd_t *pgd, unsigned long addr, unsigned long end)
8{
9 unsigned long prot;
10
11 prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE;
12 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale())
13 prot |= PMD_BIT4;
14
15 for (addr &= PGDIR_MASK; addr < end;) {
16 pmd_t *pmd = pmd_offset(pgd + pgd_index(addr), addr);
17 pmd[0] = __pmd(addr | prot);
18 addr += SECTION_SIZE;
19 pmd[1] = __pmd(addr | prot);
20 addr += SECTION_SIZE;
21 flush_pmd_entry(pmd);
22 }
23}
24
25#ifdef CONFIG_SMP
26void identity_mapping_del(pgd_t *pgd, unsigned long addr, unsigned long end)
27{
28 for (addr &= PGDIR_MASK; addr < end; addr += PGDIR_SIZE) {
29 pmd_t *pmd = pmd_offset(pgd + pgd_index(addr), addr);
30 pmd[0] = __pmd(0);
31 pmd[1] = __pmd(0);
32 clean_pmd_entry(pmd);
33 }
34}
35#endif
36
37/*
38 * In order to soft-boot, we need to insert a 1:1 mapping in place of
39 * the user-mode pages. This will then ensure that we have predictable
40 * results when turning the mmu off
41 */
42void setup_mm_for_reboot(char mode)
43{
44 /*
45 * We need to access to user-mode page tables here. For kernel threads
46 * we don't have any user-mode mappings so we use the context that we
47 * "borrowed".
48 */
49 identity_mapping_add(current->active_mm->pgd, 0, TASK_SIZE);
50 local_flush_tlb_all();
51}
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 94ee0930d69..bd1a11e62f4 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1045,38 +1045,3 @@ void __init paging_init(struct machine_desc *mdesc)
1045 empty_zero_page = virt_to_page(zero_page); 1045 empty_zero_page = virt_to_page(zero_page);
1046 __flush_dcache_page(NULL, empty_zero_page); 1046 __flush_dcache_page(NULL, empty_zero_page);
1047} 1047}
1048
1049/*
1050 * In order to soft-boot, we need to insert a 1:1 mapping in place of
1051 * the user-mode pages. This will then ensure that we have predictable
1052 * results when turning the mmu off
1053 */
1054void setup_mm_for_reboot(char mode)
1055{
1056 unsigned long base_pmdval;
1057 pgd_t *pgd;
1058 int i;
1059
1060 /*
1061 * We need to access to user-mode page tables here. For kernel threads
1062 * we don't have any user-mode mappings so we use the context that we
1063 * "borrowed".
1064 */
1065 pgd = current->active_mm->pgd;
1066
1067 base_pmdval = PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT;
1068 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale())
1069 base_pmdval |= PMD_BIT4;
1070
1071 for (i = 0; i < FIRST_USER_PGD_NR + USER_PTRS_PER_PGD; i++, pgd++) {
1072 unsigned long pmdval = (i << PGDIR_SHIFT) | base_pmdval;
1073 pmd_t *pmd;
1074
1075 pmd = pmd_off(pgd, i << PGDIR_SHIFT);
1076 pmd[0] = __pmd(pmdval);
1077 pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1)));
1078 flush_pmd_entry(pmd);
1079 }
1080
1081 local_flush_tlb_all();
1082}