From owner-freebsd-current@FreeBSD.ORG Tue Mar 30 18:01:46 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E7B2106564A for ; Tue, 30 Mar 2010 18:01:46 +0000 (UTC) (envelope-from drbaud@yahoo.com) Received: from web65613.mail.ac4.yahoo.com (web65613.mail.ac4.yahoo.com [76.13.9.81]) by mx1.freebsd.org (Postfix) with SMTP id D4ED48FC08 for ; Tue, 30 Mar 2010 18:01:45 +0000 (UTC) Received: (qmail 2347 invoked by uid 60001); 30 Mar 2010 17:35:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1269970504; bh=sTp0a5HH6YlGoM3nQ2gR6BwLZRy2zUyh3yE9JkPL6fQ=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=5DCzrpcmUCnF9P7AxK80ehPkHBOSBtkZXyBNp6hxufoHaMBSIGX3FobUjV1TRgqpb5WlmvnHbssmqu/zitGYGrl8BrhFu52Ksc1V2serMJaOK814bb4oo1md0Dwmk0hjgW+isn2/ePYs/zh5bjll3Yk5X2ZLk2PQFebB8FiyBsg= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=rMdIHGM7e/aK+wJ28cch8pg1Nqje1pi+D/8tahjoPsBwye4RRfEJ5wM0VdfoAeTOGY+k3SD/W1cEcGoGmlqd820V1+OZCxUI5xTqSDlzMUYHLFGymIkB7DjLdgl/vnOsfwk3gxl6Sc7xxmHyW1YqQ7CQPlDLafV9juMUUxGtEgw=; Message-ID: <745921.1949.qm@web65613.mail.ac4.yahoo.com> X-YMail-OSG: vCLmAzoVM1lwSiGAPTv4Dvg9qyaPe3hQSlvgS7pqUZtMOgK 00UyeVyDW3giZIXIkCAbRG6wBQJFtXK.KDB3Po9C4ZrckuxqNaFw75ciDoW5 XF33gXW33k776dkc4v1hBYG8Yt_Jq5r6HTQaZ8FKW8i0kFXKku3j5ypqFtl1 f7aOuDkZ1PPoMY0f9mnZfxKdd0Em3q_gAaFi18GOXAVUZpL.9jsRbFfKuDeb ePyukRXncPIVQtdWTanuE6e9AkyyFaiVhH7zFybMcfGXlBdwtii2dwdhJLnB 06JGiZBzX8EHGqQCqzSCRtPA2NaVDQBkeDkG.DVOuSezqxo_.qOCsKA-- Received: from [64.238.244.146] by web65613.mail.ac4.yahoo.com via HTTP; Tue, 30 Mar 2010 10:35:04 PDT X-Mailer: YahooMailClassic/10.0.8 YahooMailWebService/0.8.100.260964 Date: Tue, 30 Mar 2010 10:35:04 -0700 (PDT) From: "Dr. Baud" To: freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailman-Approved-At: Tue, 30 Mar 2010 18:11:22 +0000 Subject: pmap_extract question X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2010 18:01:46 -0000 Say I have a kernel module that allocates a contiguous chunk of kernel physical memory (note that a call to vtophys() reports a non-zero value): memory_chunk = contigmalloc( memory_chunk_length, NULL, M_NOWAIT, 0UL, ~0UL, PAGE_SIZE, 0); The kernel virtual address returned from contigmalloc is passed to a user application which maps the chunk to the virtual address space of the application: fd = open("/dev/mem", O_RDWR); mapped_memory_chunk = mmap( NULL, memory_chunk_length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t) memory_chunk); Now consider that the mapped memory chunk address is then passed back to the kernel module. My question is; shouldn't pmap_extract(9) be able to determine the physical address? struct thread *td = curthread; pmap_t pmap = &td->td_proc->p_vmspace->vm_pmap; physical_address = pmap_extract(pmap, mapped_memory_chunk); In this example pmap_extract returns 0. Note also that /proc//map indicates the page(s) associated with the virtual addresses are not resident, e.g.: 0x801731000 0x801732000 0 0 0xffffff01d1ecd360 rw- 10 0 0x1000 NCOW NNC device - The first two values shown are the start (address returned from mmap above) and end addresses. The third, in this case zero, is intended to represent whether the pages are in resident. This value is simply the result of a call to pmap_extract. Is this to be expected? Should mmap(2) serve up a virtual address which pmap_extract cannot determine the physical address? Or is there a flaw in this logic? Thanks in advance...... Dr