diff options
author | James Hogan <james.hogan@imgtec.com> | 2013-01-31 08:42:03 -0500 |
---|---|---|
committer | James Hogan <james.hogan@imgtec.com> | 2013-03-02 15:09:58 -0500 |
commit | 3d6b7bb0a2c518d24bc3036f9bbb6f3fb35462c3 (patch) | |
tree | d9f8427f6be3a3ec2882ac4c3e9ee2e0dbe9256d /arch/metag | |
parent | c787c2d62fe0c482f5fb3e5b869cd262fe69b244 (diff) |
metag: protect more non-MMU memory regions
Rename setup_txprivext() to setup_priv() and add initialisation of some
more per-thread privilege protection registers:
- TxPRIVSYSR: 0x04400000-0x047fffff
0x05000000-0x07ffffff
0x84000000-0x87ffffff
- TxPIOREG: 0x02000000-0x02ffffff
0x04800000-0x048fffff
- TxSYREG: 0x04000000-0x04000fff (except write fetch system event)
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Diffstat (limited to 'arch/metag')
-rw-r--r-- | arch/metag/include/asm/processor.h | 2 | ||||
-rw-r--r-- | arch/metag/kernel/setup.c | 45 | ||||
-rw-r--r-- | arch/metag/kernel/smp.c | 2 |
3 files changed, 42 insertions, 7 deletions
diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h index b7e25289f3a3..9b029a7911c3 100644 --- a/arch/metag/include/asm/processor.h +++ b/arch/metag/include/asm/processor.h | |||
@@ -154,7 +154,7 @@ unsigned long get_wchan(struct task_struct *p); | |||
154 | 154 | ||
155 | #define cpu_relax() barrier() | 155 | #define cpu_relax() barrier() |
156 | 156 | ||
157 | extern void setup_txprivext(void); | 157 | extern void setup_priv(void); |
158 | 158 | ||
159 | static inline unsigned int hard_processor_id(void) | 159 | static inline unsigned int hard_processor_id(void) |
160 | { | 160 | { |
diff --git a/arch/metag/kernel/setup.c b/arch/metag/kernel/setup.c index dcb1d6d51ce4..9803ca4f6510 100644 --- a/arch/metag/kernel/setup.c +++ b/arch/metag/kernel/setup.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <asm/hwthread.h> | 35 | #include <asm/hwthread.h> |
36 | #include <asm/l2cache.h> | 36 | #include <asm/l2cache.h> |
37 | #include <asm/mach/arch.h> | 37 | #include <asm/mach/arch.h> |
38 | #include <asm/metag_mem.h> | ||
38 | #include <asm/metag_regs.h> | 39 | #include <asm/metag_regs.h> |
39 | #include <asm/mmu.h> | 40 | #include <asm/mmu.h> |
40 | #include <asm/mmzone.h> | 41 | #include <asm/mmzone.h> |
@@ -75,6 +76,32 @@ | |||
75 | META2_PRIV | \ | 76 | META2_PRIV | \ |
76 | UNALIGNED_PRIV) | 77 | UNALIGNED_PRIV) |
77 | 78 | ||
79 | /* | ||
80 | * Protect access to: | ||
81 | * 0x06000000-0x07ffffff Direct mapped region | ||
82 | * 0x05000000-0x05ffffff MMU table region (Meta1) | ||
83 | * 0x04400000-0x047fffff Cache flush region | ||
84 | * 0x84000000-0x87ffffff Core cache memory region (Meta2) | ||
85 | * | ||
86 | * Allow access to: | ||
87 | * 0x80000000-0x81ffffff Core code memory region (Meta2) | ||
88 | */ | ||
89 | #ifdef CONFIG_METAG_META12 | ||
90 | #define PRIVSYSR_BITS TXPRIVSYSR_ALL_BITS | ||
91 | #else | ||
92 | #define PRIVSYSR_BITS (TXPRIVSYSR_ALL_BITS & ~TXPRIVSYSR_CORECODE_BIT) | ||
93 | #endif | ||
94 | |||
95 | /* Protect all 0x02xxxxxx and 0x048xxxxx. */ | ||
96 | #define PIOREG_BITS 0xffffffff | ||
97 | |||
98 | /* | ||
99 | * Protect all 0x04000xx0 (system events) | ||
100 | * except write combiner flush and write fence (system events 4 and 5). | ||
101 | */ | ||
102 | #define PSYREG_BITS 0xfffffffb | ||
103 | |||
104 | |||
78 | extern char _heap_start[]; | 105 | extern char _heap_start[]; |
79 | 106 | ||
80 | #ifdef CONFIG_METAG_BUILTIN_DTB | 107 | #ifdef CONFIG_METAG_BUILTIN_DTB |
@@ -371,7 +398,7 @@ void __init setup_arch(char **cmdline_p) | |||
371 | 398 | ||
372 | paging_init(heap_end); | 399 | paging_init(heap_end); |
373 | 400 | ||
374 | setup_txprivext(); | 401 | setup_priv(); |
375 | 402 | ||
376 | /* Setup the boot cpu's mapping. The rest will be setup below. */ | 403 | /* Setup the boot cpu's mapping. The rest will be setup below. */ |
377 | cpu_2_hwthread_id[smp_processor_id()] = hard_processor_id(); | 404 | cpu_2_hwthread_id[smp_processor_id()] = hard_processor_id(); |
@@ -531,13 +558,21 @@ void __init metag_start_kernel(char *args) | |||
531 | start_kernel(); | 558 | start_kernel(); |
532 | } | 559 | } |
533 | 560 | ||
534 | /* | 561 | /** |
535 | * Setup TXPRIVEXT register to be prevent userland from touching our | 562 | * setup_priv() - Set up privilege protection registers. |
536 | * precious registers. | 563 | * |
564 | * Set up privilege protection registers such as TXPRIVEXT to prevent userland | ||
565 | * from touching our precious registers and sensitive memory areas. | ||
537 | */ | 566 | */ |
538 | void setup_txprivext(void) | 567 | void setup_priv(void) |
539 | { | 568 | { |
569 | unsigned int offset = hard_processor_id() << TXPRIVREG_STRIDE_S; | ||
570 | |||
540 | __core_reg_set(TXPRIVEXT, PRIV_BITS); | 571 | __core_reg_set(TXPRIVEXT, PRIV_BITS); |
572 | |||
573 | metag_out32(PRIVSYSR_BITS, T0PRIVSYSR + offset); | ||
574 | metag_out32(PIOREG_BITS, T0PIOREG + offset); | ||
575 | metag_out32(PSYREG_BITS, T0PSYREG + offset); | ||
541 | } | 576 | } |
542 | 577 | ||
543 | PTBI pTBI_get(unsigned int cpu) | 578 | PTBI pTBI_get(unsigned int cpu) |
diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c index d1163127eb68..4b6d1f14df32 100644 --- a/arch/metag/kernel/smp.c +++ b/arch/metag/kernel/smp.c | |||
@@ -268,7 +268,7 @@ asmlinkage void secondary_start_kernel(void) | |||
268 | 268 | ||
269 | preempt_disable(); | 269 | preempt_disable(); |
270 | 270 | ||
271 | setup_txprivext(); | 271 | setup_priv(); |
272 | 272 | ||
273 | /* | 273 | /* |
274 | * Enable local interrupts. | 274 | * Enable local interrupts. |