linux-mips
[Top] [All Lists]

Re: [PATCH v4] Virtual memory size detection for 64 bit MIPS CPUs

To: Guenter Roeck <guenter.roeck@ericsson.com>
Subject: Re: [PATCH v4] Virtual memory size detection for 64 bit MIPS CPUs
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Date: Tue, 02 Feb 2010 13:04:24 +0300
Cc: linux-mips@linux-mips.org
In-reply-to: <1265068979-12052-1-git-send-email-guenter.roeck@ericsson.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1265068979-12052-1-git-send-email-guenter.roeck@ericsson.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)
Hello.

Guenter Roeck wrote:

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 <guenter.roeck@ericsson.com>

[...]

diff --git a/arch/mips/include/asm/pgtable-64.h 
b/arch/mips/include/asm/pgtable-64.h
index 9cd5089..259ec58 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -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))

Why you've added spaces around the second << but not around the first? Should be more consistent.

+
 #if defined(CONFIG_MODULES) && defined(KBUILD_64BIT_SYM32) && \
        VMALLOC_START != CKSSEG
 /* Load modules into 32bit-compatible segment. */
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 7a51866..ac9aca1 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -282,6 +282,16 @@ static inline int __cpu_has_fpu(void)
        return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
 }
+static inline void cpu_set_vmbits(struct cpuinfo_mips *c)
+{
+       if (cpu_has_64bits) {
+               write_c0_entryhi(0xfffffffffffff000ULL);
+               back_to_back_c0_hazard();
+               c->vmbits = fls64(read_c0_entryhi() & 0x3ffffffffffff000ULL);

I don't quite understand why set bits 62-63 only to mask them off later...

WBR, Sergei



<Prev in Thread] Current Thread [Next in Thread>