From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754082AbcIILML (ORCPT ); Fri, 9 Sep 2016 07:12:11 -0400 Received: from terminus.zytor.com ([198.137.202.10]:43962 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753028AbcIILMH (ORCPT ); Fri, 9 Sep 2016 07:12:07 -0400 Date: Fri, 9 Sep 2016 04:10:39 -0700 From: tip-bot for Dave Hansen Message-ID: Cc: dave@sr71.net, linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org, dave.hansen@linux.intel.com, mgorman@techsingularity.net, tglx@linutronix.de Reply-To: dave@sr71.net, linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org, dave.hansen@linux.intel.com, mgorman@techsingularity.net, tglx@linutronix.de In-Reply-To: <20160729163010.DD1FE1ED@viggo.jf.intel.com> References: <20160729163010.DD1FE1ED@viggo.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:mm/pkeys] x86/pkeys: Add fault handling for PF_PK page fault bit Git-Commit-ID: e8c6226d483cb28f55cab718065ea1b7226d40e8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e8c6226d483cb28f55cab718065ea1b7226d40e8 Gitweb: http://git.kernel.org/tip/e8c6226d483cb28f55cab718065ea1b7226d40e8 Author: Dave Hansen AuthorDate: Fri, 29 Jul 2016 09:30:10 -0700 Committer: Thomas Gleixner CommitDate: Fri, 9 Sep 2016 13:02:26 +0200 x86/pkeys: Add fault handling for PF_PK page fault bit 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-arch@vger.kernel.org Cc: Dave Hansen Cc: arnd@arndb.de Cc: linux-api@vger.kernel.org Cc: linux-mm@kvack.org Cc: luto@kernel.org Cc: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org Link: http://lkml.kernel.org/r/20160729163010.DD1FE1ED@viggo.jf.intel.com Signed-off-by: Thomas Gleixner --- arch/x86/mm/fault.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index dc80230..b88d8ac 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1112,6 +1112,15 @@ access_error(unsigned long error_code, struct vm_area_struct *vma) { /* 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