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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70CC4C43457 for ; Thu, 15 Oct 2020 04:13:22 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0565A22241 for ; Thu, 15 Oct 2020 04:13:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0565A22241 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1D94F159D0DD7; Wed, 14 Oct 2020 21:13:21 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=ira.weiny@intel.com; receiver= Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 242B0159D0DD5 for ; Wed, 14 Oct 2020 21:13:17 -0700 (PDT) IronPort-SDR: SSvRoCEYpp7tR/ebQvJ2ShO7nu+jAS0Lm36/SUChQUTFPqt7wIonNAOY4+/Y2OFlAqYOGqcKX5 ZBTv5XBM+hZA== X-IronPort-AV: E=McAfee;i="6000,8403,9774"; a="145561034" X-IronPort-AV: E=Sophos;i="5.77,377,1596524400"; d="scan'208";a="145561034" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 21:13:17 -0700 IronPort-SDR: Rl7k8n0kXpoNoqIwrMtUpN8XayQEpRNT0hviQBpmpRIMPeasyhZ2HMFjVvFRrQMIIhpfXjPBuY pHwulYaXA35w== X-IronPort-AV: E=Sophos;i="5.77,377,1596524400"; d="scan'208";a="531099549" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 21:13:16 -0700 Date: Wed, 14 Oct 2020 21:13:16 -0700 From: Ira Weiny To: Dave Hansen Subject: Re: [PATCH RFC V3 8/9] x86/fault: Report the PKRS state on fault Message-ID: <20201015041316.GR2046448@iweiny-DESK2.sc.intel.com> References: <20201009194258.3207172-1-ira.weiny@intel.com> <20201009194258.3207172-9-ira.weiny@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) Message-ID-Hash: GKHEVOMDUSUIPQGBHRYWS3UTFO7XDGXB X-Message-ID-Hash: GKHEVOMDUSUIPQGBHRYWS3UTFO7XDGXB X-MailFrom: ira.weiny@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Peter Zijlstra , x86@kernel.org, Dave Hansen , Andrew Morton , Fenghua Yu , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Tue, Oct 13, 2020 at 11:56:53AM -0700, Dave Hansen wrote: > > @@ -548,6 +549,11 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad > > (error_code & X86_PF_PK) ? "protection keys violation" : > > "permissions violation"); > > > > +#ifdef CONFIG_ARCH_HAS_SUPERVISOR_PKEYS > > + if (irq_state && (error_code & X86_PF_PK)) > > + pr_alert("PKRS: 0x%x\n", irq_state->pkrs); > > +#endif > > This means everyone will see 'PKRS: 0x0', even if they're on non-PKS > hardware. I think I'd rather have this only show PKRS when we're on > cpu_feature_enabled(PKS) hardware. Good catch, thanks. > > ... > > @@ -1148,14 +1156,15 @@ static int fault_in_kernel_space(unsigned long address) > > */ > > static void > > do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code, > > - unsigned long address) > > + unsigned long address, irqentry_state_t *irq_state) > > { > > /* > > - * Protection keys exceptions only happen on user pages. We > > - * have no user pages in the kernel portion of the address > > - * space, so do not expect them here. > > + * If protection keys are not enabled for kernel space > > + * do not expect Pkey errors here. > > */ > > Let's fix the double-negative: > > /* > * PF_PK is only expected on kernel addresses whenn > * supervisor pkeys are enabled: > */ done. thanks. > > > - WARN_ON_ONCE(hw_error_code & X86_PF_PK); > > + if (!IS_ENABLED(CONFIG_ARCH_HAS_SUPERVISOR_PKEYS) || > > + !cpu_feature_enabled(X86_FEATURE_PKS)) > > + WARN_ON_ONCE(hw_error_code & X86_PF_PK); > > Yeah, please stick X86_FEATURE_PKS in disabled-features so you can use > cpu_feature_enabled(X86_FEATURE_PKS) by itself here.. done. thanks, Ira _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org