From owner-freebsd-hackers@FreeBSD.ORG Tue Sep 21 17:38:05 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3EDCE106566C for ; Tue, 21 Sep 2010 17:38:05 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id E2D2B8FC0A for ; Tue, 21 Sep 2010 17:38:04 +0000 (UTC) Received: by qwg5 with SMTP id 5so5056479qwg.13 for ; Tue, 21 Sep 2010 10:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:reply-to :in-reply-to:references:date:message-id:subject:from:to:cc :content-type; bh=5YcA9YnxRLob+EkNSsDAfiFOqL0XGqBpCUn90J2fFzo=; b=pUN0vbd+f81WarS7gKbP2B8I051VTfs2aF0GV2kgibv4shb0H5KeppQ4EApPkiGaP6 F3KMe4p8Arrk4qC3FXxQt5rTbdfxOcFscM0VDZtHXBqkRYzQM6bbMeSFaiWM0dwt3pLI uV39nljmtj5CeZ5cOuugDEz8Im8gwY0oJOqSM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=nmyFUGSta3JhT4rt96AkAf2YGcjloUK1K0pMizEvJz7XUaszYojKeonoUPTeAcGrWp 4bO180Dsgyah8P8RpNCz2iBcjzOCV+gk3NJW2aXEbnqdlp1z6b/mkNKrdu4CMUP0Da/o 73+/nXqadvnnazltTTdhSPwkCFQgF7utz5awY= MIME-Version: 1.0 Received: by 10.229.191.135 with SMTP id dm7mr7722109qcb.29.1285090683991; Tue, 21 Sep 2010 10:38:03 -0700 (PDT) Received: by 10.229.37.85 with HTTP; Tue, 21 Sep 2010 10:38:03 -0700 (PDT) In-Reply-To: <29760054.post@talk.nabble.com> References: <29760054.post@talk.nabble.com> Date: Tue, 21 Sep 2010 12:38:03 -0500 Message-ID: From: Alan Cox To: Svatopluk Kraus Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: page table fault, which should map kernel virtual address space X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: alc@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2010 17:38:05 -0000 On Mon, Sep 20, 2010 at 9:32 AM, Svatopluk Kraus 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