Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2221227pxa; Mon, 3 Aug 2020 10:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTEExBjoPA/dvA2CnU3tXRbv+oECVF0eZjVKdN2UIwnk8N0JlHjovZVti6G7BNFNW0QxF+ X-Received: by 2002:a50:a6da:: with SMTP id f26mr16883300edc.4.1596475385920; Mon, 03 Aug 2020 10:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596475385; cv=none; d=google.com; s=arc-20160816; b=M1QMUuSA2RvrgnGdAZtWUvs4FcuUyvBT2yy4nCpVikNr0dR66bHmQiJrsJHrADQKwC NzRNPWdyhr8utKUN7L1oaQF0rZQKT0mDFdjdtIoypswt61996H47Ns8QzNsxITUscD50 SvKu80Vob/d2wWJo/a2plGPqlMDjiUgwyzuiyGFHP4LqLgT14H9RQPnEbwj5qXbZaSyJ 4glSmgWOTjkGz70p8Sg+bU7d/PUuXLz2O8jyvpahzf20MqqVDM4Jdg3aVvw6jfi5APqZ 9XXU2VaspMaPT7GfjakPzkcHGV13D1++jFJb51tBSS5pUCJuF4BHdH5XoPPhItL1jt/u W7rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=+TSlpUVu7WNnlNISfUgWL/yXjLC3z2JkLUIYFH9/0zg=; b=dUGOqP2jl59DjMsBnLJzmo1AjnjixHPd+NVfDLbkhJ9yQNQ4AcU+A0oN9mEoJcz3xC 1/I9cvmxFGNqU5O9jdFWQQC3wGRWX+tsf04C9e9Eq7C1sxcJWI+w297hAeexTI+eaG+q yO4h2SOg0DvNEQCpwBx35kMqKARJVoSBg/4FdhxX7j+MbzwjjW4qf9OuxkDKznA1hYor Wygr7oqiRKvHc9/SmXXFf+HQbMRMdlcL7+tI6ftWTxaR17XojbHd5qNqQESCffyOQbo2 NPjxHBoLeRiW/pqvnUd97f7fQyxDwBpj7EjawgjXHY3ghB9QhTGhN118VN8/Ht4ImlJN M6MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si10132153ejz.724.2020.08.03.10.22.42; Mon, 03 Aug 2020 10:23:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728269AbgHCRTr (ORCPT + 99 others); Mon, 3 Aug 2020 13:19:47 -0400 Received: from mga12.intel.com ([192.55.52.136]:57963 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbgHCRTr (ORCPT ); Mon, 3 Aug 2020 13:19:47 -0400 IronPort-SDR: fY6V27xfypH9r6Az8EPEF+QSxbLloTxwTbDmr6/9g0Jttp3F3btsrWKd9KeYMZ0CNl4zW5kiZy ioJTHr8widvg== X-IronPort-AV: E=McAfee;i="6000,8403,9702"; a="131727768" X-IronPort-AV: E=Sophos;i="5.75,430,1589266800"; d="scan'208";a="131727768" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2020 10:19:47 -0700 IronPort-SDR: KtHv35ANwZ8f7TkVfEpIBacjRUfJCoFDiYIqTEtwVJn0JL3JUXRZ6F9eqNCZZWvhjuk8Saq7H4 s4Ctke6jmV9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,430,1589266800"; d="scan'208";a="275358327" Received: from otcwcpicx6.sc.intel.com ([172.25.55.29]) by fmsmga008.fm.intel.com with ESMTP; 03 Aug 2020 10:19:47 -0700 Date: Mon, 3 Aug 2020 17:19:47 +0000 From: Fenghua Yu To: Andy Lutomirski Cc: Fenghua Yu , Thomas Gleixner , Joerg Roedel , Ingo Molnar , Borislav Petkov , Peter Zijlstra , H Peter Anvin , David Woodhouse , Lu Baolu , Felix Kuehling , Dave Hansen , Tony Luck , Jean-Philippe Brucker , Christoph Hellwig , Ashok Raj , Jacob Jun Pan , Dave Jiang , Sohil Mehta , Ravi V Shankar , linux-kernel , x86 , iommu , amd-gfx Subject: Re: [PATCH v6 12/12] x86/traps: Fix up invalid PASID Message-ID: <20200803171947.GA329474@otcwcpicx6.sc.intel.com> References: <1594684087-61184-1-git-send-email-fenghua.yu@intel.com> <1594684087-61184-13-git-send-email-fenghua.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Andy, On Fri, Jul 31, 2020 at 06:28:37PM -0700, Andy Lutomirski wrote: > On Mon, Jul 13, 2020 at 4:48 PM Fenghua Yu wrote: > > > > A #GP fault is generated when ENQCMD instruction is executed without > > a valid PASID value programmed in the current thread's PASID MSR. The > > #GP fault handler will initialize the MSR if a PASID has been allocated > > for this process. > > Let's take a step back here. Why are we trying to avoid IPIs? If you > call munmap(), you IPI other CPUs running tasks in the current mm. If > you do perf_event_open() and thus acquire RDPMC permission, you IPI > other CPUs running tasks in the current mm. If you call modify_ldt(), > you IPI other CPUs running tasks in the current mm. These events can > all happen more than once per process. > > Now we have ENQCMD. An mm can be assigned a PASID *once* in the model > that these patches support. Why not just send an IPI using > essentially identical code to the LDT sync or the CR4.PCE sync? ldt (or the other two cases) is different from ENQCMD: the PASID MSR is per-task and is supported by xsaves. The per-task PASID MSR needs to updated to ALL tasks. That means IPI, which only updates running tasks' MSRs, is not enough. All tasks' MSRs need to be updated when a PASID is allocated. This difference increases the complexity of sending IPI to running tasks and updating sleeping tasks's MSRs with locking etc. Of course, it's doable not to update the MSRs in all task when a new PASID is allocated to the mm. But that means we need to discard xsaves support for the MSR and create our own switch function to load the MSR. That increases complexity. We tried similar IPI way to update the PASID in about 200 lines of code. As Dave Hansen pointed, it's too complex. The current lazy updating the MSR only takes essential 3 lines of code in #GP. Does it make sense to still use the current fix up method to update the MSR? Thanks. -Fenghua