From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753292AbcG2Qah (ORCPT ); Fri, 29 Jul 2016 12:30:37 -0400 Received: from mga03.intel.com ([134.134.136.65]:1181 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751695AbcG2QaN (ORCPT ); Fri, 29 Jul 2016 12:30:13 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,440,1464678000"; d="scan'208";a="855940928" Subject: [PATCH 01/10] x86, pkeys: add fault handling for PF_PK page fault bit To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, luto@kernel.org, mgorman@techsingularity.net, Dave Hansen , dave.hansen@linux.intel.com, arnd@arndb.de From: Dave Hansen Date: Fri, 29 Jul 2016 09:30:10 -0700 References: <20160729163009.5EC1D38C@viggo.jf.intel.com> In-Reply-To: <20160729163009.5EC1D38C@viggo.jf.intel.com> Message-Id: <20160729163010.DD1FE1ED@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen PF_PK means that a memory access violated the protection key access restrictions. It is unconditionally an access_error() because the permissions set on the VMA don't matter (the PKRU value overrides it), and we never "resolve" PK faults (like how a COW can "resolve write fault). Signed-off-by: Dave Hansen Acked-by: Mel Gorman Cc: linux-api@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-mm@kvack.org Cc: x86@kernel.org Cc: torvalds@linux-foundation.org Cc: akpm@linux-foundation.org Cc: Arnd Bergmann --- b/arch/x86/mm/fault.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff -puN arch/x86/mm/fault.c~pkeys-105-add-pk-to-fault arch/x86/mm/fault.c --- a/arch/x86/mm/fault.c~pkeys-105-add-pk-to-fault 2016-07-29 09:18:55.920448993 -0700 +++ b/arch/x86/mm/fault.c 2016-07-29 09:18:55.923449129 -0700 @@ -1112,6 +1112,15 @@ access_error(unsigned long error_code, s { /* This is only called for the current mm, so: */ bool foreign = false; + + /* + * Read or write was blocked by protection keys. This is + * always an unconditional error and can never result in + * a follow-up action to resolve the fault, like a COW. + */ + if (error_code & PF_PK) + return 1; + /* * Make sure to check the VMA so that we do not perform * faults just to hit a PF_PK as soon as we fill in a _ From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: [PATCH 01/10] x86, pkeys: add fault handling for PF_PK page fault bit Date: Fri, 29 Jul 2016 09:30:10 -0700 Message-ID: <20160729163010.DD1FE1ED@viggo.jf.intel.com> References: <20160729163009.5EC1D38C@viggo.jf.intel.com> Return-path: In-Reply-To: <20160729163009.5EC1D38C@viggo.jf.intel.com> Sender: owner-linux-mm@kvack.org To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, luto@kernel.org, mgorman@techsingularity.net, Dave Hansen , dave.hansen@linux.intel.com, arnd@arndb.de List-Id: linux-api@vger.kernel.org From: Dave Hansen PF_PK means that a memory access violated the protection key access restrictions. It is unconditionally an access_error() because the permissions set on the VMA don't matter (the PKRU value overrides it), and we never "resolve" PK faults (like how a COW can "resolve write fault). Signed-off-by: Dave Hansen Acked-by: Mel Gorman Cc: linux-api@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-mm@kvack.org Cc: x86@kernel.org Cc: torvalds@linux-foundation.org Cc: akpm@linux-foundation.org Cc: Arnd Bergmann --- b/arch/x86/mm/fault.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff -puN arch/x86/mm/fault.c~pkeys-105-add-pk-to-fault arch/x86/mm/fault.c --- a/arch/x86/mm/fault.c~pkeys-105-add-pk-to-fault 2016-07-29 09:18:55.920448993 -0700 +++ b/arch/x86/mm/fault.c 2016-07-29 09:18:55.923449129 -0700 @@ -1112,6 +1112,15 @@ access_error(unsigned long error_code, s { /* This is only called for the current mm, so: */ bool foreign = false; + + /* + * Read or write was blocked by protection keys. This is + * always an unconditional error and can never result in + * a follow-up action to resolve the fault, like a COW. + */ + if (error_code & PF_PK) + return 1; + /* * Make sure to check the VMA so that we do not perform * faults just to hit a PF_PK as soon as we fill in a _ -- 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