NOMMU fixes and preparation for NOMMU/SMP
cover NOMMU fixes and preparation for NOMMU/SMP
This patch series, mostly written by Will Deacon, contains fixes for !CONFIG_MMU that are required in order to be able to run an SMP/NOMMU system.
These patches are required for Cortex-R7 and MPU support, that will be posted to this list shortly.
This series represents my 'nommu' branch, which can be found at
http://www.linux-arm.org/git?p=linux-ja.git
These patches have been tested over the last year on Versatile Express/NOMMU.
Jonathan Austin (2):
ARM: nommu: Don't build smp_tlb.c for !CONFIG_MMU
ARM: nommu: add stub local_flush_bp_all() for !CONFIG_MMUU
Will Deacon (5):
ARM: nommu: add entry point for secondary CPUs to head-nommu.S
ARM: nommu: define dummy TLB operations for nommu configurations
ARM: nommu: provide dummy cpu_switch_mm implementation
ARM: nommu: do not initialise page tables in secondary_data structure
ARM: suspend: fix CPU suspend code for !CONFIG_MMU configurations
arch/arm/include/asm/proc-fns.h | 4 +++ arch/arm/include/asm/smp_plat.h | 4 +++ arch/arm/include/asm/tlbflush.h | 25 ++++++++++++++- arch/arm/kernel/Makefile | 5 ++- arch/arm/kernel/head-nommu.S | 50 +++++++++++++++++++++++++++--- arch/arm/kernel/smp.c | 2 ++ arch/arm/kernel/suspend.c | 64 ++++++++++++++++++++++----------------- arch/arm/mm/proc-v6.S | 6 +++- arch/arm/mm/proc-v7.S | 14 ++++++--- 9 files changed, 134 insertions(+), 40 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/7 ARM: nommu: add entry point for secondary CPUs to head-nommu.S
From: Will Deacon <[email protected]>
This patch adds a secondary_startup entry point to head-nommu.S so that we can boot secondary CPUs on an SMP nommu configuration.
--- arch/arm/kernel/head-nommu.S | 50 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-)
arch/arm/kernel/head-nommu.S +46 -4
@@ -59,12 +59,56 @@ ENTRY(stext) movs r10, r5 @ invalid processor (r5=0)? beq __error_p @ yes, error 'p' - adr lr, BSYM(__after_proc_init) @ return (PIC) address + ldr r13, =__mmap_switched @ address to jump to after + @ initialising sctlr + adr lr, BSYM(1f) @ return (PIC) address ARM( add pc, r10, #PROCINFO_INITFUNC ) THUMB( add r12, r10, #PROCINFO_INITFUNC ) THUMB( mov pc, r12 ) + 1: b __after_proc_init ENDPROC(stext) +#ifdef CONFIG_SMP + __CPUINIT +ENTRY(secondary_startup) + /* + * Common entry point for secondary CPUs. + * + * Ensure that we're in SVC mode, and IRQs are disabled. Lookup + * the processor type - there is no need to check the machine type + * as it has already been validated by the primary processor. + */ + setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 +#ifndef CONFIG_CPU_CP15 + ldr r9, =CONFIG_PROCESSOR_ID +#else + mrc p15, 0, r9, c0, c0 @ get processor id +#endif + bl __lookup_processor_type @ r5=procinfo r9=cpuid + movs r10, r5 @ invalid processor? + beq __error_p @ yes, error 'p' + + adr r4, __secondary_data + ldmia r4, {r7, r12} + adr lr, BSYM(__after_proc_init) @ return address + mov r13, r12 @ __secondary_switched address + ARM( add pc, r10, #PROCINFO_INITFUNC ) + THUMB( add r12, r10, #PROCINFO_INITFUNC ) + THUMB( mov pc, r12 ) +ENDPROC(secondary_startup) + +ENTRY(__secondary_switched) + ldr sp, [r7, #8] @ set up the stack pointer + mov fp, #0 + b secondary_start_kernel +ENDPROC(__secondary_switched) + + .type __secondary_data, %object +__secondary_data: + .long secondary_data + .long __secondary_switched +#endif /* CONFIG_SMP */ + /* * Set the Control Register and Read the process ID. */
@@ -95,9 +139,7 @@ __after_proc_init: #endif mcr p15, 0, r0, c1, c0, 0 @ write control reg #endif /* CONFIG_CPU_CP15 */ - - b __mmap_switched @ clear the BSS and jump - @ to start_kernel + mov pc, r13 ENDPROC(__after_proc_init) .ltorg
Signature · 1 line
1.7.9.5
PATCH 2/7 ARM: nommu: define dummy TLB operations for nommu configurations
In reply to Jonathan AustinFrom: Will Deacon <[email protected]>
nommu platforms do not perform address translation and therefore clearly don't have TLBs. However, some SMP code assumes the presence of the TLB flushing routines and will therefore fail to compile for a nommu system.
This patch defines dummy local_* TLB operations and #defines tlb_ops_need_broadcast() as 0, therefore causing the usual ARM SMP TLB operations to call the local variants instead.
--- arch/arm/include/asm/smp_plat.h | 4 ++++ arch/arm/include/asm/tlbflush.h | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
arch/arm/include/asm/smp_plat.h +4 -0
@@ -26,6 +26,9 @@ static inline bool is_smp(void) }/* all SMP configurations have the extended CPUID registers */ +#ifndef CONFIG_MMU +#define tlb_ops_need_broadcast () 0 +#else static inline int tlb_ops_need_broadcast (void ) {if (!is_smp ())
@@ -33,6 +36,7 @@ static inline int tlb_ops_need_broadcast(void) return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2; } +#endif #if !defined(CONFIG_SMP ) || __LINUX_ARM_ARCH__ >=7 #define cache_ops_need_broadcast () 0
arch/arm/include/asm/tlbflush.h +22 -1
@@ -537,6 +537,27 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,#endif -#endif /* CONFIG_MMU */ +#elif defined(CONFIG_SMP )/* !CONFIG_MMU */ + +#ifndef __ASSEMBLY__ + +#include <linux/mm_types.h> + +static inline void local_flush_tlb_all (void ) { } +static inline void local_flush_tlb_mm (struct mm_struct *mm) { } +static inline void local_flush_tlb_page (struct vm_area_struct *vma,unsigned long uaddr) { } +static inline void local_flush_tlb_kernel_page (unsigned long kaddr) { } +static inline void local_flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end) { } +static inline void local_flush_tlb_kernel_range (unsigned long start,unsigned long end) { } + +extern void flush_tlb_all (void ); +extern void flush_tlb_mm (struct mm_struct *mm); +extern void flush_tlb_page (struct vm_area_struct *vma,unsigned long uaddr); +extern void flush_tlb_kernel_page (unsigned long kaddr); +extern void flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end); +extern void flush_tlb_kernel_range (unsigned long start,unsigned long end); +#endif /* __ASSEMBLY__ */ + +#endif #endif
Signature · 1 line
1.7.9.5
PATCH 3/7 ARM: nommu: provide dummy cpu_switch_mm implementation
In reply to Jonathan AustinFrom: Will Deacon <[email protected]>
cpu_switch_mm is a logical nop on nommu systems, so define it as such when !CONFIG_MMU.
--- arch/arm/include/asm/proc-fns.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/include/asm/proc-fns.h +4 -0
@@ -137,6 +137,10 @@ extern void cpu_resume(void); })#endif +#else /*!CONFIG_MMU */ + +#define cpu_switch_mm (pgd,mm) { } +#endif #endif /* __ASSEMBLY__ */
Signature · 1 line
1.7.9.5
PATCH 4/7 ARM: nommu: do not initialise page tables in secondary_data structure
In reply to Jonathan AustinFrom: Will Deacon <[email protected]>
nommu systems do not require any page tables, so don't try to initialise them when bringing up secondary cores.
--- arch/arm/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/kernel/smp.c +2 -0
@@ -87,8 +87,10 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)* its stack and the page tables. */ secondary_data.stack =task_stack_page (idle) +THREAD_START_SP ; +#ifdef CONFIG_MMU secondary_data.pgdir =virt_to_phys (idmap_pgd); secondary_data.swapper_pg_dir =virt_to_phys (swapper_pg_dir); +#endif __cpuc_flush_dcache_area (&secondary_data,sizeof (secondary_data));outer_clean_range (__pa (&secondary_data),__pa (&secondary_data +1 ));
Signature · 1 line
1.7.9.5
PATCH 5/7 ARM: suspend: fix CPU suspend code for !CONFIG_MMU configurations
In reply to Jonathan AustinFrom: Will Deacon <[email protected]>
The ARM CPU suspend code can be selected even for a !CONFIG_MMU configuration. The resulting kernel will not compile and, even if it did, would access undefined co-processor registers when executing.
This patch fixes the v6 and v7 CPU suspend code for the nommu case.
--- arch/arm/kernel/suspend.c | 64 +++++++++++++++++++++++++-------------------- arch/arm/mm/proc-v6.S | 6 ++++- arch/arm/mm/proc-v7.S | 14 ++++++---- 3 files changed, 50 insertions(+), 34 deletions(-)
arch/arm/kernel/suspend.c +36 -28
@@ -10,6 +10,42 @@extern int __cpu_suspend (unsigned long ,int (*)(unsigned long ));extern void cpu_resume_mmu (void ); +#ifdef CONFIG_MMU +/* +* Hide the first two arguments to __cpu_suspend - these are an implementation +* detail which platform code shouldn't have to know about. +*/ +int cpu_suspend (unsigned long arg,int (*fn)(unsigned long )) +{ +struct mm_struct *mm = current->active_mm; +int ret; + +if (!idmap_pgd) +return -EINVAL ; + +/* +* Provide a temporary page table with an identity mapping for +* the MMU-enable code, required for resuming. On successful +* resume (indicated by a zero return code), we need to switch +* back to the correct page tables. +*/ + ret =__cpu_suspend (arg, fn); +if (ret ==0 ) { +cpu_switch_mm (mm->pgd, mm); +local_flush_bp_all (); +local_flush_tlb_all (); + } + +return ret; +} +#else +int cpu_suspend (unsigned long arg,int (*fn)(unsigned long )) +{ +return __cpu_suspend (arg, fn); +} +#define idmap_pgd NULL +#endif +/* * This is called by __cpu_suspend() to save the state, and do whatever * flushing is required to ensure that when the CPU goes to sleep we have
@@ -46,31 +82,3 @@ void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr)outer_clean_range (virt_to_phys (save_ptr),virt_to_phys (save_ptr) +sizeof (*save_ptr)); } - -/* -* Hide the first two arguments to __cpu_suspend - these are an implementation -* detail which platform code shouldn't have to know about. -*/ -int cpu_suspend (unsigned long arg,int (*fn)(unsigned long )) -{ -struct mm_struct *mm = current->active_mm; -int ret; - -if (!idmap_pgd) -return -EINVAL ; - -/* -* Provide a temporary page table with an identity mapping for -* the MMU-enable code, required for resuming. On successful -* resume (indicated by a zero return code), we need to switch -* back to the correct page tables. -*/ - ret =__cpu_suspend (arg, fn); -if (ret ==0 ) { -cpu_switch_mm (mm->pgd, mm); -local_flush_bp_all (); -local_flush_tlb_all (); - } - -return ret; -}
arch/arm/mm/proc-v6.S +5 -1
@@ -140,8 +140,10 @@ ENTRY(cpu_v6_set_pte_ext) ENTRY(cpu_v6_do_suspend) stmfd sp!, {r4 - r9, lr} mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID +#ifdef CONFIG_MMU mrc p15, 0, r5, c3, c0, 0 @ Domain ID mrc p15, 0, r6, c2, c0, 1 @ Translation table base 1 +#endif mrc p15, 0, r7, c1, c0, 1 @ auxiliary control register mrc p15, 0, r8, c1, c0, 2 @ co-processor access control mrc p15, 0, r9, c1, c0, 0 @ control register
@@ -158,14 +160,16 @@ ENTRY(cpu_v6_do_resume) mcr p15, 0, ip, c13, c0, 1 @ set reserved context ID ldmia r0, {r4 - r9} mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID +#ifdef CONFIG_MMU mcr p15, 0, r5, c3, c0, 0 @ Domain ID ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP) ALT_UP(orr r1, r1, #TTB_FLAGS_UP) mcr p15, 0, r1, c2, c0, 0 @ Translation table base 0 mcr p15, 0, r6, c2, c0, 1 @ Translation table base 1 + mcr p15, 0, ip, c2, c0, 2 @ TTB control register +#endif mcr p15, 0, r7, c1, c0, 1 @ auxiliary control register mcr p15, 0, r8, c1, c0, 2 @ co-processor access control - mcr p15, 0, ip, c2, c0, 2 @ TTB control register mcr p15, 0, ip, c7, c5, 4 @ ISB mov r0, r9 @ control register b cpu_resume_mmu
arch/arm/mm/proc-v7.S +9 -5
@@ -98,9 +98,11 @@ ENTRY(cpu_v7_do_suspend) mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID mrc p15, 0, r5, c13, c0, 3 @ User r/o thread ID stmia r0!, {r4 - r5} +#ifdef CONFIG_MMU mrc p15, 0, r6, c3, c0, 0 @ Domain ID mrc p15, 0, r7, c2, c0, 1 @ TTB 1 mrc p15, 0, r11, c2, c0, 2 @ TTB control register +#endif mrc p15, 0, r8, c1, c0, 0 @ Control register mrc p15, 0, r9, c1, c0, 1 @ Auxiliary control register mrc p15, 0, r10, c1, c0, 2 @ Co-processor access control
@@ -110,13 +112,14 @@ ENDPROC(cpu_v7_do_suspend) ENTRY(cpu_v7_do_resume) mov ip, #0 - mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache mcr p15, 0, ip, c13, c0, 1 @ set reserved context ID ldmia r0!, {r4 - r5} mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID mcr p15, 0, r5, c13, c0, 3 @ User r/o thread ID ldmia r0, {r6 - r11} +#ifdef CONFIG_MMU + mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs mcr p15, 0, r6, c3, c0, 0 @ Domain ID #ifndef CONFIG_ARM_LPAE ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP)
@@ -125,14 +128,15 @@ ENTRY(cpu_v7_do_resume) mcr p15, 0, r1, c2, c0, 0 @ TTB 0 mcr p15, 0, r7, c2, c0, 1 @ TTB 1 mcr p15, 0, r11, c2, c0, 2 @ TTB control register - mrc p15, 0, r4, c1, c0, 1 @ Read Auxiliary control register - teq r4, r9 @ Is it already set? - mcrne p15, 0, r9, c1, c0, 1 @ No, so write it - mcr p15, 0, r10, c1, c0, 2 @ Co-processor access control ldr r4, =PRRR @ PRRR ldr r5, =NMRR @ NMRR mcr p15, 0, r4, c10, c2, 0 @ write PRRR mcr p15, 0, r5, c10, c2, 1 @ write NMRR +#endif /* CONFIG_MMU */ + mrc p15, 0, r4, c1, c0, 1 @ Read Auxiliary control register + teq r4, r9 @ Is it already set? + mcrne p15, 0, r9, c1, c0, 1 @ No, so write it + mcr p15, 0, r10, c1, c0, 2 @ Co-processor access control isb dsb mov r0, r8 @ control register
Signature · 1 line
1.7.9.5
PATCH 6/7 ARM: nommu: Don't build smp_tlb.c for !CONFIG_MMU
In reply to Jonathan AustinWithout an MMU we don't need to do any TLB maintenance. Until the addition of 93dc68876b60 (ARM: 7684/1: errata: Workaround for Cortex-A15 erratum 798181 (TLBI/DSB operations)) building the tlb maintenance ops in smp_tlb.c worked, though none of the contents were used.
Since that commit, however, SMP NOMMU has not been able to build. This patch restores that ability by making the building of smp_tlb.c dependent on MMU.
--- arch/arm/kernel/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/kernel/Makefile +4 -1
@@ -32,7 +32,10 @@ obj-$(CONFIG_ARTHUR) += arthur.o obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o obj-$(CONFIG_ARM_CPU_SUSPEND) += sleep.o suspend.o -obj-$(CONFIG_SMP) += smp.o smp_tlb.o +obj-$(CONFIG_SMP) += smp.o +ifdef CONFIG_MMU +obj-$(CONFIG_SMP) += smp_tlb.o +endif obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o obj-$(CONFIG_HAVE_ARM_TWD) += smp_twd.o obj-$(CONFIG_ARM_ARCH_TIMER) += arch_timer.o
Signature · 1 line
1.7.9.5
PATCH 7/7 ARM: nommu: add stub local_flush_bp_all() for !CONFIG_MMUU
In reply to Jonathan AustinSince the merging of Will's tlb-ops branch, specifically 89c7e4b8bbb3 (ARM: 7661/1: mm: perform explicit branch predictor maintenance when required), building SMP without CONFIG_MMU has been broken.
The local_flush_bp_all function is only called for operations related to changing the kernel's view of memory and ASID rollover - both of which are irrelevant to an !MMU kernel.
This patch adds a stub local_flush_bp_all() function to the other tlb maintenance stubs and restores the ability to build an SMP !MMU kernel.
--- arch/arm/include/asm/tlbflush.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/include/asm/tlbflush.h +2 -0
@@ -549,6 +549,7 @@ static inline void local_flush_tlb_page(struct vm_area_struct *vma, unsigned lonstatic inline void local_flush_tlb_kernel_page (unsigned long kaddr) { }static inline void local_flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end) { }static inline void local_flush_tlb_kernel_range (unsigned long start,unsigned long end) { } +static inline void local_flush_bp_all (void ) { }extern void flush_tlb_all (void );extern void flush_tlb_mm (struct mm_struct *mm);
@@ -556,6 +557,7 @@ extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr);extern void flush_tlb_kernel_page (unsigned long kaddr);extern void flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end);extern void flush_tlb_kernel_range (unsigned long start,unsigned long end); +extern void flush_bp_all (void );#endif /* __ASSEMBLY__ */ #endif
Signature · 1 line
1.7.9.5