From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D224C433F5 for ; Fri, 18 Feb 2022 06:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbiBRGBl (ORCPT ); Fri, 18 Feb 2022 01:01:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbiBRGBh (ORCPT ); Fri, 18 Feb 2022 01:01:37 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5CE626512B for ; Thu, 17 Feb 2022 22:01:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645164080; x=1676700080; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=WIaZmEHzMxcJvoDjxKbAEPF9S2X6WO7L8fWfrnJriR8=; b=L0090UBv+xR/lkb5JTOeY344iLTd2n08Hx9BgQKvajpH/ejzSPp25+9r KN7a2n68ImZYl4MH2O14ZWek7uL01LzKCfkMerZH+WUcLLJlaiAJaz68B fIAieSzQNKPAfR1jUvqcDKK672V6/augx4m+enDkbIJlKB6wHnbYUprAB vCpov+NZP0qSvhn3X5AQsiNYBvEoYU1HKcHBU7lb4ctuD3xVpgYiPvOT7 yLNM9PoA8CEkgCCDajN2NRcNR/uQumM8ZWJFhqOS0aXp8ng4JQ349nU34 qD1JxhPb2BuMTIgLnjeke87wbKzrl9YTsqiirhcS4C8GVdtIE4DaXsK6U w==; X-IronPort-AV: E=McAfee;i="6200,9189,10261"; a="238463423" X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="238463423" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 22:01:20 -0800 X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="605453730" Received: from rbfawkes-mobl1.amr.corp.intel.com (HELO localhost) ([10.212.127.120]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 22:01:19 -0800 Date: Thu, 17 Feb 2022 22:01:19 -0800 From: Ira Weiny To: "Edgecombe, Rick P" Cc: "hpa@zytor.com" , "Williams, Dan J" , "dave.hansen@linux.intel.com" , "Yu, Fenghua" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V8 26/44] x86/fault: Print PKS MSR on fault Message-ID: References: <20220127175505.851391-1-ira.weiny@intel.com> <20220127175505.851391-27-ira.weiny@intel.com> <2a919d9ed8ed874f8b89014c0b42cbadb44d837b.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2a919d9ed8ed874f8b89014c0b42cbadb44d837b.camel@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 01, 2022 at 10:13:40AM -0800, Edgecombe, Rick P wrote: > On Thu, 2022-01-27 at 09:54 -0800, ira.weiny@intel.com wrote: > > + if (error_code & X86_PF_PK) > > + pks_dump_fault_info(regs); > > + > > If the kernel makes an errant accesses to a userspace address with PKU > enabled and the usersapce page marked AD, it should oops and get here, > but will the X86_PF_PK bit be set even if smap is the real cause? Per > the SDM, it sounds like it would: > " > For accesses to user-mode addresses, the flag is set if > (1) CR4.PKE = 1; > (2) the linear address has protection key i; and > (3) the PKRU register (see Section 4.6.2) is such that either > (a) ADi = 1; or > (b) the following all hold: > (i) WDi = 1; > (ii) the access is a write access; and > (iii) either CR0.WP = 1 or the access causing the > page-fault exception was a user-mode access. > " > > ...and then this somewhat confusingly dumps the pks register. Is that > the real behavior? Are you suggesting the PKRU should be printed instead or in addition to the PKS? AFAICS this really should not present a problem even if the fault is due to a user pkey violation. It is simply extra information. Ira