From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932669AbbIXRlN (ORCPT ); Thu, 24 Sep 2015 13:41:13 -0400 Received: from www.sr71.net ([198.145.64.142]:59330 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932621AbbIXRlK (ORCPT ); Thu, 24 Sep 2015 13:41:10 -0400 Subject: Re: [PATCH 10/26] x86, pkeys: notify userspace about protection key faults To: Ingo Molnar References: <20150916174903.E112E464@viggo.jf.intel.com> <20150916174906.51062FBC@viggo.jf.intel.com> <20150924092320.GA26876@gmail.com> <20150924093026.GA29699@gmail.com> Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andrew Morton , Peter Zijlstra , Thomas Gleixner From: Dave Hansen Message-ID: <560435B4.1010603@sr71.net> Date: Thu, 24 Sep 2015 10:41:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150924093026.GA29699@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/24/2015 02:30 AM, Ingo Molnar wrote: >> To answer your question in the comment: it looks useful to have some sort of >> 'extended page fault error code' information here, which shows why the page fault >> happened. With the regular error_code it's easy - with protection keys there's 16 >> separate keys possible and user-space might not know the actual key value in the >> pte. > > Btw., alternatively we could also say that user-space should know what protection > key it used when it created the mapping - there's no need to recover it for every > page fault. That's true. We don't, for instance, tell userspace whether it was a write that caused a fault. But, other than smaps we don't have *any* way to tell userspace what protection key a page has. I think some mechanism is going to be required for this to be reasonably debuggable. > OTOH, as long as we don't do a separate find_vma(), it looks cheap enough to look > up the pkey value of that address and give it to user-space in the signal frame. I still think that find_vma() in this case is pretty darn cheap, definitely if you compare it to the cost of the entire fault path. > Btw., how does pkey support interact with hugepages? Surprisingly little. I've made sure that everything works with huge pages and that the (huge) PTEs and VMAs get set up correctly, but I'm not sure I had to touch the huge page code at all. I have test code to ensure that it works the same as with small pages, but everything worked pretty naturally.