From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: Re: [PATCHv3 33/33] mm, x86: introduce PR_SET_MAX_VADDR and PR_GET_MAX_VADDR Date: Fri, 17 Feb 2017 09:19:56 -0800 Message-ID: References: <20170217141328.164563-1-kirill.shutemov@linux.intel.com> <20170217141328.164563-34-kirill.shutemov@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170217141328.164563-34-kirill.shutemov-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: "Kirill A. Shutemov" , Linus Torvalds , Andrew Morton , x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Thomas Gleixner , Ingo Molnar , Arnd Bergmann , "H. Peter Anvin" Cc: Andi Kleen , Andy Lutomirski , linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Catalin Marinas , linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-arch.vger.kernel.org On 02/17/2017 06:13 AM, Kirill A. Shutemov wrote: > +/* > + * Default maximum virtual address. This is required for > + * compatibility with applications that assumes 47-bit VA. > + * The limit can be changed with prctl(PR_SET_MAX_VADDR). > + */ > +#define MAX_VADDR_DEFAULT ((1UL << 47) - PAGE_SIZE) This is a bit goofy. It's not the largest virtual adddress that can be accessed, but the beginning of the last page. Isn't this easier to deal with in userspace if we make it a "limit", so we can do: if (addr >= limit) // error Now, we have to do: prctl(PR_GET_MAX_VADDR, &max_vaddr, 0, 0, 0); if (addr > (max_vaddr + PAGE_SIZE)) // error I don't care what you track in the kernel, but I think we need to provide a more usable number out to userspace. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com ([192.55.52.120]:3175 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934122AbdBQRT5 (ORCPT ); Fri, 17 Feb 2017 12:19:57 -0500 Subject: Re: [PATCHv3 33/33] mm, x86: introduce PR_SET_MAX_VADDR and PR_GET_MAX_VADDR References: <20170217141328.164563-1-kirill.shutemov@linux.intel.com> <20170217141328.164563-34-kirill.shutemov@linux.intel.com> From: Dave Hansen Message-ID: Date: Fri, 17 Feb 2017 09:19:56 -0800 MIME-Version: 1.0 In-Reply-To: <20170217141328.164563-34-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: "Kirill A. Shutemov" , Linus Torvalds , Andrew Morton , x86@kernel.org, Thomas Gleixner , Ingo Molnar , Arnd Bergmann , "H. Peter Anvin" Cc: Andi Kleen , Andy Lutomirski , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Catalin Marinas , linux-api@vger.kernel.org Message-ID: <20170217171956.-j11pS15rRowLpP327ClUQtby1pEMpHEfF8bOS674OQ@z> On 02/17/2017 06:13 AM, Kirill A. Shutemov wrote: > +/* > + * Default maximum virtual address. This is required for > + * compatibility with applications that assumes 47-bit VA. > + * The limit can be changed with prctl(PR_SET_MAX_VADDR). > + */ > +#define MAX_VADDR_DEFAULT ((1UL << 47) - PAGE_SIZE) This is a bit goofy. It's not the largest virtual adddress that can be accessed, but the beginning of the last page. Isn't this easier to deal with in userspace if we make it a "limit", so we can do: if (addr >= limit) // error Now, we have to do: prctl(PR_GET_MAX_VADDR, &max_vaddr, 0, 0, 0); if (addr > (max_vaddr + PAGE_SIZE)) // error I don't care what you track in the kernel, but I think we need to provide a more usable number out to userspace.