ARM: use cache type functions for arch_get_unmapped_area
PATCH v2 1/2 ARM: use cache type functions for arch_get_unmapped_area
From: Rob Herring <[email protected]>
There are already cache type decoding functions, so use those instead of custom decode code which only works for ARMv6.
This change also correctly enables cache colour alignment on Cortex-A9 whose I-cache is aliasing VIPT.
---
v2:
- remove icache_is_vipt_aliasing check
Nico, can you pick up these 2 patches into the Linaro kernel to get some testing?
Rob
arch/arm/mm/mmap.c | 23 ++++++----------------- 1 files changed, 6 insertions(+), 17 deletions(-)
arch/arm/mm/mmap.c +6 -17
@@ -9,8 +9,7 @@#include <linux/io.h> #include <linux/personality.h> #include <linux/random.h> -#include <asm/cputype.h> -#include <asm/system.h> +#include <asm/cachetype.h> #define COLOUR_ALIGN (addr,pgoff) \ ((((addr)+SHMLBA-1)&~(SHMLBA-1)) + \
@@ -32,25 +31,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,struct mm_struct *mm = current->mm;struct vm_area_struct *vma;unsigned long start_addr; -#if defined(CONFIG_CPU_V6 ) || defined(CONFIG_CPU_V6K ) -unsigned int cache_type; -int do_align =0 , aliasing =0 ; +int do_align =0 ; +int aliasing =cache_is_vipt_aliasing ();/* * We only need to do colour alignment if either the I or D -* caches alias. This is indicated by bits 9 and 21 of the -* cache type register. +* caches alias. */ - cache_type =read_cpuid_cachetype (); -if (cache_type !=read_cpuid_id ()) { - aliasing = (cache_type | cache_type >>12 ) & (1 <<11 ); -if (aliasing) - do_align = filp || flags &MAP_SHARED ; - } -#else -#define do_align 0 -#define aliasing 0 -#endif +if (aliasing) + do_align = filp || (flags &MAP_SHARED );/* * We enforce the MAP_FIXED case.
Signature · 1 line
1.7.5.4
PATCH v2 2/2 ARM: topdown mmap support
From: Rob Herring <[email protected]>
Similar to other architectures, this adds topdown mmap support in user process address space allocation policy. This allows mmap sizes greater than 2GB. This support is largely copied from MIPS and the generic implementations.
The address space randomization is moved into arch_pick_mmap_layout.
Tested on V-Express with ubuntu and a mmap test from here:
https://bugs.launchpad.net/bugs/861296
---
v2:
- remove icache_is_vipt_aliasing check
arch/arm/include/asm/pgtable.h | 1 + arch/arm/include/asm/processor.h | 2 + arch/arm/mm/mmap.c | 173 ++++++++++++++++++++++++++++++++++++- 3 files changed, 171 insertions(+), 5 deletions(-)
arch/arm/include/asm/pgtable.h +1 -0
@@ -336,6 +336,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)* We provide our own arch_get_unmapped_area to cope with VIPT caches. */ #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN /* * remap a physical page `pfn' of size `size' with page protection `prot'
arch/arm/include/asm/processor.h +2 -0
@@ -123,6 +123,8 @@ static inline void prefetch(const void *ptr)#endif +#define HAVE_ARCH_PICK_MMAP_LAYOUT +#endif #endif /* __ASM_ARM_PROCESSOR_H */
arch/arm/mm/mmap.c +168 -5
197 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH v2 1/2 ARM: use cache type functions for arch_get_unmapped_area
In reply to Rob HerringHi Rob,
Quoted 7 lines · Rob Herring
From: Rob Herring <[email protected]>
There are already cache type decoding functions, so use those instead of custom decode code which only works for ARMv6.
This change also correctly enables cache colour alignment on Cortex-A9 whose I-cache is aliasing VIPT.
You can probably drop this paragraph.
With that,
but yes, it would be nice to see this in -next for a bit.
Cheers,
Will
PATCH v2 2/2 ARM: topdown mmap support
In reply to Rob HerringQuoted 14 lines · Rob Herring
From: Rob Herring <[email protected]>
Similar to other architectures, this adds topdown mmap support in user process address space allocation policy. This allows mmap sizes greater than 2GB. This support is largely copied from MIPS and the generic implementations.
The address space randomization is moved into
arch_pick_mmap_layout.Tested on V-Express with ubuntu and a mmap test from here:
https://bugs.launchpad.net/bugs/861296Signed-off-by Rob Herring <[email protected]>Acked-by Nicolas Pitre <[email protected]>
Quoted 9 lines
---
v2:
- removeicache_is_vipt_aliasingcheckarch/arm/include/asm/pgtable.h | 1 + arch/arm/include/asm/processor.h | 2 + arch/arm/mm/mmap.c | 173 ++++++++++++++++++++++++++++++++++++- 3 files changed, 171 insertions(+), 5 deletions(-)
Russell,
I submitted these 2 patches to the patch system. Can you please pull into your next branch so they can get some more testing.
Cheers,
Rob
PATCH v2 2/2 ARM: topdown mmap support
Quoted 25 lines · Rob Herring
Quoted 14 lines · Rob Herring
From: Rob Herring <[email protected]>
Similar to other architectures, this adds topdown mmap support in user process address space allocation policy. This allows mmap sizes greater than 2GB. This support is largely copied from MIPS and the generic implementations.
The address space randomization is moved into
arch_pick_mmap_layout.Tested on V-Express with ubuntu and a mmap test from here:
https://bugs.launchpad.net/bugs/861296Signed-off-by Rob Herring <[email protected]>Acked-by Nicolas Pitre <[email protected]>Quoted 9 lines
---
v2:
- removeicache_is_vipt_aliasingcheckarch/arm/include/asm/pgtable.h | 1 + arch/arm/include/asm/processor.h | 2 + arch/arm/mm/mmap.c | 173 ++++++++++++++++++++++++++++++++++++- 3 files changed, 171 insertions(+), 5 deletions(-)
Quoted 4 lines
Russell,
I submitted these 2 patches to the patch system. Can you please pull into your next branch so they can get some more testing.
For the record, I included an earlier version of those patches in the Linaro kernel a week ago, and no breakage were reported so far.
Nicolas
PATCH v2 2/2 ARM: topdown mmap support
In reply to Rob HerringQuoted 7 lines · Rob Herring
From: Rob Herring <[email protected]>
Similar to other architectures, this adds topdown mmap support in user process address space allocation policy. This allows mmap sizes greater than 2GB. This support is largely copied from MIPS and the generic implementations.
Quoted 7 lines
The address space randomization is moved into
arch_pick_mmap_layout.Tested on V-Express with ubuntu and a mmap test from here:
https://bugs.launchpad.net/bugs/861296Signed-off-by Rob Herring <[email protected]>Acked-by Nicolas Pitre <[email protected]>
Unfortunately, we met "no vspace available" during loading libmono.so, when using default arch_get_unmapped_area_topdown method, tested on Jelly Bean with 3.4 kernel.
While no problem using arch_get_unmapped_area in the patch, or just revert this patch.
The result is some application can not run.
Just google, find same issue reported on Jelly Bean with 3.4 kernel.
Any suggestion?
Thanks
PATCH v2 2/2 ARM: topdown mmap support
Quoted 23 lines · zhangfei gao
Quoted 7 lines · Rob Herring
From: Rob Herring <[email protected]>
Similar to other architectures, this adds topdown mmap support in user process address space allocation policy. This allows mmap sizes greater than 2GB. This support is largely copied from MIPS and the generic implementations.
Quoted 7 lines
The address space randomization is moved into
arch_pick_mmap_layout.Tested on V-Express with ubuntu and a mmap test from here:
https://bugs.launchpad.net/bugs/861296Signed-off-by Rob Herring <[email protected]>Acked-by Nicolas Pitre <[email protected]>Unfortunately, we met "no vspace available" during loading libmono.so, when using default
arch_get_unmapped_area_topdownmethod, tested on Jelly Bean with 3.4 kernel.
While no problem usingarch_get_unmapped_areain the patch, or just revert this patch.
The result is some application can not run.
Quoted 3 lines
Just google, find same issue reported on Jelly Bean with 3.4 kernel.
Any suggestion?
Perhaps Android has hardcoded expectations about the virtual memory layout? I was worried about that at the time and asked the Linaro Android folks to test it.
I believe either layout can be selected at runtime per process. I don't recall the exact /proc file to control this.
Rob