Date: Thu, 12 Jan 2012 15:58:16 +0530 From: "Jayachandran C." <c.jayachandran@gmail.com> To: Alan Cox <alc@rice.edu> Cc: Oleksandr Tymoshenko <gonzo@freebsd.org>, "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org> Subject: Re: MIPS64 modules Message-ID: <CA%2B7sy7At32450%2BpXP3%2BdY=AEfm5aX2F9__dUO%2BHQOFYwfYQusA@mail.gmail.com> In-Reply-To: <4F0E9A31.5070401@rice.edu> References: <4F0E1965.6060808@freebsd.org> <CA%2B7sy7DLLpOJRLM646PprS_EcCm64QrEKpyrf2rut=uAJy4Ygg@mail.gmail.com> <4F0E9A31.5070401@rice.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 12, 2012 at 2:00 PM, Alan Cox <alc@rice.edu> wrote: > On 01/12/2012 01:50, Jayachandran C. wrote: >> >> On Thu, Jan 12, 2012 at 4:51 AM, Oleksandr Tymoshenko<gonzo@freebsd.org> >> =A0wrote: >>> >>> =A0 =A0Modules on MIPS use the same interface as AMD64 modules: >>> sys/kern/link_elf_obj.c. It works for MIPS32 but there is a problem >>> with MIPS64. sys/kern/link_elf_obj.c calls vm_map_find that uses >>> KERNBASE as a map base. As I told - it works for mips32 because >>> KERNBASE for mips32 is located before actual virtual memory area >>> (KERNBASE points to directly-mapped KSEG0 segment). But for MIPS64 >>> it's not the case - KERNBASE points to the very end of address space >>> and vm_map_find fails. >>> >>> Using VM_MIN_KERNEL_ADDRESS fixes this problem. So the question is - >>> what should I do? Add #ifdef to link_elf_obj.c as in kmem_init in >>> vm/vm_kern.c or change KERNBASE to VM_MIN_KERNEL_ADDRESS? >> >> This is probably the right fix for both 32 and 64-bit mips. Using a >> KSEG0 address as argument for vm_map_find is not correct as the kernel >> map does not include that region for mips. >> >> This reminds me of another issue I had seen in kern/link_elf.c, the >> value of linker_kernel_file->address is also set to KERNBASE, but this >> really should be KERNLOADADDR (used in our conf files) for mips. > > I was somewhat surprised to find that KERNBASE points to the direct map. > =A0What is the virtual address range for a running kernel's code and data > segments? =A0In other words, are the kernel code and data segments access= ed > through the direct map even after initialization? Yes, this direct map (KSEG0 in 32bit and CKSEG0 in 64bit) maps the first 512MB physical memory and is outside the VM_MIN_KERNEL_ADDRESS - VM_MAX_KERNEL_ADDRESS range. KERNBASE points to the start of this direct map. In 64 bit, there are a few more direct maps (XKPHYS) which maps the whole physical memory (location depends on the caching needed). We use this when we need a direct mapped pointer (by MIPS_PHYS_TO_DIRECT) in 64 bit. This is also outside the kernel min and max vm. JC.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B7sy7At32450%2BpXP3%2BdY=AEfm5aX2F9__dUO%2BHQOFYwfYQusA>