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=-2.5 required=3.0 tests=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 AA24DC433E1 for ; Fri, 26 Jun 2020 18:16:48 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 8FF78206DD for ; Fri, 26 Jun 2020 18:16:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FF78206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4DDE487DA1; Fri, 26 Jun 2020 18:16:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fqRVF5EHEfTa; Fri, 26 Jun 2020 18:16:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id A768887BA6; Fri, 26 Jun 2020 18:16:47 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9249AC0863; Fri, 26 Jun 2020 18:16:47 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id E405AC016F for ; Fri, 26 Jun 2020 18:16:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D3A0E87C6F for ; Fri, 26 Jun 2020 18:16:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ikgc3JlZDFNl for ; Fri, 26 Jun 2020 18:16:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id 3986E876BF for ; Fri, 26 Jun 2020 18:16:45 +0000 (UTC) IronPort-SDR: gmjsqMd0PWQc5xwgXgL8dLUwUIcdbWkj7w8TsCfn0cDPPaBhVERWZbS2OaOVsJlIIuQKDlWFuv IKGOFQSMzV1w== X-IronPort-AV: E=McAfee;i="6000,8403,9664"; a="142927736" X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="142927736" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 11:16:44 -0700 IronPort-SDR: LrvGyNnpWX6ik5OFFqZoBMW0OQOmmNpAFfodvXeT2j9bQlZKueLItipolrt/V64t2tcadV1dna D9NzoyBXgSJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="385835873" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga001.fm.intel.com with ESMTP; 26 Jun 2020 11:16:44 -0700 Date: Fri, 26 Jun 2020 11:16:24 -0700 From: Fenghua Yu To: Peter Zijlstra Subject: Re: [PATCH v4 12/12] x86/traps: Fix up invalid PASID Message-ID: <20200626181624.GA32961@romley-ivt3.sc.intel.com> References: <1593116242-31507-1-git-send-email-fenghua.yu@intel.com> <1593116242-31507-13-git-send-email-fenghua.yu@intel.com> <20200626094450.GJ4800@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200626094450.GJ4800@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Jean-Philippe Brucker , Tony Luck , Dave Jiang , Ashok Raj , Ravi V Shankar , x86 , linux-kernel , Dave Hansen , iommu@lists.linux-foundation.org, Ingo Molnar , Borislav Petkov , Jacob Jun Pan , H Peter Anvin , Christoph Hellwig , Thomas Gleixner , David Woodhouse X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" Hi, Peter, On Fri, Jun 26, 2020 at 11:44:50AM +0200, Peter Zijlstra wrote: > On Thu, Jun 25, 2020 at 01:17:22PM -0700, Fenghua Yu wrote: > > > +static bool fixup_pasid_exception(void) > > +{ > > + if (!IS_ENABLED(CONFIG_INTEL_IOMMU_SVM)) > > + return false; > > + if (!static_cpu_has(X86_FEATURE_ENQCMD)) > > + return false; > > elsewhere you had another variation: > > + if (!IS_ENABLED(CONFIG_INTEL_IOMMU_SVM)) > + return; > + > + if (!cpu_feature_enabled(X86_FEATURE_ENQCMD)) > + return; > > Which is it, and why do we need the CONFIG thing when combined with the > enabled thing? > I will use the second one with cpu_feature_enabled() for both cases. The CONFIG thing is for compilation time optimization when CONFIG_INTEL_IOMMU_SVM is not set. If CONFIG_INTEL_IOMMU_SVM is not set, IS_ENABLED(CONFIG_INTEL_IOMMU_SVM) is "false" during compilation time. Then GCC will optimize fixup_pasid_execption() to empty and will not define __fixup_pasid_exception() at all because no one calls it. If CONFIG_INTEL_IOMMU_SVM is set, IS_ENABLED(...) is always true. Depending on cpu_feature_enabled(X86_FEATURE_ENQCMD), __fixup_pasid_execption() will be called or not during run time. Does it make sense? Do you want me to define a helper enqcmd_enabled()? static inline bool enqcmd_enabled(void) { if (!IS_ENABLED(CONFIG_INTEL_IOMMU_SVM)) return false; if (!static_cpu_has(X86_FEATURE_ENQCMD)) return false; return true; } Then both fixup_pasid_execption() and free_pasid() can call it. static bool fixup_pasid_exception(void) { if (!enqcmd_enabled()) return false; return __fixup_pasid_exception(); } statis inline void free_pasid(struct m_struct *mm) { if (!enqcmd_enabled()) return; __free_pasid(mm); } Please advice. -Fenghua _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu