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.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 17E19C433E7 for ; Thu, 15 Oct 2020 04:13:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B349221FF for ; Thu, 15 Oct 2020 04:13:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B349221FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B9D576B0068; Thu, 15 Oct 2020 00:13:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4DA56B0070; Thu, 15 Oct 2020 00:13:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3C686B0071; Thu, 15 Oct 2020 00:13:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id 76BDB6B0068 for ; Thu, 15 Oct 2020 00:13:20 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 119308249980 for ; Thu, 15 Oct 2020 04:13:20 +0000 (UTC) X-FDA: 77372840160.03.thumb22_0c0022427211 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id C6CBA28A4E8 for ; Thu, 15 Oct 2020 04:13:19 +0000 (UTC) X-HE-Tag: thumb22_0c0022427211 X-Filterd-Recvd-Size: 3999 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 04:13:18 +0000 (UTC) IronPort-SDR: 8w3YqrF4qmgvVO46vMYLvi03Rz1wPDHtq4G5IlsYLnKaORdW5Qi9+nky/0VZIXFz2xj9N129H2 aXlKHUEzE/cg== X-IronPort-AV: E=McAfee;i="6000,8403,9774"; a="146122256" X-IronPort-AV: E=Sophos;i="5.77,377,1596524400"; d="scan'208";a="146122256" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.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 Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Peter Zijlstra , x86@kernel.org, Dave Hansen , Dan Williams , 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 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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