From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 27 09:02:47 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 89A3B106566B for ; Thu, 27 Oct 2011 09:02:47 +0000 (UTC) (envelope-from dgre090@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 1AD0D8FC16 for ; Thu, 27 Oct 2011 09:02:46 +0000 (UTC) Received: by faar19 with SMTP id r19so3375598faa.13 for ; Thu, 27 Oct 2011 02:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=cCOQycGtz/F46Kno0WeHz62K1LY2y+5CALDPH9WgjoM=; b=JXPSKKsiRzJ5ziRUZV17OtQxU/n96Q/cTBEtns7sKjvjv2JFB4rs0NkNLdv5bKITlO mvT/cI+JwVC+CMH8vbq6mI7s0P5l/1xJGPSZvw5LOumlcgUgggn1J7FbiAi7tk2LAfsz w99/EBdBYsNjj3xcgX9u6YbqYJSpUukHAzNQU= MIME-Version: 1.0 Received: by 10.223.36.193 with SMTP id u1mr14514702fad.27.1319704303265; Thu, 27 Oct 2011 01:31:43 -0700 (PDT) Received: by 10.152.24.198 with HTTP; Thu, 27 Oct 2011 01:31:43 -0700 (PDT) Date: Thu, 27 Oct 2011 10:31:43 +0200 Message-ID: From: Daniel Grech To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: 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 09:02:47 -0000 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