From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 27 13:20:09 2011 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 9241A1065672 for ; Thu, 27 Oct 2011 13:20:09 +0000 (UTC) (envelope-from marktinguely@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 587CD8FC1C for ; Thu, 27 Oct 2011 13:20:09 +0000 (UTC) Received: by iaky10 with SMTP id y10so4478308iak.13 for ; Thu, 27 Oct 2011 06:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=8NEZ/gEniMSSLogxOYKKBiffU779IOCrlMRRNZKaBMY=; b=opDJG906tvFrHxXSPwZa/pGJ3jP5Q0k01ilHEjEpjrOt6q5pbB3u0spr3DAS0Go8UD 3NRcQMDdxJU+O2UYqnAMCuJ+CCcRiSu9zF6bkAZlswjj/w38egJG1FNK7tdd4Tu204Zz tkJx/EKEIx6lRqGhw6/RAluP8Yl88iu5PVfUs= Received: by 10.42.197.73 with SMTP id ej9mr59411265icb.2.1319720126283; Thu, 27 Oct 2011 05:55:26 -0700 (PDT) Received: from [192.168.1.100] ([216.129.185.155]) by mx.google.com with ESMTPS id en6sm1725651igb.0.2011.10.27.05.55.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Oct 2011 05:55:25 -0700 (PDT) Message-ID: <4EA954B7.7070205@gmail.com> Date: Thu, 27 Oct 2011 07:55:19 -0500 From: Mark Tinguely User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: Daniel Grech References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: Kernel Space Memory Allocation 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: Thu, 27 Oct 2011 13:20:09 -0000 On 10/27/2011 3:31 AM, Daniel Grech wrote: > Hi, > > I am allocating memory from a device driver in the kernel and passing it on > to another driver. In the other driver it is neccessary for me to determine > whether the address passed is from user space or kernel space as this driver > can also be called from user space. I am currently using the following check > to determine if the address is in kernel space or userspace : > > if ( ( (char *) VM_MIN_KERNEL_ADDRESS<= address)&& (address<= (char *) > VM_MAX_KERNEL_ADDRESS) ) > { > KERNEL SPACE > } > else > { > USER SPACE > } > > However, this does not always work. Sometimes although I allocate memory in > the kernel using the malloc macro, this returns an address which is not in > the above range. Is there any workaround for this problem? > > Thanks in advance for your help. > > Daniel > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > Be careful if using user virtual addresses in DMA POST commands, because the interrupt handler may not have the the same address space as the caller. For example: BUS_DMASYNC_POSTREAD copying a bounce buffer to a user VA. --Mark Tinguely