提交 b849a60e 编写于 作者: U Uwe Kleine-König

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: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Message-Id: 1358413196-5609-2-git-send-email-u.kleine-koenig@pengutronix.de (v8)
上级 949db153
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#define vectors_high() (0) #define vectors_high() (0)
#endif #endif
#ifdef CONFIG_CPU_CP15
extern unsigned long cr_no_alignment; /* defined in entry-armv.S */ extern unsigned long cr_no_alignment; /* defined in entry-armv.S */
extern unsigned long cr_alignment; /* defined in entry-armv.S */ extern unsigned long cr_alignment; /* defined in entry-armv.S */
...@@ -82,6 +84,18 @@ static inline void set_copro_access(unsigned int val) ...@@ -82,6 +84,18 @@ static inline void set_copro_access(unsigned int val)
isb(); isb();
} }
#endif #else /* ifdef CONFIG_CPU_CP15 */
/*
* cr_alignment and cr_no_alignment are tightly coupled to cp15 (at least in the
* minds of the developers). Yielding 0 for machines without a cp15 (and making
* it read-only) is fine for most cases and saves quite some #ifdeffery.
*/
#define cr_no_alignment UL(0)
#define cr_alignment UL(0)
#endif /* ifdef CONFIG_CPU_CP15 / else */
#endif /* ifndef __ASSEMBLY__ */
#endif #endif
...@@ -98,8 +98,9 @@ __mmap_switched: ...@@ -98,8 +98,9 @@ __mmap_switched:
str r9, [r4] @ Save processor ID str r9, [r4] @ Save processor ID
str r1, [r5] @ Save machine type str r1, [r5] @ Save machine type
str r2, [r6] @ Save atags pointer str r2, [r6] @ Save atags pointer
bic r4, r0, #CR_A @ Clear 'A' bit cmp r7, #0
stmia r7, {r0, r4} @ Save control register values bicne r4, r0, #CR_A @ Clear 'A' bit
stmneia r7, {r0, r4} @ Save control register values
b start_kernel b start_kernel
ENDPROC(__mmap_switched) ENDPROC(__mmap_switched)
...@@ -113,7 +114,11 @@ __mmap_switched_data: ...@@ -113,7 +114,11 @@ __mmap_switched_data:
.long processor_id @ r4 .long processor_id @ r4
.long __machine_arch_type @ r5 .long __machine_arch_type @ r5
.long __atags_pointer @ r6 .long __atags_pointer @ r6
#ifdef CONFIG_CPU_CP15
.long cr_alignment @ r7 .long cr_alignment @ r7
#else
.long 0 @ r7
#endif
.long init_thread_union + THREAD_START_SP @ sp .long init_thread_union + THREAD_START_SP @ sp
.size __mmap_switched_data, . - __mmap_switched_data .size __mmap_switched_data, . - __mmap_switched_data
......
...@@ -964,12 +964,14 @@ static int __init alignment_init(void) ...@@ -964,12 +964,14 @@ static int __init alignment_init(void)
return -ENOMEM; return -ENOMEM;
#endif #endif
#ifdef CONFIG_CPU_CP15
if (cpu_is_v6_unaligned()) { if (cpu_is_v6_unaligned()) {
cr_alignment &= ~CR_A; cr_alignment &= ~CR_A;
cr_no_alignment &= ~CR_A; cr_no_alignment &= ~CR_A;
set_cr(cr_alignment); set_cr(cr_alignment);
ai_usermode = safe_usermode(ai_usermode, false); ai_usermode = safe_usermode(ai_usermode, false);
} }
#endif
hook_fault_code(FAULT_CODE_ALIGNMENT, do_alignment, SIGBUS, BUS_ADRALN, hook_fault_code(FAULT_CODE_ALIGNMENT, do_alignment, SIGBUS, BUS_ADRALN,
"alignment exception"); "alignment exception");
......
...@@ -97,6 +97,7 @@ static struct cachepolicy cache_policies[] __initdata = { ...@@ -97,6 +97,7 @@ static struct cachepolicy cache_policies[] __initdata = {
} }
}; };
#ifdef CONFIG_CPU_CP15
/* /*
* These are useful for identifying cache coherency * These are useful for identifying cache coherency
* problems by allowing the cache or the cache and * problems by allowing the cache or the cache and
...@@ -195,6 +196,22 @@ void adjust_cr(unsigned long mask, unsigned long set) ...@@ -195,6 +196,22 @@ void adjust_cr(unsigned long mask, unsigned long set)
} }
#endif #endif
#else /* ifdef CONFIG_CPU_CP15 */
static int __init early_cachepolicy(char *p)
{
pr_warning("cachepolicy kernel parameter not supported without cp15\n");
}
early_param("cachepolicy", early_cachepolicy);
static int __init noalign_setup(char *__unused)
{
pr_warning("noalign kernel parameter not supported without cp15\n");
}
__setup("noalign", noalign_setup);
#endif /* ifdef CONFIG_CPU_CP15 / else */
#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN #define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
#define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册