From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [PATCH 0/6] x86: 5-level paging enabling for v4.12, Part 1 Date: Tue, 14 Mar 2017 10:48:51 -0700 Message-ID: References: <20170313143309.16020-1-kirill.shutemov@linux.intel.com> <20170314074729.GA23151@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: <20170314074729.GA23151@gmail.com> Sender: owner-linux-mm@kvack.org To: Ingo Molnar Cc: "Kirill A. Shutemov" , Andrew Morton , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , Arnd Bergmann , "H. Peter Anvin" , Andi Kleen , Dave Hansen , Andy Lutomirski , Michal Hocko , "linux-arch@vger.kernel.org" , linux-mm , Linux Kernel Mailing List List-Id: linux-arch.vger.kernel.org On Tue, Mar 14, 2017 at 12:47 AM, Ingo Molnar wrote: > > I've also applied the GUP patch, with the assumption that you'll address Linus's > request to switch x86 over to the generic version. Note that switching over to the generic version is somewhat fraught with subtle issues: (a) we need to make sure that x86 actually matches the required semantics for the generic GUP. (b) we need to make sure the atomicity of the page table reads is ok. (c) need to verify the maximum VM address properly I _think_ (a) is ok. The code (and the config option name) talks about freeing page tables using RCU, but in fact I don't think it relies on it, and it's sufficient that it disables interrupts and that that will block any IPI's. In contrast, I think (b) needs real work to make sure it's ok on 32-bit PAE with 64-bit pte entries. The generic code currently just does READ_ONCE(), while the x86 code does gup_get_pte(). And (c) means that we need to really replace that generic code that does "access_ok()": with a proper check against maximum user address (ie independent of set_fs(KERNEL_DS)). But it would be good to aim for unifying this part of the VM, considering how many bugs we've had in GUP. The latest 5-level typo has not been the only one. It's clearly more subtle than you'd think. So it's not quite as simple as just "switching over". I think we need to introduce that gup_get_pte() to all the generic users, and we need to introduce a "user address limit" for those architectures too. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f67.google.com ([209.85.214.67]:34077 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbdCNRsx (ORCPT ); Tue, 14 Mar 2017 13:48:53 -0400 MIME-Version: 1.0 In-Reply-To: <20170314074729.GA23151@gmail.com> References: <20170313143309.16020-1-kirill.shutemov@linux.intel.com> <20170314074729.GA23151@gmail.com> From: Linus Torvalds Date: Tue, 14 Mar 2017 10:48:51 -0700 Message-ID: Subject: Re: [PATCH 0/6] x86: 5-level paging enabling for v4.12, Part 1 Content-Type: text/plain; charset=UTF-8 Sender: linux-arch-owner@vger.kernel.org List-ID: To: Ingo Molnar Cc: "Kirill A. Shutemov" , Andrew Morton , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , Arnd Bergmann , "H. Peter Anvin" , Andi Kleen , Dave Hansen , Andy Lutomirski , Michal Hocko , "linux-arch@vger.kernel.org" , linux-mm , Linux Kernel Mailing List Message-ID: <20170314174851.NS9jsCF5qlfp9HI45wkkpA2oOiT8JeylhQnOqVlm4-A@z> On Tue, Mar 14, 2017 at 12:47 AM, Ingo Molnar wrote: > > I've also applied the GUP patch, with the assumption that you'll address Linus's > request to switch x86 over to the generic version. Note that switching over to the generic version is somewhat fraught with subtle issues: (a) we need to make sure that x86 actually matches the required semantics for the generic GUP. (b) we need to make sure the atomicity of the page table reads is ok. (c) need to verify the maximum VM address properly I _think_ (a) is ok. The code (and the config option name) talks about freeing page tables using RCU, but in fact I don't think it relies on it, and it's sufficient that it disables interrupts and that that will block any IPI's. In contrast, I think (b) needs real work to make sure it's ok on 32-bit PAE with 64-bit pte entries. The generic code currently just does READ_ONCE(), while the x86 code does gup_get_pte(). And (c) means that we need to really replace that generic code that does "access_ok()": with a proper check against maximum user address (ie independent of set_fs(KERNEL_DS)). But it would be good to aim for unifying this part of the VM, considering how many bugs we've had in GUP. The latest 5-level typo has not been the only one. It's clearly more subtle than you'd think. So it's not quite as simple as just "switching over". I think we need to introduce that gup_get_pte() to all the generic users, and we need to introduce a "user address limit" for those architectures too. Linus