aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2013-06-29 06:44:43 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2013-06-29 06:44:43 -0400
commit3c0c01ab742ddfaf6b6f2d64b890e77cda4b7727 (patch)
treed0f196c53d209f44190fd8a6481823b7770866e6 /arch/arm/include
parentcbd379b10019617457bda31eb243890f4377fa3e (diff)
parent809e660f438fc5a69bf57630a85bcd8112263f37 (diff)
Merge branch 'devel-stable' into for-next
Conflicts: arch/arm/Makefile arch/arm/include/asm/glue-proc.h
Diffstat (limited to 'arch/arm/include')
-rw-r--r--arch/arm/include/asm/arch_timer.h9
-rw-r--r--arch/arm/include/asm/assembler.h17
-rw-r--r--arch/arm/include/asm/cp15.h5
-rw-r--r--arch/arm/include/asm/cputype.h45
-rw-r--r--arch/arm/include/asm/glue-cache.h27
-rw-r--r--arch/arm/include/asm/glue-df.h8
-rw-r--r--arch/arm/include/asm/glue-proc.h9
-rw-r--r--arch/arm/include/asm/hugetlb-3level.h71
-rw-r--r--arch/arm/include/asm/hugetlb.h84
-rw-r--r--arch/arm/include/asm/irqflags.h22
-rw-r--r--arch/arm/include/asm/mach/arch.h5
-rw-r--r--arch/arm/include/asm/memory.h18
-rw-r--r--arch/arm/include/asm/mpu.h76
-rw-r--r--arch/arm/include/asm/page.h2
-rw-r--r--arch/arm/include/asm/pgtable-3level-hwdef.h24
-rw-r--r--arch/arm/include/asm/pgtable-3level.h96
-rw-r--r--arch/arm/include/asm/pgtable.h3
-rw-r--r--arch/arm/include/asm/proc-fns.h30
-rw-r--r--arch/arm/include/asm/psci.h9
-rw-r--r--arch/arm/include/asm/ptrace.h4
-rw-r--r--arch/arm/include/asm/smp.h5
-rw-r--r--arch/arm/include/asm/smp_plat.h22
-rw-r--r--arch/arm/include/asm/suspend.h5
-rw-r--r--arch/arm/include/asm/system_info.h1
-rw-r--r--arch/arm/include/asm/tlb.h6
-rw-r--r--arch/arm/include/asm/tlbflush.h27
-rw-r--r--arch/arm/include/asm/v7m.h44
-rw-r--r--arch/arm/include/debug/vexpress.S10
-rw-r--r--arch/arm/include/uapi/asm/hwcap.h2
-rw-r--r--arch/arm/include/uapi/asm/ptrace.h35
30 files changed, 679 insertions, 42 deletions
diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index 7c1bfc0aea0c..accefe099182 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -80,15 +80,6 @@ static inline u32 arch_timer_get_cntfrq(void)
80 return val; 80 return val;
81} 81}
82 82
83static inline u64 arch_counter_get_cntpct(void)
84{
85 u64 cval;
86
87 isb();
88 asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (cval));
89 return cval;
90}
91
92static inline u64 arch_counter_get_cntvct(void) 83static inline u64 arch_counter_get_cntvct(void)
93{ 84{
94 u64 cval; 85 u64 cval;
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 05ee9eebad6b..a5fef710af32 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -136,7 +136,11 @@
136 * assumes FIQs are enabled, and that the processor is in SVC mode. 136 * assumes FIQs are enabled, and that the processor is in SVC mode.
137 */ 137 */
138 .macro save_and_disable_irqs, oldcpsr 138 .macro save_and_disable_irqs, oldcpsr
139#ifdef CONFIG_CPU_V7M
140 mrs \oldcpsr, primask
141#else
139 mrs \oldcpsr, cpsr 142 mrs \oldcpsr, cpsr
143#endif
140 disable_irq 144 disable_irq
141 .endm 145 .endm
142 146
@@ -150,7 +154,11 @@
150 * guarantee that this will preserve the flags. 154 * guarantee that this will preserve the flags.
151 */ 155 */
152 .macro restore_irqs_notrace, oldcpsr 156 .macro restore_irqs_notrace, oldcpsr
157#ifdef CONFIG_CPU_V7M
158 msr primask, \oldcpsr
159#else
153 msr cpsr_c, \oldcpsr 160 msr cpsr_c, \oldcpsr
161#endif
154 .endm 162 .endm
155 163
156 .macro restore_irqs, oldcpsr 164 .macro restore_irqs, oldcpsr
@@ -229,7 +237,14 @@
229#endif 237#endif
230 .endm 238 .endm
231 239
232#ifdef CONFIG_THUMB2_KERNEL 240#if defined(CONFIG_CPU_V7M)
241 /*
242 * setmode is used to assert to be in svc mode during boot. For v7-M
243 * this is done in __v7m_setup, so setmode can be empty here.
244 */
245 .macro setmode, mode, reg
246 .endm
247#elif defined(CONFIG_THUMB2_KERNEL)
233 .macro setmode, mode, reg 248 .macro setmode, mode, reg
234 mov \reg, #\mode 249 mov \reg, #\mode
235 msr cpsr_c, \reg 250 msr cpsr_c, \reg
diff --git a/arch/arm/include/asm/cp15.h b/arch/arm/include/asm/cp15.h
index 1f3262e99d81..a524a23d8627 100644
--- a/arch/arm/include/asm/cp15.h
+++ b/arch/arm/include/asm/cp15.h
@@ -23,6 +23,11 @@
23#define CR_RR (1 << 14) /* Round Robin cache replacement */ 23#define CR_RR (1 << 14) /* Round Robin cache replacement */
24#define CR_L4 (1 << 15) /* LDR pc can set T bit */ 24#define CR_L4 (1 << 15) /* LDR pc can set T bit */
25#define CR_DT (1 << 16) 25#define CR_DT (1 << 16)
26#ifdef CONFIG_MMU
27#define CR_HA (1 << 17) /* Hardware management of Access Flag */
28#else
29#define CR_BR (1 << 17) /* MPU Background region enable (PMSA) */
30#endif
26#define CR_IT (1 << 18) 31#define CR_IT (1 << 18)
27#define CR_ST (1 << 19) 32#define CR_ST (1 << 19)
28#define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */ 33#define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index dba62cb1ad08..8c25dc4e9851 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -8,8 +8,25 @@
8#define CPUID_CACHETYPE 1 8#define CPUID_CACHETYPE 1
9#define CPUID_TCM 2 9#define CPUID_TCM 2
10#define CPUID_TLBTYPE 3 10#define CPUID_TLBTYPE 3
11#define CPUID_MPUIR 4
11#define CPUID_MPIDR 5 12#define CPUID_MPIDR 5
12 13
14#ifdef CONFIG_CPU_V7M
15#define CPUID_EXT_PFR0 0x40
16#define CPUID_EXT_PFR1 0x44
17#define CPUID_EXT_DFR0 0x48
18#define CPUID_EXT_AFR0 0x4c
19#define CPUID_EXT_MMFR0 0x50
20#define CPUID_EXT_MMFR1 0x54
21#define CPUID_EXT_MMFR2 0x58
22#define CPUID_EXT_MMFR3 0x5c
23#define CPUID_EXT_ISAR0 0x60
24#define CPUID_EXT_ISAR1 0x64
25#define CPUID_EXT_ISAR2 0x68
26#define CPUID_EXT_ISAR3 0x6c
27#define CPUID_EXT_ISAR4 0x70
28#define CPUID_EXT_ISAR5 0x74
29#else
13#define CPUID_EXT_PFR0 "c1, 0" 30#define CPUID_EXT_PFR0 "c1, 0"
14#define CPUID_EXT_PFR1 "c1, 1" 31#define CPUID_EXT_PFR1 "c1, 1"
15#define CPUID_EXT_DFR0 "c1, 2" 32#define CPUID_EXT_DFR0 "c1, 2"
@@ -24,6 +41,7 @@
24#define CPUID_EXT_ISAR3 "c2, 3" 41#define CPUID_EXT_ISAR3 "c2, 3"
25#define CPUID_EXT_ISAR4 "c2, 4" 42#define CPUID_EXT_ISAR4 "c2, 4"
26#define CPUID_EXT_ISAR5 "c2, 5" 43#define CPUID_EXT_ISAR5 "c2, 5"
44#endif
27 45
28#define MPIDR_SMP_BITMASK (0x3 << 30) 46#define MPIDR_SMP_BITMASK (0x3 << 30)
29#define MPIDR_SMP_VALUE (0x2 << 30) 47#define MPIDR_SMP_VALUE (0x2 << 30)
@@ -81,7 +99,23 @@ extern unsigned int processor_id;
81 __val; \ 99 __val; \
82 }) 100 })
83 101
84#else /* ifdef CONFIG_CPU_CP15 */ 102#elif defined(CONFIG_CPU_V7M)
103
104#include <asm/io.h>
105#include <asm/v7m.h>
106
107#define read_cpuid(reg) \
108 ({ \
109 WARN_ON_ONCE(1); \
110 0; \
111 })
112
113static inline unsigned int __attribute_const__ read_cpuid_ext(unsigned offset)
114{
115 return readl(BASEADDR_V7M_SCB + offset);
116}
117
118#else /* ifdef CONFIG_CPU_CP15 / elif defined (CONFIG_CPU_V7M) */
85 119
86/* 120/*
87 * read_cpuid and read_cpuid_ext should only ever be called on machines that 121 * read_cpuid and read_cpuid_ext should only ever be called on machines that
@@ -108,7 +142,14 @@ static inline unsigned int __attribute_const__ read_cpuid_id(void)
108 return read_cpuid(CPUID_ID); 142 return read_cpuid(CPUID_ID);
109} 143}
110 144
111#else /* ifdef CONFIG_CPU_CP15 */ 145#elif defined(CONFIG_CPU_V7M)
146
147static inline unsigned int __attribute_const__ read_cpuid_id(void)
148{
149 return readl(BASEADDR_V7M_SCB + V7M_SCB_CPUID);
150}
151
152#else /* ifdef CONFIG_CPU_CP15 / elif defined(CONFIG_CPU_V7M) */
112 153
113static inline unsigned int __attribute_const__ read_cpuid_id(void) 154static inline unsigned int __attribute_const__ read_cpuid_id(void)
114{ 155{
diff --git a/arch/arm/include/asm/glue-cache.h b/arch/arm/include/asm/glue-cache.h
index ea289e1435e7..c81adc08b3fb 100644
--- a/arch/arm/include/asm/glue-cache.h
+++ b/arch/arm/include/asm/glue-cache.h
@@ -117,10 +117,37 @@
117# endif 117# endif
118#endif 118#endif
119 119
120#if defined(CONFIG_CPU_V7M)
121# ifdef _CACHE
122# define MULTI_CACHE 1
123# else
124# define _CACHE nop
125# endif
126#endif
127
120#if !defined(_CACHE) && !defined(MULTI_CACHE) 128#if !defined(_CACHE) && !defined(MULTI_CACHE)
121#error Unknown cache maintenance model 129#error Unknown cache maintenance model
122#endif 130#endif
123 131
132#ifndef __ASSEMBLER__
133extern inline void nop_flush_icache_all(void) { }
134extern inline void nop_flush_kern_cache_all(void) { }
135extern inline void nop_flush_kern_cache_louis(void) { }
136extern inline void nop_flush_user_cache_all(void) { }
137extern inline void nop_flush_user_cache_range(unsigned long a,
138 unsigned long b, unsigned int c) { }
139
140extern inline void nop_coherent_kern_range(unsigned long a, unsigned long b) { }
141extern inline int nop_coherent_user_range(unsigned long a,
142 unsigned long b) { return 0; }
143extern inline void nop_flush_kern_dcache_area(void *a, size_t s) { }
144
145extern inline void nop_dma_flush_range(const void *a, const void *b) { }
146
147extern inline void nop_dma_map_area(const void *s, size_t l, int f) { }
148extern inline void nop_dma_unmap_area(const void *s, size_t l, int f) { }
149#endif
150
124#ifndef MULTI_CACHE 151#ifndef MULTI_CACHE
125#define __cpuc_flush_icache_all __glue(_CACHE,_flush_icache_all) 152#define __cpuc_flush_icache_all __glue(_CACHE,_flush_icache_all)
126#define __cpuc_flush_kern_all __glue(_CACHE,_flush_kern_cache_all) 153#define __cpuc_flush_kern_all __glue(_CACHE,_flush_kern_cache_all)
diff --git a/arch/arm/include/asm/glue-df.h b/arch/arm/include/asm/glue-df.h
index b6e9f2c108b5..6b70f1b46a6e 100644
--- a/arch/arm/include/asm/glue-df.h
+++ b/arch/arm/include/asm/glue-df.h
@@ -95,6 +95,14 @@
95# endif 95# endif
96#endif 96#endif
97 97
98#ifdef CONFIG_CPU_ABRT_NOMMU
99# ifdef CPU_DABORT_HANDLER
100# define MULTI_DABORT 1
101# else
102# define CPU_DABORT_HANDLER nommu_early_abort
103# endif
104#endif
105
98#ifndef CPU_DABORT_HANDLER 106#ifndef CPU_DABORT_HANDLER
99#error Unknown data abort handler type 107#error Unknown data abort handler type
100#endif 108#endif
diff --git a/arch/arm/include/asm/glue-proc.h b/arch/arm/include/asm/glue-proc.h
index 8017e94acc5e..74a8b84f3cb1 100644
--- a/arch/arm/include/asm/glue-proc.h
+++ b/arch/arm/include/asm/glue-proc.h
@@ -230,6 +230,15 @@
230# endif 230# endif
231#endif 231#endif
232 232
233#ifdef CONFIG_CPU_V7M
234# ifdef CPU_NAME
235# undef MULTI_CPU
236# define MULTI_CPU
237# else
238# define CPU_NAME cpu_v7m
239# endif
240#endif
241
233#ifdef CONFIG_CPU_PJ4B 242#ifdef CONFIG_CPU_PJ4B
234# ifdef CPU_NAME 243# ifdef CPU_NAME
235# undef MULTI_CPU 244# undef MULTI_CPU
diff --git a/arch/arm/include/asm/hugetlb-3level.h b/arch/arm/include/asm/hugetlb-3level.h
new file mode 100644
index 000000000000..d4014fbe5ea3
--- /dev/null
+++ b/arch/arm/include/asm/hugetlb-3level.h
@@ -0,0 +1,71 @@
1/*
2 * arch/arm/include/asm/hugetlb-3level.h
3 *
4 * Copyright (C) 2012 ARM Ltd.
5 *
6 * Based on arch/x86/include/asm/hugetlb.h.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef _ASM_ARM_HUGETLB_3LEVEL_H
23#define _ASM_ARM_HUGETLB_3LEVEL_H
24
25
26/*
27 * If our huge pte is non-zero then mark the valid bit.
28 * This allows pte_present(huge_ptep_get(ptep)) to return true for non-zero
29 * ptes.
30 * (The valid bit is automatically cleared by set_pte_at for PROT_NONE ptes).
31 */
32static inline pte_t huge_ptep_get(pte_t *ptep)
33{
34 pte_t retval = *ptep;
35 if (pte_val(retval))
36 pte_val(retval) |= L_PTE_VALID;
37 return retval;
38}
39
40static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
41 pte_t *ptep, pte_t pte)
42{
43 set_pte_at(mm, addr, ptep, pte);
44}
45
46static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
47 unsigned long addr, pte_t *ptep)
48{
49 ptep_clear_flush(vma, addr, ptep);
50}
51
52static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
53 unsigned long addr, pte_t *ptep)
54{
55 ptep_set_wrprotect(mm, addr, ptep);
56}
57
58static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
59 unsigned long addr, pte_t *ptep)
60{
61 return ptep_get_and_clear(mm, addr, ptep);
62}
63
64static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
65 unsigned long addr, pte_t *ptep,
66 pte_t pte, int dirty)
67{
68 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
69}
70
71#endif /* _ASM_ARM_HUGETLB_3LEVEL_H */
diff --git a/arch/arm/include/asm/hugetlb.h b/arch/arm/include/asm/hugetlb.h
new file mode 100644
index 000000000000..1f1b1cd112f3
--- /dev/null
+++ b/arch/arm/include/asm/hugetlb.h
@@ -0,0 +1,84 @@
1/*
2 * arch/arm/include/asm/hugetlb.h
3 *
4 * Copyright (C) 2012 ARM Ltd.
5 *
6 * Based on arch/x86/include/asm/hugetlb.h
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef _ASM_ARM_HUGETLB_H
23#define _ASM_ARM_HUGETLB_H
24
25#include <asm/page.h>
26#include <asm-generic/hugetlb.h>
27
28#include <asm/hugetlb-3level.h>
29
30static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
31 unsigned long addr, unsigned long end,
32 unsigned long floor,
33 unsigned long ceiling)
34{
35 free_pgd_range(tlb, addr, end, floor, ceiling);
36}
37
38
39static inline int is_hugepage_only_range(struct mm_struct *mm,
40 unsigned long addr, unsigned long len)
41{
42 return 0;
43}
44
45static inline int prepare_hugepage_range(struct file *file,
46 unsigned long addr, unsigned long len)
47{
48 struct hstate *h = hstate_file(file);
49 if (len & ~huge_page_mask(h))
50 return -EINVAL;
51 if (addr & ~huge_page_mask(h))
52 return -EINVAL;
53 return 0;
54}
55
56static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
57{
58}
59
60static inline int huge_pte_none(pte_t pte)
61{
62 return pte_none(pte);
63}
64
65static inline pte_t huge_pte_wrprotect(pte_t pte)
66{
67 return pte_wrprotect(pte);
68}
69
70static inline int arch_prepare_hugepage(struct page *page)
71{
72 return 0;
73}
74
75static inline void arch_release_hugepage(struct page *page)
76{
77}
78
79static inline void arch_clear_hugepage_flags(struct page *page)
80{
81 clear_bit(PG_dcache_clean, &page->flags);
82}
83
84#endif /* _ASM_ARM_HUGETLB_H */
diff --git a/arch/arm/include/asm/irqflags.h b/arch/arm/include/asm/irqflags.h
index 1e6cca55c750..3b763d6652a0 100644
--- a/arch/arm/include/asm/irqflags.h
+++ b/arch/arm/include/asm/irqflags.h
@@ -8,6 +8,16 @@
8/* 8/*
9 * CPU interrupt mask handling. 9 * CPU interrupt mask handling.
10 */ 10 */
11#ifdef CONFIG_CPU_V7M
12#define IRQMASK_REG_NAME_R "primask"
13#define IRQMASK_REG_NAME_W "primask"
14#define IRQMASK_I_BIT 1
15#else
16#define IRQMASK_REG_NAME_R "cpsr"
17#define IRQMASK_REG_NAME_W "cpsr_c"
18#define IRQMASK_I_BIT PSR_I_BIT
19#endif
20
11#if __LINUX_ARM_ARCH__ >= 6 21#if __LINUX_ARM_ARCH__ >= 6
12 22
13static inline unsigned long arch_local_irq_save(void) 23static inline unsigned long arch_local_irq_save(void)
@@ -15,7 +25,7 @@ static inline unsigned long arch_local_irq_save(void)
15 unsigned long flags; 25 unsigned long flags;
16 26
17 asm volatile( 27 asm volatile(
18 " mrs %0, cpsr @ arch_local_irq_save\n" 28 " mrs %0, " IRQMASK_REG_NAME_R " @ arch_local_irq_save\n"
19 " cpsid i" 29 " cpsid i"
20 : "=r" (flags) : : "memory", "cc"); 30 : "=r" (flags) : : "memory", "cc");
21 return flags; 31 return flags;
@@ -129,7 +139,7 @@ static inline unsigned long arch_local_save_flags(void)
129{ 139{
130 unsigned long flags; 140 unsigned long flags;
131 asm volatile( 141 asm volatile(
132 " mrs %0, cpsr @ local_save_flags" 142 " mrs %0, " IRQMASK_REG_NAME_R " @ local_save_flags"
133 : "=r" (flags) : : "memory", "cc"); 143 : "=r" (flags) : : "memory", "cc");
134 return flags; 144 return flags;
135} 145}
@@ -140,7 +150,7 @@ static inline unsigned long arch_local_save_flags(void)
140static inline void arch_local_irq_restore(unsigned long flags) 150static inline void arch_local_irq_restore(unsigned long flags)
141{ 151{
142 asm volatile( 152 asm volatile(
143 " msr cpsr_c, %0 @ local_irq_restore" 153 " msr " IRQMASK_REG_NAME_W ", %0 @ local_irq_restore"
144 : 154 :
145 : "r" (flags) 155 : "r" (flags)
146 : "memory", "cc"); 156 : "memory", "cc");
@@ -148,8 +158,8 @@ static inline void arch_local_irq_restore(unsigned long flags)
148 158
149static inline int arch_irqs_disabled_flags(unsigned long flags) 159static inline int arch_irqs_disabled_flags(unsigned long flags)
150{ 160{
151 return flags & PSR_I_BIT; 161 return flags & IRQMASK_I_BIT;
152} 162}
153 163
154#endif 164#endif /* ifdef __KERNEL__ */
155#endif 165#endif /* ifndef __ASM_ARM_IRQFLAGS_H */
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index 308ad7d6f98b..75bf07910b81 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -8,6 +8,8 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11#include <linux/types.h>
12
11#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
12 14
13struct tag; 15struct tag;
@@ -16,8 +18,10 @@ struct pt_regs;
16struct smp_operations; 18struct smp_operations;
17#ifdef CONFIG_SMP 19#ifdef CONFIG_SMP
18#define smp_ops(ops) (&(ops)) 20#define smp_ops(ops) (&(ops))
21#define smp_init_ops(ops) (&(ops))
19#else 22#else
20#define smp_ops(ops) (struct smp_operations *)NULL 23#define smp_ops(ops) (struct smp_operations *)NULL
24#define smp_init_ops(ops) (bool (*)(void))NULL
21#endif 25#endif
22 26
23struct machine_desc { 27struct machine_desc {
@@ -41,6 +45,7 @@ struct machine_desc {
41 unsigned char reserve_lp2 :1; /* never has lp2 */ 45 unsigned char reserve_lp2 :1; /* never has lp2 */
42 char restart_mode; /* default restart mode */ 46 char restart_mode; /* default restart mode */
43 struct smp_operations *smp; /* SMP operations */ 47 struct smp_operations *smp; /* SMP operations */
48 bool (*smp_init)(void);
44 void (*fixup)(struct tag *, char **, 49 void (*fixup)(struct tag *, char **,
45 struct meminfo *); 50 struct meminfo *);
46 void (*reserve)(void);/* reserve mem blocks */ 51 void (*reserve)(void);/* reserve mem blocks */
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 57870ab313c5..584786f740f9 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -18,6 +18,8 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/sizes.h> 19#include <linux/sizes.h>
20 20
21#include <asm/cache.h>
22
21#ifdef CONFIG_NEED_MACH_MEMORY_H 23#ifdef CONFIG_NEED_MACH_MEMORY_H
22#include <mach/memory.h> 24#include <mach/memory.h>
23#endif 25#endif
@@ -141,6 +143,20 @@
141#define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) 143#define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
142#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys))) 144#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
143 145
146/*
147 * Minimum guaranted alignment in pgd_alloc(). The page table pointers passed
148 * around in head.S and proc-*.S are shifted by this amount, in order to
149 * leave spare high bits for systems with physical address extension. This
150 * does not fully accomodate the 40-bit addressing capability of ARM LPAE, but
151 * gives us about 38-bits or so.
152 */
153#ifdef CONFIG_ARM_LPAE
154#define ARCH_PGD_SHIFT L1_CACHE_SHIFT
155#else
156#define ARCH_PGD_SHIFT 0
157#endif
158#define ARCH_PGD_MASK ((1 << ARCH_PGD_SHIFT) - 1)
159
144#ifndef __ASSEMBLY__ 160#ifndef __ASSEMBLY__
145 161
146/* 162/*
@@ -207,7 +223,7 @@ static inline unsigned long __phys_to_virt(unsigned long x)
207 * direct-mapped view. We assume this is the first page 223 * direct-mapped view. We assume this is the first page
208 * of RAM in the mem_map as well. 224 * of RAM in the mem_map as well.
209 */ 225 */
210#define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) 226#define PHYS_PFN_OFFSET ((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT))
211 227
212/* 228/*
213 * These are *only* valid on the kernel direct mapped RAM memory. 229 * These are *only* valid on the kernel direct mapped RAM memory.
diff --git a/arch/arm/include/asm/mpu.h b/arch/arm/include/asm/mpu.h
new file mode 100644
index 000000000000..c3247cc2fe08
--- /dev/null
+++ b/arch/arm/include/asm/mpu.h
@@ -0,0 +1,76 @@
1#ifndef __ARM_MPU_H
2#define __ARM_MPU_H
3
4#ifdef CONFIG_ARM_MPU
5
6/* MPUIR layout */
7#define MPUIR_nU 1
8#define MPUIR_DREGION 8
9#define MPUIR_IREGION 16
10#define MPUIR_DREGION_SZMASK (0xFF << MPUIR_DREGION)
11#define MPUIR_IREGION_SZMASK (0xFF << MPUIR_IREGION)
12
13/* ID_MMFR0 data relevant to MPU */
14#define MMFR0_PMSA (0xF << 4)
15#define MMFR0_PMSAv7 (3 << 4)
16
17/* MPU D/I Size Register fields */
18#define MPU_RSR_SZ 1
19#define MPU_RSR_EN 0
20
21/* The D/I RSR value for an enabled region spanning the whole of memory */
22#define MPU_RSR_ALL_MEM 63
23
24/* Individual bits in the DR/IR ACR */
25#define MPU_ACR_XN (1 << 12)
26#define MPU_ACR_SHARED (1 << 2)
27
28/* C, B and TEX[2:0] bits only have semantic meanings when grouped */
29#define MPU_RGN_CACHEABLE 0xB
30#define MPU_RGN_SHARED_CACHEABLE (MPU_RGN_CACHEABLE | MPU_ACR_SHARED)
31#define MPU_RGN_STRONGLY_ORDERED 0
32
33/* Main region should only be shared for SMP */
34#ifdef CONFIG_SMP
35#define MPU_RGN_NORMAL (MPU_RGN_CACHEABLE | MPU_ACR_SHARED)
36#else
37#define MPU_RGN_NORMAL MPU_RGN_CACHEABLE
38#endif
39
40/* Access permission bits of ACR (only define those that we use)*/
41#define MPU_AP_PL1RW_PL0RW (0x3 << 8)
42#define MPU_AP_PL1RW_PL0R0 (0x2 << 8)
43#define MPU_AP_PL1RW_PL0NA (0x1 << 8)
44
45/* For minimal static MPU region configurations */
46#define MPU_PROBE_REGION 0
47#define MPU_BG_REGION 1
48#define MPU_RAM_REGION 2
49#define MPU_VECTORS_REGION 3
50
51/* Maximum number of regions Linux is interested in */
52#define MPU_MAX_REGIONS 16
53
54#define MPU_DATA_SIDE 0
55#define MPU_INSTR_SIDE 1
56
57#ifndef __ASSEMBLY__
58
59struct mpu_rgn {
60 /* Assume same attributes for d/i-side */
61 u32 drbar;
62 u32 drsr;
63 u32 dracr;
64};
65
66struct mpu_rgn_info {
67 u32 mpuir;
68 struct mpu_rgn rgns[MPU_MAX_REGIONS];
69};
70extern struct mpu_rgn_info mpu_rgn_info;
71
72#endif /* __ASSEMBLY__ */
73
74#endif /* CONFIG_ARM_MPU */
75
76#endif
diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index 812a4944e783..6363f3d1d505 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -13,7 +13,7 @@
13/* PAGE_SHIFT determines the page size */ 13/* PAGE_SHIFT determines the page size */
14#define PAGE_SHIFT 12 14#define PAGE_SHIFT 12
15#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) 15#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
16#define PAGE_MASK (~(PAGE_SIZE-1)) 16#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
17 17
18#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
19 19
diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
index 18f5cef82ad5..626989fec4d3 100644
--- a/arch/arm/include/asm/pgtable-3level-hwdef.h
+++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
@@ -30,6 +30,7 @@
30#define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0) 30#define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
31#define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0) 31#define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0)
32#define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0) 32#define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
33#define PMD_TABLE_BIT (_AT(pmdval_t, 1) << 1)
33#define PMD_BIT4 (_AT(pmdval_t, 0)) 34#define PMD_BIT4 (_AT(pmdval_t, 0))
34#define PMD_DOMAIN(x) (_AT(pmdval_t, 0)) 35#define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
35#define PMD_APTABLE_SHIFT (61) 36#define PMD_APTABLE_SHIFT (61)
@@ -41,6 +42,8 @@
41 */ 42 */
42#define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2) 43#define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
43#define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3) 44#define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
45#define PMD_SECT_USER (_AT(pmdval_t, 1) << 6) /* AP[1] */
46#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7) /* AP[2] */
44#define PMD_SECT_S (_AT(pmdval_t, 3) << 8) 47#define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
45#define PMD_SECT_AF (_AT(pmdval_t, 1) << 10) 48#define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
46#define PMD_SECT_nG (_AT(pmdval_t, 1) << 11) 49#define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
@@ -66,6 +69,7 @@
66#define PTE_TYPE_MASK (_AT(pteval_t, 3) << 0) 69#define PTE_TYPE_MASK (_AT(pteval_t, 3) << 0)
67#define PTE_TYPE_FAULT (_AT(pteval_t, 0) << 0) 70#define PTE_TYPE_FAULT (_AT(pteval_t, 0) << 0)
68#define PTE_TYPE_PAGE (_AT(pteval_t, 3) << 0) 71#define PTE_TYPE_PAGE (_AT(pteval_t, 3) << 0)
72#define PTE_TABLE_BIT (_AT(pteval_t, 1) << 1)
69#define PTE_BUFFERABLE (_AT(pteval_t, 1) << 2) /* AttrIndx[0] */ 73#define PTE_BUFFERABLE (_AT(pteval_t, 1) << 2) /* AttrIndx[0] */
70#define PTE_CACHEABLE (_AT(pteval_t, 1) << 3) /* AttrIndx[1] */ 74#define PTE_CACHEABLE (_AT(pteval_t, 1) << 3) /* AttrIndx[1] */
71#define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */ 75#define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
@@ -79,4 +83,24 @@
79#define PHYS_MASK_SHIFT (40) 83#define PHYS_MASK_SHIFT (40)
80#define PHYS_MASK ((1ULL << PHYS_MASK_SHIFT) - 1) 84#define PHYS_MASK ((1ULL << PHYS_MASK_SHIFT) - 1)
81 85
86/*
87 * TTBR0/TTBR1 split (PAGE_OFFSET):
88 * 0x40000000: T0SZ = 2, T1SZ = 0 (not used)
89 * 0x80000000: T0SZ = 0, T1SZ = 1
90 * 0xc0000000: T0SZ = 0, T1SZ = 2
91 *
92 * Only use this feature if PHYS_OFFSET <= PAGE_OFFSET, otherwise
93 * booting secondary CPUs would end up using TTBR1 for the identity
94 * mapping set up in TTBR0.
95 */
96#if defined CONFIG_VMSPLIT_2G
97#define TTBR1_OFFSET 16 /* skip two L1 entries */
98#elif defined CONFIG_VMSPLIT_3G
99#define TTBR1_OFFSET (4096 * (1 + 3)) /* only L2, skip pgd + 3*pmd */
100#else
101#define TTBR1_OFFSET 0
102#endif
103
104#define TTBR1_SIZE (((PAGE_OFFSET >> 30) - 1) << 16)
105
82#endif 106#endif
diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
index 86b8fe398b95..5689c18c85f5 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -33,7 +33,7 @@
33#define PTRS_PER_PMD 512 33#define PTRS_PER_PMD 512
34#define PTRS_PER_PGD 4 34#define PTRS_PER_PGD 4
35 35
36#define PTE_HWTABLE_PTRS (PTRS_PER_PTE) 36#define PTE_HWTABLE_PTRS (0)
37#define PTE_HWTABLE_OFF (0) 37#define PTE_HWTABLE_OFF (0)
38#define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u64)) 38#define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u64))
39 39
@@ -48,20 +48,28 @@
48#define PMD_SHIFT 21 48#define PMD_SHIFT 21
49 49
50#define PMD_SIZE (1UL << PMD_SHIFT) 50#define PMD_SIZE (1UL << PMD_SHIFT)
51#define PMD_MASK (~(PMD_SIZE-1)) 51#define PMD_MASK (~((1 << PMD_SHIFT) - 1))
52#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 52#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
53#define PGDIR_MASK (~(PGDIR_SIZE-1)) 53#define PGDIR_MASK (~((1 << PGDIR_SHIFT) - 1))
54 54
55/* 55/*
56 * section address mask and size definitions. 56 * section address mask and size definitions.
57 */ 57 */
58#define SECTION_SHIFT 21 58#define SECTION_SHIFT 21
59#define SECTION_SIZE (1UL << SECTION_SHIFT) 59#define SECTION_SIZE (1UL << SECTION_SHIFT)
60#define SECTION_MASK (~(SECTION_SIZE-1)) 60#define SECTION_MASK (~((1 << SECTION_SHIFT) - 1))
61 61
62#define USER_PTRS_PER_PGD (PAGE_OFFSET / PGDIR_SIZE) 62#define USER_PTRS_PER_PGD (PAGE_OFFSET / PGDIR_SIZE)
63 63
64/* 64/*
65 * Hugetlb definitions.
66 */
67#define HPAGE_SHIFT PMD_SHIFT
68#define HPAGE_SIZE (_AC(1, UL) << HPAGE_SHIFT)
69#define HPAGE_MASK (~(HPAGE_SIZE - 1))
70#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
71
72/*
65 * "Linux" PTE definitions for LPAE. 73 * "Linux" PTE definitions for LPAE.
66 * 74 *
67 * These bits overlap with the hardware bits but the naming is preserved for 75 * These bits overlap with the hardware bits but the naming is preserved for
@@ -79,6 +87,11 @@
79#define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */ 87#define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
80#define L_PTE_NONE (_AT(pteval_t, 1) << 57) /* PROT_NONE */ 88#define L_PTE_NONE (_AT(pteval_t, 1) << 57) /* PROT_NONE */
81 89
90#define PMD_SECT_VALID (_AT(pmdval_t, 1) << 0)
91#define PMD_SECT_DIRTY (_AT(pmdval_t, 1) << 55)
92#define PMD_SECT_SPLITTING (_AT(pmdval_t, 1) << 56)
93#define PMD_SECT_NONE (_AT(pmdval_t, 1) << 57)
94
82/* 95/*
83 * To be used in assembly code with the upper page attributes. 96 * To be used in assembly code with the upper page attributes.
84 */ 97 */
@@ -166,8 +179,83 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
166 clean_pmd_entry(pmdp); \ 179 clean_pmd_entry(pmdp); \
167 } while (0) 180 } while (0)
168 181
182/*
183 * For 3 levels of paging the PTE_EXT_NG bit will be set for user address ptes
184 * that are written to a page table but not for ptes created with mk_pte.
185 *
186 * In hugetlb_no_page, a new huge pte (new_pte) is generated and passed to
187 * hugetlb_cow, where it is compared with an entry in a page table.
188 * This comparison test fails erroneously leading ultimately to a memory leak.
189 *
190 * To correct this behaviour, we mask off PTE_EXT_NG for any pte that is
191 * present before running the comparison.
192 */
193#define __HAVE_ARCH_PTE_SAME
194#define pte_same(pte_a,pte_b) ((pte_present(pte_a) ? pte_val(pte_a) & ~PTE_EXT_NG \
195 : pte_val(pte_a)) \
196 == (pte_present(pte_b) ? pte_val(pte_b) & ~PTE_EXT_NG \
197 : pte_val(pte_b)))
198
169#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,__pte(pte_val(pte)|(ext))) 199#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,__pte(pte_val(pte)|(ext)))
170 200
201#define pte_huge(pte) (pte_val(pte) && !(pte_val(pte) & PTE_TABLE_BIT))
202#define pte_mkhuge(pte) (__pte(pte_val(pte) & ~PTE_TABLE_BIT))
203
204#define pmd_young(pmd) (pmd_val(pmd) & PMD_SECT_AF)
205
206#define __HAVE_ARCH_PMD_WRITE
207#define pmd_write(pmd) (!(pmd_val(pmd) & PMD_SECT_RDONLY))
208
209#ifdef CONFIG_TRANSPARENT_HUGEPAGE
210#define pmd_trans_huge(pmd) (pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT))
211#define pmd_trans_splitting(pmd) (pmd_val(pmd) & PMD_SECT_SPLITTING)
212#endif
213
214#define PMD_BIT_FUNC(fn,op) \
215static inline pmd_t pmd_##fn(pmd_t pmd) { pmd_val(pmd) op; return pmd; }
216
217PMD_BIT_FUNC(wrprotect, |= PMD_SECT_RDONLY);
218PMD_BIT_FUNC(mkold, &= ~PMD_SECT_AF);
219PMD_BIT_FUNC(mksplitting, |= PMD_SECT_SPLITTING);
220PMD_BIT_FUNC(mkwrite, &= ~PMD_SECT_RDONLY);
221PMD_BIT_FUNC(mkdirty, |= PMD_SECT_DIRTY);
222PMD_BIT_FUNC(mkyoung, |= PMD_SECT_AF);
223
224#define pmd_mkhuge(pmd) (__pmd(pmd_val(pmd) & ~PMD_TABLE_BIT))
225
226#define pmd_pfn(pmd) (((pmd_val(pmd) & PMD_MASK) & PHYS_MASK) >> PAGE_SHIFT)
227#define pfn_pmd(pfn,prot) (__pmd(((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)))
228#define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot)
229
230/* represent a notpresent pmd by zero, this is used by pmdp_invalidate */
231#define pmd_mknotpresent(pmd) (__pmd(0))
232
233static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
234{
235 const pmdval_t mask = PMD_SECT_USER | PMD_SECT_XN | PMD_SECT_RDONLY |
236 PMD_SECT_VALID | PMD_SECT_NONE;
237 pmd_val(pmd) = (pmd_val(pmd) & ~mask) | (pgprot_val(newprot) & mask);
238 return pmd;
239}
240
241static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
242 pmd_t *pmdp, pmd_t pmd)
243{
244 BUG_ON(addr >= TASK_SIZE);
245
246 /* create a faulting entry if PROT_NONE protected */
247 if (pmd_val(pmd) & PMD_SECT_NONE)
248 pmd_val(pmd) &= ~PMD_SECT_VALID;
249
250 *pmdp = __pmd(pmd_val(pmd) | PMD_SECT_nG);
251 flush_pmd_entry(pmdp);
252}
253
254static inline int has_transparent_hugepage(void)
255{
256 return 1;
257}
258
171#endif /* __ASSEMBLY__ */ 259#endif /* __ASSEMBLY__ */
172 260
173#endif /* _ASM_PGTABLE_3LEVEL_H */ 261#endif /* _ASM_PGTABLE_3LEVEL_H */
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index 9bcd262a9008..eaedce7b7e3a 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -24,6 +24,9 @@
24#include <asm/memory.h> 24#include <asm/memory.h>
25#include <asm/pgtable-hwdef.h> 25#include <asm/pgtable-hwdef.h>
26 26
27
28#include <asm/tlbflush.h>
29
27#ifdef CONFIG_ARM_LPAE 30#ifdef CONFIG_ARM_LPAE
28#include <asm/pgtable-3level.h> 31#include <asm/pgtable-3level.h>
29#else 32#else
diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
index f3628fb3d2b3..5324c1112f3a 100644
--- a/arch/arm/include/asm/proc-fns.h
+++ b/arch/arm/include/asm/proc-fns.h
@@ -60,7 +60,7 @@ extern struct processor {
60 /* 60 /*
61 * Set the page table 61 * Set the page table
62 */ 62 */
63 void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *mm); 63 void (*switch_mm)(phys_addr_t pgd_phys, struct mm_struct *mm);
64 /* 64 /*
65 * Set a possibly extended PTE. Non-extended PTEs should 65 * Set a possibly extended PTE. Non-extended PTEs should
66 * ignore 'ext'. 66 * ignore 'ext'.
@@ -82,7 +82,7 @@ extern void cpu_proc_init(void);
82extern void cpu_proc_fin(void); 82extern void cpu_proc_fin(void);
83extern int cpu_do_idle(void); 83extern int cpu_do_idle(void);
84extern void cpu_dcache_clean_area(void *, int); 84extern void cpu_dcache_clean_area(void *, int);
85extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm); 85extern void cpu_do_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm);
86#ifdef CONFIG_ARM_LPAE 86#ifdef CONFIG_ARM_LPAE
87extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte); 87extern void cpu_set_pte_ext(pte_t *ptep, pte_t pte);
88#else 88#else
@@ -116,13 +116,25 @@ extern void cpu_resume(void);
116#define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm) 116#define cpu_switch_mm(pgd,mm) cpu_do_switch_mm(virt_to_phys(pgd),mm)
117 117
118#ifdef CONFIG_ARM_LPAE 118#ifdef CONFIG_ARM_LPAE
119
120#define cpu_get_ttbr(nr) \
121 ({ \
122 u64 ttbr; \
123 __asm__("mrrc p15, " #nr ", %Q0, %R0, c2" \
124 : "=r" (ttbr)); \
125 ttbr; \
126 })
127
128#define cpu_set_ttbr(nr, val) \
129 do { \
130 u64 ttbr = val; \
131 __asm__("mcrr p15, " #nr ", %Q0, %R0, c2" \
132 : : "r" (ttbr)); \
133 } while (0)
134
119#define cpu_get_pgd() \ 135#define cpu_get_pgd() \
120 ({ \ 136 ({ \
121 unsigned long pg, pg2; \ 137 u64 pg = cpu_get_ttbr(0); \
122 __asm__("mrrc p15, 0, %0, %1, c2" \
123 : "=r" (pg), "=r" (pg2) \
124 : \
125 : "cc"); \
126 pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \ 138 pg &= ~(PTRS_PER_PGD*sizeof(pgd_t)-1); \
127 (pgd_t *)phys_to_virt(pg); \ 139 (pgd_t *)phys_to_virt(pg); \
128 }) 140 })
@@ -137,6 +149,10 @@ extern void cpu_resume(void);
137 }) 149 })
138#endif 150#endif
139 151
152#else /*!CONFIG_MMU */
153
154#define cpu_switch_mm(pgd,mm) { }
155
140#endif 156#endif
141 157
142#endif /* __ASSEMBLY__ */ 158#endif /* __ASSEMBLY__ */
diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
index ce0dbe7c1625..c4ae171850f8 100644
--- a/arch/arm/include/asm/psci.h
+++ b/arch/arm/include/asm/psci.h
@@ -32,5 +32,14 @@ struct psci_operations {
32}; 32};
33 33
34extern struct psci_operations psci_ops; 34extern struct psci_operations psci_ops;
35extern struct smp_operations psci_smp_ops;
36
37#ifdef CONFIG_ARM_PSCI
38void psci_init(void);
39bool psci_smp_available(void);
40#else
41static inline void psci_init(void) { }
42static inline bool psci_smp_available(void) { return false; }
43#endif
35 44
36#endif /* __ASM_ARM_PSCI_H */ 45#endif /* __ASM_ARM_PSCI_H */
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index 3d52ee1bfb31..04c99f36ff7f 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -45,6 +45,7 @@ struct pt_regs {
45 */ 45 */
46static inline int valid_user_regs(struct pt_regs *regs) 46static inline int valid_user_regs(struct pt_regs *regs)
47{ 47{
48#ifndef CONFIG_CPU_V7M
48 unsigned long mode = regs->ARM_cpsr & MODE_MASK; 49 unsigned long mode = regs->ARM_cpsr & MODE_MASK;
49 50
50 /* 51 /*
@@ -67,6 +68,9 @@ static inline int valid_user_regs(struct pt_regs *regs)
67 regs->ARM_cpsr |= USR_MODE; 68 regs->ARM_cpsr |= USR_MODE;
68 69
69 return 0; 70 return 0;
71#else /* ifndef CONFIG_CPU_V7M */
72 return 1;
73#endif
70} 74}
71 75
72static inline long regs_return_value(struct pt_regs *regs) 76static inline long regs_return_value(struct pt_regs *regs)
diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index d3a22bebe6ce..a8cae71caceb 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -65,7 +65,10 @@ asmlinkage void secondary_start_kernel(void);
65 * Initial data for bringing up a secondary CPU. 65 * Initial data for bringing up a secondary CPU.
66 */ 66 */
67struct secondary_data { 67struct secondary_data {
68 unsigned long pgdir; 68 union {
69 unsigned long mpu_rgn_szr;
70 unsigned long pgdir;
71 };
69 unsigned long swapper_pg_dir; 72 unsigned long swapper_pg_dir;
70 void *stack; 73 void *stack;
71}; 74};
diff --git a/arch/arm/include/asm/smp_plat.h b/arch/arm/include/asm/smp_plat.h
index e78983202737..6462a721ebd4 100644
--- a/arch/arm/include/asm/smp_plat.h
+++ b/arch/arm/include/asm/smp_plat.h
@@ -26,6 +26,9 @@ static inline bool is_smp(void)
26} 26}
27 27
28/* all SMP configurations have the extended CPUID registers */ 28/* all SMP configurations have the extended CPUID registers */
29#ifndef CONFIG_MMU
30#define tlb_ops_need_broadcast() 0
31#else
29static inline int tlb_ops_need_broadcast(void) 32static inline int tlb_ops_need_broadcast(void)
30{ 33{
31 if (!is_smp()) 34 if (!is_smp())
@@ -33,6 +36,7 @@ static inline int tlb_ops_need_broadcast(void)
33 36
34 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2; 37 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
35} 38}
39#endif
36 40
37#if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7 41#if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
38#define cache_ops_need_broadcast() 0 42#define cache_ops_need_broadcast() 0
@@ -66,4 +70,22 @@ static inline int get_logical_index(u32 mpidr)
66 return -EINVAL; 70 return -EINVAL;
67} 71}
68 72
73/*
74 * NOTE ! Assembly code relies on the following
75 * structure memory layout in order to carry out load
76 * multiple from its base address. For more
77 * information check arch/arm/kernel/sleep.S
78 */
79struct mpidr_hash {
80 u32 mask; /* used by sleep.S */
81 u32 shift_aff[3]; /* used by sleep.S */
82 u32 bits;
83};
84
85extern struct mpidr_hash mpidr_hash;
86
87static inline u32 mpidr_hash_size(void)
88{
89 return 1 << mpidr_hash.bits;
90}
69#endif 91#endif
diff --git a/arch/arm/include/asm/suspend.h b/arch/arm/include/asm/suspend.h
index 1c0a551ae375..cd20029bcd94 100644
--- a/arch/arm/include/asm/suspend.h
+++ b/arch/arm/include/asm/suspend.h
@@ -1,6 +1,11 @@
1#ifndef __ASM_ARM_SUSPEND_H 1#ifndef __ASM_ARM_SUSPEND_H
2#define __ASM_ARM_SUSPEND_H 2#define __ASM_ARM_SUSPEND_H
3 3
4struct sleep_save_sp {
5 u32 *save_ptr_stash;
6 u32 save_ptr_stash_phys;
7};
8
4extern void cpu_resume(void); 9extern void cpu_resume(void);
5extern int cpu_suspend(unsigned long, int (*)(unsigned long)); 10extern int cpu_suspend(unsigned long, int (*)(unsigned long));
6 11
diff --git a/arch/arm/include/asm/system_info.h b/arch/arm/include/asm/system_info.h
index dfd386d0c022..720ea0320a6d 100644
--- a/arch/arm/include/asm/system_info.h
+++ b/arch/arm/include/asm/system_info.h
@@ -11,6 +11,7 @@
11#define CPU_ARCH_ARMv5TEJ 7 11#define CPU_ARCH_ARMv5TEJ 7
12#define CPU_ARCH_ARMv6 8 12#define CPU_ARCH_ARMv6 8
13#define CPU_ARCH_ARMv7 9 13#define CPU_ARCH_ARMv7 9
14#define CPU_ARCH_ARMv7M 10
14 15
15#ifndef __ASSEMBLY__ 16#ifndef __ASSEMBLY__
16 17
diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
index bdf2b8458ec1..46e7cfb3e721 100644
--- a/arch/arm/include/asm/tlb.h
+++ b/arch/arm/include/asm/tlb.h
@@ -204,6 +204,12 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
204#endif 204#endif
205} 205}
206 206
207static inline void
208tlb_remove_pmd_tlb_entry(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr)
209{
210 tlb_add_flush(tlb, addr);
211}
212
207#define pte_free_tlb(tlb, ptep, addr) __pte_free_tlb(tlb, ptep, addr) 213#define pte_free_tlb(tlb, ptep, addr) __pte_free_tlb(tlb, ptep, addr)
208#define pmd_free_tlb(tlb, pmdp, addr) __pmd_free_tlb(tlb, pmdp, addr) 214#define pmd_free_tlb(tlb, pmdp, addr) __pmd_free_tlb(tlb, pmdp, addr)
209#define pud_free_tlb(tlb, pudp, addr) pud_free((tlb)->mm, pudp) 215#define pud_free_tlb(tlb, pudp, addr) pud_free((tlb)->mm, pudp)
diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
index a3625d141c1d..fdbb9e369745 100644
--- a/arch/arm/include/asm/tlbflush.h
+++ b/arch/arm/include/asm/tlbflush.h
@@ -535,8 +535,33 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
535} 535}
536#endif 536#endif
537 537
538#define update_mmu_cache_pmd(vma, address, pmd) do { } while (0)
539
538#endif 540#endif
539 541
540#endif /* CONFIG_MMU */ 542#elif defined(CONFIG_SMP) /* !CONFIG_MMU */
543
544#ifndef __ASSEMBLY__
545
546#include <linux/mm_types.h>
547
548static inline void local_flush_tlb_all(void) { }
549static inline void local_flush_tlb_mm(struct mm_struct *mm) { }
550static inline void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr) { }
551static inline void local_flush_tlb_kernel_page(unsigned long kaddr) { }
552static inline void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { }
553static inline void local_flush_tlb_kernel_range(unsigned long start, unsigned long end) { }
554static inline void local_flush_bp_all(void) { }
555
556extern void flush_tlb_all(void);
557extern void flush_tlb_mm(struct mm_struct *mm);
558extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr);
559extern void flush_tlb_kernel_page(unsigned long kaddr);
560extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
561extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
562extern void flush_bp_all(void);
563#endif /* __ASSEMBLY__ */
564
565#endif
541 566
542#endif 567#endif
diff --git a/arch/arm/include/asm/v7m.h b/arch/arm/include/asm/v7m.h
new file mode 100644
index 000000000000..fa88d09fa3d9
--- /dev/null
+++ b/arch/arm/include/asm/v7m.h
@@ -0,0 +1,44 @@
1/*
2 * Common defines for v7m cpus
3 */
4#define V7M_SCS_ICTR IOMEM(0xe000e004)
5#define V7M_SCS_ICTR_INTLINESNUM_MASK 0x0000000f
6
7#define BASEADDR_V7M_SCB IOMEM(0xe000ed00)
8
9#define V7M_SCB_CPUID 0x00
10
11#define V7M_SCB_ICSR 0x04
12#define V7M_SCB_ICSR_PENDSVSET (1 << 28)
13#define V7M_SCB_ICSR_PENDSVCLR (1 << 27)
14#define V7M_SCB_ICSR_RETTOBASE (1 << 11)
15
16#define V7M_SCB_VTOR 0x08
17
18#define V7M_SCB_SCR 0x10
19#define V7M_SCB_SCR_SLEEPDEEP (1 << 2)
20
21#define V7M_SCB_CCR 0x14
22#define V7M_SCB_CCR_STKALIGN (1 << 9)
23
24#define V7M_SCB_SHPR2 0x1c
25#define V7M_SCB_SHPR3 0x20
26
27#define V7M_SCB_SHCSR 0x24
28#define V7M_SCB_SHCSR_USGFAULTENA (1 << 18)
29#define V7M_SCB_SHCSR_BUSFAULTENA (1 << 17)
30#define V7M_SCB_SHCSR_MEMFAULTENA (1 << 16)
31
32#define V7M_xPSR_FRAMEPTRALIGN 0x00000200
33#define V7M_xPSR_EXCEPTIONNO 0x000001ff
34
35/*
36 * When branching to an address that has bits [31:28] == 0xf an exception return
37 * occurs. Bits [27:5] are reserved (SBOP). If the processor implements the FP
38 * extension Bit [4] defines if the exception frame has space allocated for FP
39 * state information, SBOP otherwise. Bit [3] defines the mode that is returned
40 * to (0 -> handler mode; 1 -> thread mode). Bit [2] defines which sp is used
41 * (0 -> msp; 1 -> psp). Bits [1:0] are fixed to 0b01.
42 */
43#define EXC_RET_STACK_MASK 0x00000004
44#define EXC_RET_THREADMODE_PROCESSSTACK 0xfffffffd
diff --git a/arch/arm/include/debug/vexpress.S b/arch/arm/include/debug/vexpress.S
index dc8e882a6257..acafb229e2b6 100644
--- a/arch/arm/include/debug/vexpress.S
+++ b/arch/arm/include/debug/vexpress.S
@@ -16,6 +16,8 @@
16#define DEBUG_LL_PHYS_BASE_RS1 0x1c000000 16#define DEBUG_LL_PHYS_BASE_RS1 0x1c000000
17#define DEBUG_LL_UART_OFFSET_RS1 0x00090000 17#define DEBUG_LL_UART_OFFSET_RS1 0x00090000
18 18
19#define DEBUG_LL_UART_PHYS_CRX 0xb0090000
20
19#define DEBUG_LL_VIRT_BASE 0xf8000000 21#define DEBUG_LL_VIRT_BASE 0xf8000000
20 22
21#if defined(CONFIG_DEBUG_VEXPRESS_UART0_DETECT) 23#if defined(CONFIG_DEBUG_VEXPRESS_UART0_DETECT)
@@ -67,6 +69,14 @@
67 69
68#include <asm/hardware/debug-pl01x.S> 70#include <asm/hardware/debug-pl01x.S>
69 71
72#elif defined(CONFIG_DEBUG_VEXPRESS_UART0_CRX)
73
74 .macro addruart,rp,tmp,tmp2
75 ldr \rp, =DEBUG_LL_UART_PHYS_CRX
76 .endm
77
78#include <asm/hardware/debug-pl01x.S>
79
70#else /* CONFIG_DEBUG_LL_UART_NONE */ 80#else /* CONFIG_DEBUG_LL_UART_NONE */
71 81
72 .macro addruart, rp, rv, tmp 82 .macro addruart, rp, rv, tmp
diff --git a/arch/arm/include/uapi/asm/hwcap.h b/arch/arm/include/uapi/asm/hwcap.h
index 3688fd15a32d..6d34d080372a 100644
--- a/arch/arm/include/uapi/asm/hwcap.h
+++ b/arch/arm/include/uapi/asm/hwcap.h
@@ -25,6 +25,6 @@
25#define HWCAP_IDIVT (1 << 18) 25#define HWCAP_IDIVT (1 << 18)
26#define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */ 26#define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */
27#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT) 27#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
28 28#define HWCAP_LPAE (1 << 20)
29 29
30#endif /* _UAPI__ASMARM_HWCAP_H */ 30#endif /* _UAPI__ASMARM_HWCAP_H */
diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
index 96ee0929790f..5af0ed1b825a 100644
--- a/arch/arm/include/uapi/asm/ptrace.h
+++ b/arch/arm/include/uapi/asm/ptrace.h
@@ -34,28 +34,47 @@
34 34
35/* 35/*
36 * PSR bits 36 * PSR bits
37 * Note on V7M there is no mode contained in the PSR
37 */ 38 */
38#define USR26_MODE 0x00000000 39#define USR26_MODE 0x00000000
39#define FIQ26_MODE 0x00000001 40#define FIQ26_MODE 0x00000001
40#define IRQ26_MODE 0x00000002 41#define IRQ26_MODE 0x00000002
41#define SVC26_MODE 0x00000003 42#define SVC26_MODE 0x00000003
43#if defined(__KERNEL__) && defined(CONFIG_CPU_V7M)
44/*
45 * Use 0 here to get code right that creates a userspace
46 * or kernel space thread.
47 */
48#define USR_MODE 0x00000000
49#define SVC_MODE 0x00000000
50#else
42#define USR_MODE 0x00000010 51#define USR_MODE 0x00000010
52#define SVC_MODE 0x00000013
53#endif
43#define FIQ_MODE 0x00000011 54#define FIQ_MODE 0x00000011
44#define IRQ_MODE 0x00000012 55#define IRQ_MODE 0x00000012
45#define SVC_MODE 0x00000013
46#define ABT_MODE 0x00000017 56#define ABT_MODE 0x00000017
47#define HYP_MODE 0x0000001a 57#define HYP_MODE 0x0000001a
48#define UND_MODE 0x0000001b 58#define UND_MODE 0x0000001b
49#define SYSTEM_MODE 0x0000001f 59#define SYSTEM_MODE 0x0000001f
50#define MODE32_BIT 0x00000010 60#define MODE32_BIT 0x00000010
51#define MODE_MASK 0x0000001f 61#define MODE_MASK 0x0000001f
52#define PSR_T_BIT 0x00000020 62
53#define PSR_F_BIT 0x00000040 63#define V4_PSR_T_BIT 0x00000020 /* >= V4T, but not V7M */
54#define PSR_I_BIT 0x00000080 64#define V7M_PSR_T_BIT 0x01000000
55#define PSR_A_BIT 0x00000100 65#if defined(__KERNEL__) && defined(CONFIG_CPU_V7M)
56#define PSR_E_BIT 0x00000200 66#define PSR_T_BIT V7M_PSR_T_BIT
57#define PSR_J_BIT 0x01000000 67#else
58#define PSR_Q_BIT 0x08000000 68/* for compatibility */
69#define PSR_T_BIT V4_PSR_T_BIT
70#endif
71
72#define PSR_F_BIT 0x00000040 /* >= V4, but not V7M */
73#define PSR_I_BIT 0x00000080 /* >= V4, but not V7M */
74#define PSR_A_BIT 0x00000100 /* >= V6, but not V7M */
75#define PSR_E_BIT 0x00000200 /* >= V6, but not V7M */
76#define PSR_J_BIT 0x01000000 /* >= V5J, but not V7M */
77#define PSR_Q_BIT 0x08000000 /* >= V5E, including V7M */
59#define PSR_V_BIT 0x10000000 78#define PSR_V_BIT 0x10000000
60#define PSR_C_BIT 0x20000000 79#define PSR_C_BIT 0x20000000
61#define PSR_Z_BIT 0x40000000 80#define PSR_Z_BIT 0x40000000