From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 1 14:06:20 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E3F6D16A420; Wed, 1 Mar 2006 14:06:20 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id B563243D48; Wed, 1 Mar 2006 14:06:19 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from pm513-1.comsys.ntu-kpi.kiev.ua (pm513-1.comsys.ntu-kpi.kiev.ua [10.18.52.101]) (authenticated bits=0) by comsys.ntu-kpi.kiev.ua (8.12.10/8.12.10) with ESMTP id k21EJNVO001722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 1 Mar 2006 16:19:26 +0200 (EET) Received: by pm513-1.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1001) id 988405C023; Wed, 1 Mar 2006 16:06:35 +0200 (EET) Date: Wed, 1 Mar 2006 16:06:35 +0200 From: Andrey Simonenko To: John Baldwin Message-ID: <20060301140635.GA669@pm513-1.comsys.ntu-kpi.kiev.ua> References: <20060227183142.GJ840@funkthat.com> <200602281333.49277.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200602281333.49277.jhb@freebsd.org> User-Agent: Mutt/1.5.11 X-Virus-Scanned: ClamAV 0.82/1293/Sun Feb 19 18:40:25 2006 on comsys.ntu-kpi.kiev.ua X-Virus-Status: Clean Cc: freebsd-hackers@freebsd.org Subject: Re: Accessing address space of a process through kld!! X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Mar 2006 14:06:21 -0000 On Tue, Feb 28, 2006 at 01:33:47PM -0500, John Baldwin wrote: > On Monday 27 February 2006 13:31, John-Mark Gurney wrote: > > Tanmay wrote this message on Mon, Feb 27, 2006 at 13:56 +0530: > > > How do I access the address space ie text,data and stack of a (user > > > level)process whose pid I know from my kld. for eg: Suppose 'vi' is running > > > and I want to access its address space through my kld, then how do I do it? > > > > You look up the process with pfind(9), and then you can use uio(9) to > > transfer data into kernel space... Don't forget to PROC_UNLOCK the > > struct once you are done referencing it. > > You can use the proc_rwmem() function (it takes a uio and a struct proc) > to do the actual I/O portion. You can see example use in the ptrace() > syscall. I have two questions about this function: 1. vm_fault() does not guarantee, that (possibly) faulted in page will be in the object or in one of backing objects when vm_fault() returns, because a page can become not resident again. Why not to wire needed page in vm_fault() (by giving a special flag to vm_fault() function)? 2. When the object which owns the page is unlocked, which lock guarantees, then m will point to a page? I mean m, which is used in vm_page_hold(m), which is called after VM_OBJECT_UNLOCK() (I mean a gap of time between VM_OBJECT_UNLOCK() and vm_page_lock_queues() function calls). Can you answer these two question? Thanks.