Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Sep 2010 12:38:03 -0500
From:      Alan Cox <alan.l.cox@gmail.com>
To:        Svatopluk Kraus <onwahe@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: page table fault, which should map kernel virtual address space
Message-ID:  <AANLkTin6fPhb4R1T=99S1AT-sPk3He2akWf2taKUa2ry@mail.gmail.com>
In-Reply-To: <29760054.post@talk.nabble.com>
References:  <29760054.post@talk.nabble.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 20, 2010 at 9:32 AM, Svatopluk Kraus <onwahe@gmail.com> wrote:

>
> Hallo,
>
> this is about 'NKPT' definition, 'kernel_map' submaps,
> and 'vm_map_findspace' function.
>
> Variable 'kernel_map' is used to manage kernel virtual address
> space. When 'vm_map_findspace' function deals with 'kernel_map'
> then 'pmap_growkernel' function is called.
>
> At least in 'i386' architecture, pmap implementation uses
> 'pmap_growkernel' function to allocate missing page tables.
> Missing page tables are problem, because no one checks
> 'pte' pointer for validity after use of 'vtopte' macro.
>
> 'NKPT' definition defines a number of preallocated
> page tables during system boot.
>
> Beyond 'kernel_map', some submaps of 'kernel_map' (buffer_map,
> pager_map,...) exist as result of 'kmem_suballoc' function call.
> When this submaps are used (for example 'kmem_alloc_nofault'
> function) and its virtual address subspace is at the end of
> used kernel virtual address space at the moment (and above 'NKPT'
> preallocation), then missing page tables are not allocated
> and double fault can happen.
>
>
No, the page tables are allocated.  If you create a submap X of the kernel
map using kmem_suballoc(), then a vm_map_findspace() is performed by
vm_map_find() on the kernel map to find space for the submap X.  As you note
above, the call to vm_map_findspace() on the kernel map will call
pmap_growkernel() if needed to extend the kernel page table.

If you create another submap X' of X, then that submap X' can only map
addresses that fall within the range for X.  So, any necessary page table
pages were allocated when X was created.

That said, there may actually be a problem with the implementation of the
superpage_align parameter to kmem_suballoc().  If a submap is created with
superpage_align equal to TRUE, but the submap's size is not a multiple of
the superpage size, then vm_map_find() may not allocate a page table page
for the last megabyte or so of the submap.

There are only a few places where kmem_suballoc() is called with
superpage_align set to TRUE.  If you changed them to FALSE, that is an easy
way to test this hypothesis.

Regards,
Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTin6fPhb4R1T=99S1AT-sPk3He2akWf2taKUa2ry>