Virtual memory size detection for 64 bit MIPS CPUs
v6 cover Virtual memory size detection for 64 bit MIPS CPUs
This patchset addresses some of the most recent comments.
It does not address changes to TASK_SIZE, and it does not address replacing the VMALLOC_END macro with a variable. Those changes are non-trivial and will require more discussion and/or clarification.
PATCH v6 1/1 Virtual memory size detection for 64 bit MIPS CPUs
Linux kernel 2.6.32 and later allocates memory from the top of virtual memory space.
This patch implements virtual memory size detection for 64 bit MIPS CPUs to avoid resulting crashes.
--- arch/mips/include/asm/cpu-features.h | 7 +++++++ arch/mips/include/asm/cpu-info.h | 3 +++ arch/mips/include/asm/pgtable-64.h | 4 +++- arch/mips/kernel/cpu-probe.c | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletions(-)
arch/mips/include/asm/cpu-features.h +7 -0
@@ -191,6 +191,9 @@# ifndef cpu_has_64bit_addresses# define cpu_has_64bit_addresses 0# endif +# ifndef cpu_vmbits +# define cpu_vmbits 31 +# endif #endif #ifdef CONFIG_64BIT
@@ -209,6 +212,10 @@# ifndef cpu_has_64bit_addresses# define cpu_has_64bit_addresses 1# endif +# ifndef cpu_vmbits +# define cpu_vmbits cpu_data[0].vmbits +# define __NEED_VMBITS_PROBE +# endif #endif #if defined(CONFIG_CPU_MIPSR2_IRQ_VI ) && !defined(cpu_has_vint)
arch/mips/include/asm/cpu-info.h +3 -0
@@ -58,6 +58,9 @@ struct cpuinfo_mips {struct cache_desc tcache;/* Tertiary/split secondary cache */ int srsets;/* Shadow register sets */ int core;/* physical core number */ +#ifdef CONFIG_64BIT +int vmbits;/* Virtual memory size in bits */ +#endif #if defined(CONFIG_MIPS_MT_SMP ) || defined(CONFIG_MIPS_MT_SMTC )/* * In the MIPS MT "SMTC" model, each TC is considered
arch/mips/include/asm/pgtable-64.h +3 -1
@@ -110,7 +110,9 @@#define VMALLOC_START MAP_BASE#define VMALLOC_END \ (VMALLOC_START + \ - PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE - (1UL << 32)) + min(PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE, \ + (1UL << cpu_vmbits)) - (1UL << 32)) +#if defined(CONFIG_MODULES ) && defined(KBUILD_64BIT_SYM32 ) && \VMALLOC_START !=CKSSEG /* Load modules into 32bit-compatible segment. */
arch/mips/kernel/cpu-probe.c +11 -0
@@ -282,6 +282,15 @@ static inline int __cpu_has_fpu(void)return ((cpu_get_fpu_id () &0xff00 ) !=FPIR_IMP_NONE ); } +static inline void cpu_probe_vmbits (struct cpuinfo_mips *c) +{ +#ifdef __NEED_VMBITS_PROBE +write_c0_entryhi (0x3ffffffffffff000ULL ); +back_to_back_c0_hazard (); + c->vmbits =fls64 (read_c0_entryhi () &0x3ffffffffffff000ULL ); +#endif +} +#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \ | MIPS_CPU_COUNTER)
@@ -967,6 +976,8 @@ __cpuinit void cpu_probe(void) c->srsets = ((read_c0_srsctl () >>26 ) &0x0f ) +1 ; else c->srsets = 1; + +cpu_probe_vmbits (c); }__cpuinit void cpu_report (void )
Signature · 1 line
1.6.0.4
Quoted 7 lines · Guenter Roeck
Linux kernel 2.6.32 and later allocates memory from the top of virtual memory space.
This patch implements virtual memory size detection for 64 bit MIPS CPUs to avoid resulting crashes.
Signed-off-by Guenter Roeck <[email protected]>
Quoted 90 lines
--- arch/mips/include/asm/cpu-features.h | 7 +++++++ arch/mips/include/asm/cpu-info.h | 3 +++ arch/mips/include/asm/pgtable-64.h | 4 +++- arch/mips/kernel/cpu-probe.c | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletions(-)arch/mips/include/asm/cpu-features.h +7
-0@@ -191,6 +191,9 @@# ifndef cpu_has_64bit_addresses# define cpu_has_64bit_addresses 0# endif +# ifndef cpu_vmbits +# define cpu_vmbits 31 +# endif #endif #ifdef CONFIG_64BIT @@ -209,6 +212,10 @@# ifndef cpu_has_64bit_addresses# define cpu_has_64bit_addresses 1# endif +# ifndef cpu_vmbits +# define cpu_vmbits cpu_data[0].vmbits +# define __NEED_VMBITS_PROBE +# endif #endif #if defined(CONFIG_CPU_MIPSR2_IRQ_VI ) && !defined(cpu_has_vint)arch/mips/include/asm/cpu-info.h +3
-0@@ -58,6 +58,9 @@ struct cpuinfo_mips {struct cache_desc tcache;/* Tertiary/split secondary cache */ int srsets;/* Shadow register sets */ int core;/* physical core number */ +#ifdef CONFIG_64BIT +int vmbits;/* Virtual memory size in bits */ +#endif #if defined(CONFIG_MIPS_MT_SMP ) || defined(CONFIG_MIPS_MT_SMTC )/* * In the MIPS MT "SMTC" model, each TC is considered arch/mips/include/asm/pgtable-64.h +3
-1@@ -110,7 +110,9 @@#define VMALLOC_START MAP_BASE#define VMALLOC_END \ (VMALLOC_START + \ - PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE - (1UL << 32)) + min(PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE, \ + (1UL << cpu_vmbits)) - (1UL << 32)) +#if defined(CONFIG_MODULES ) && defined(KBUILD_64BIT_SYM32 ) && \VMALLOC_START !=CKSSEG /* Load modules into 32bit-compatible segment. */ arch/mips/kernel/cpu-probe.c +11
-0@@ -282,6 +282,15 @@ static inline int __cpu_has_fpu(void)return ((cpu_get_fpu_id () &0xff00 ) !=FPIR_IMP_NONE ); } +static inline void cpu_probe_vmbits (struct cpuinfo_mips *c) +{ +#ifdef __NEED_VMBITS_PROBE +write_c0_entryhi (0x3ffffffffffff000ULL ); +back_to_back_c0_hazard (); + c->vmbits =fls64 (read_c0_entryhi () &0x3ffffffffffff000ULL ); +#endif +} +#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \ | MIPS_CPU_COUNTER)@@ -967,6 +976,8 @@ __cpuinit void cpu_probe(void) c->srsets = ((read_c0_srsctl () >>26 ) &0x0f ) +1 ; else c->srsets = 1; + +cpu_probe_vmbits (c); }__cpuinit void cpu_report (void )
Quoted 3 lines · David Daney
Quoted 1 line
Signed-off-by Guenter Roeck <[email protected]>Reviewed-by David Daney <[email protected]>
Thanks for reviewing - as close as this to a release I appreciate a 2nd pair of eyes.
Applied and will go to Linus asap.
Thanks everybody,
Ralf
Quoted 5 lines · Guenter Roeck
This patchset addresses some of the most recent comments.
It does not address changes to
TASK_SIZE, and it does not address replacing theVMALLOC_ENDmacro with a variable. Those changes are non-trivial and will require more discussion and/or clarification.
I think I'm happy with doing these in followup patches. What's most important is sorting the whole issue soon so we can release a working 2.6.33.
Ralf