diff options
| author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2012-01-16 04:34:31 -0500 |
|---|---|---|
| committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2013-01-31 15:44:45 -0500 |
| commit | b849a60e0903b1c5430c3859864554662e127a8d (patch) | |
| tree | fe441d30362531fa204b52661a3d20a7f836fb19 /arch | |
| parent | 949db153b6466c6f7cad5a427ecea94985927311 (diff) | |
ARM: make cr_alignment read-only #ifndef CONFIG_CPU_CP15
This makes cr_alignment a constant 0 to break code that tries to modify
the value as it's likely that it's built on wrong assumption when
CONFIG_CPU_CP15 isn't defined. For code that is only reading the value 0
is more or less a fine value to report.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Message-Id: 1358413196-5609-2-git-send-email-u.kleine-koenig@pengutronix.de (v8)
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/arm/include/asm/cp15.h | 16 | ||||
| -rw-r--r-- | arch/arm/kernel/head-common.S | 9 | ||||
| -rw-r--r-- | arch/arm/mm/alignment.c | 2 | ||||
| -rw-r--r-- | arch/arm/mm/mmu.c | 17 |
4 files changed, 41 insertions, 3 deletions
diff --git a/arch/arm/include/asm/cp15.h b/arch/arm/include/asm/cp15.h index 5ef4d8015a60..1f3262e99d81 100644 --- a/arch/arm/include/asm/cp15.h +++ b/arch/arm/include/asm/cp15.h | |||
| @@ -42,6 +42,8 @@ | |||
| 42 | #define vectors_high() (0) | 42 | #define vectors_high() (0) |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| 45 | #ifdef CONFIG_CPU_CP15 | ||
| 46 | |||
| 45 | extern unsigned long cr_no_alignment; /* defined in entry-armv.S */ | 47 | extern unsigned long cr_no_alignment; /* defined in entry-armv.S */ |
| 46 | extern unsigned long cr_alignment; /* defined in entry-armv.S */ | 48 | extern unsigned long cr_alignment; /* defined in entry-armv.S */ |
| 47 | 49 | ||
| @@ -82,6 +84,18 @@ static inline void set_copro_access(unsigned int val) | |||
| 82 | isb(); | 84 | isb(); |
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | #endif | 87 | #else /* ifdef CONFIG_CPU_CP15 */ |
| 88 | |||
| 89 | /* | ||
| 90 | * cr_alignment and cr_no_alignment are tightly coupled to cp15 (at least in the | ||
| 91 | * minds of the developers). Yielding 0 for machines without a cp15 (and making | ||
| 92 | * it read-only) is fine for most cases and saves quite some #ifdeffery. | ||
| 93 | */ | ||
| 94 | #define cr_no_alignment UL(0) | ||
| 95 | #define cr_alignment UL(0) | ||
| 96 | |||
| 97 | #endif /* ifdef CONFIG_CPU_CP15 / else */ | ||
| 98 | |||
| 99 | #endif /* ifndef __ASSEMBLY__ */ | ||
| 86 | 100 | ||
| 87 | #endif | 101 | #endif |
diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S index 854bd22380d3..5b391a689b47 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S | |||
| @@ -98,8 +98,9 @@ __mmap_switched: | |||
| 98 | str r9, [r4] @ Save processor ID | 98 | str r9, [r4] @ Save processor ID |
| 99 | str r1, [r5] @ Save machine type | 99 | str r1, [r5] @ Save machine type |
| 100 | str r2, [r6] @ Save atags pointer | 100 | str r2, [r6] @ Save atags pointer |
| 101 | bic r4, r0, #CR_A @ Clear 'A' bit | 101 | cmp r7, #0 |
| 102 | stmia r7, {r0, r4} @ Save control register values | 102 | bicne r4, r0, #CR_A @ Clear 'A' bit |
| 103 | stmneia r7, {r0, r4} @ Save control register values | ||
| 103 | b start_kernel | 104 | b start_kernel |
| 104 | ENDPROC(__mmap_switched) | 105 | ENDPROC(__mmap_switched) |
| 105 | 106 | ||
| @@ -113,7 +114,11 @@ __mmap_switched_data: | |||
| 113 | .long processor_id @ r4 | 114 | .long processor_id @ r4 |
| 114 | .long __machine_arch_type @ r5 | 115 | .long __machine_arch_type @ r5 |
| 115 | .long __atags_pointer @ r6 | 116 | .long __atags_pointer @ r6 |
| 117 | #ifdef CONFIG_CPU_CP15 | ||
| 116 | .long cr_alignment @ r7 | 118 | .long cr_alignment @ r7 |
| 119 | #else | ||
| 120 | .long 0 @ r7 | ||
| 121 | #endif | ||
| 117 | .long init_thread_union + THREAD_START_SP @ sp | 122 | .long init_thread_union + THREAD_START_SP @ sp |
| 118 | .size __mmap_switched_data, . - __mmap_switched_data | 123 | .size __mmap_switched_data, . - __mmap_switched_data |
| 119 | 124 | ||
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c index b820edaf3184..feeb3eaccb1c 100644 --- a/arch/arm/mm/alignment.c +++ b/arch/arm/mm/alignment.c | |||
| @@ -964,12 +964,14 @@ static int __init alignment_init(void) | |||
| 964 | return -ENOMEM; | 964 | return -ENOMEM; |
| 965 | #endif | 965 | #endif |
| 966 | 966 | ||
| 967 | #ifdef CONFIG_CPU_CP15 | ||
| 967 | if (cpu_is_v6_unaligned()) { | 968 | if (cpu_is_v6_unaligned()) { |
| 968 | cr_alignment &= ~CR_A; | 969 | cr_alignment &= ~CR_A; |
| 969 | cr_no_alignment &= ~CR_A; | 970 | cr_no_alignment &= ~CR_A; |
| 970 | set_cr(cr_alignment); | 971 | set_cr(cr_alignment); |
| 971 | ai_usermode = safe_usermode(ai_usermode, false); | 972 | ai_usermode = safe_usermode(ai_usermode, false); |
| 972 | } | 973 | } |
| 974 | #endif | ||
| 973 | 975 | ||
| 974 | hook_fault_code(FAULT_CODE_ALIGNMENT, do_alignment, SIGBUS, BUS_ADRALN, | 976 | hook_fault_code(FAULT_CODE_ALIGNMENT, do_alignment, SIGBUS, BUS_ADRALN, |
| 975 | "alignment exception"); | 977 | "alignment exception"); |
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index ce328c7f5c94..7c347bcc9421 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
| @@ -97,6 +97,7 @@ static struct cachepolicy cache_policies[] __initdata = { | |||
| 97 | } | 97 | } |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | #ifdef CONFIG_CPU_CP15 | ||
| 100 | /* | 101 | /* |
| 101 | * These are useful for identifying cache coherency | 102 | * These are useful for identifying cache coherency |
| 102 | * problems by allowing the cache or the cache and | 103 | * problems by allowing the cache or the cache and |
| @@ -195,6 +196,22 @@ void adjust_cr(unsigned long mask, unsigned long set) | |||
| 195 | } | 196 | } |
| 196 | #endif | 197 | #endif |
| 197 | 198 | ||
| 199 | #else /* ifdef CONFIG_CPU_CP15 */ | ||
| 200 | |||
| 201 | static int __init early_cachepolicy(char *p) | ||
| 202 | { | ||
| 203 | pr_warning("cachepolicy kernel parameter not supported without cp15\n"); | ||
| 204 | } | ||
| 205 | early_param("cachepolicy", early_cachepolicy); | ||
| 206 | |||
| 207 | static int __init noalign_setup(char *__unused) | ||
| 208 | { | ||
| 209 | pr_warning("noalign kernel parameter not supported without cp15\n"); | ||
| 210 | } | ||
| 211 | __setup("noalign", noalign_setup); | ||
| 212 | |||
| 213 | #endif /* ifdef CONFIG_CPU_CP15 / else */ | ||
| 214 | |||
| 198 | #define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN | 215 | #define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN |
| 199 | #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE | 216 | #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE |
| 200 | 217 | ||
