Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934290AbcCIWDC (ORCPT ); Wed, 9 Mar 2016 17:03:02 -0500 Received: from mga02.intel.com ([134.134.136.20]:52194 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754166AbcCIWAM (ORCPT ); Wed, 9 Mar 2016 17:00:12 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,312,1455004800"; d="scan'208";a="666666901" Subject: [PATCH 2/9] x86, pkeys: add fault handling for PF_PK page fault bit To: linux-kernel@vger.kernel.org Cc: Dave Hansen , dave.hansen@linux.intel.com From: Dave Hansen Date: Wed, 09 Mar 2016 14:00:11 -0800 References: <20160309220008.D61AF421@viggo.jf.intel.com> In-Reply-To: <20160309220008.D61AF421@viggo.jf.intel.com> Message-Id: <20160309220011.D39177BC@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1190 Lines: 35 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 --- 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-03-09 13:55:19.682431296 -0800 +++ b/arch/x86/mm/fault.c 2016-03-09 13:55:19.685431432 -0800 @@ -1121,6 +1121,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 _