Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1885497ybt; Mon, 15 Jun 2020 11:57:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr/xsYmbHReRtJuO2qKxyjGzHvh0emd+e/ttLYtSs3qWT5M/t1Uh2wuAdnev+ZtprhqXPM X-Received: by 2002:a50:8425:: with SMTP id 34mr25429899edp.314.1592247460392; Mon, 15 Jun 2020 11:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592247460; cv=none; d=google.com; s=arc-20160816; b=dOVoetsXMPz6dKsGf36agCwuU62nFTxvQvJLwztfPYge76clcIYdmkwQzXJOvFQIWa 3eyUpshurr3uKb9Cvdig8OZffdU63LqQ5+tUeUnwd4FTfG0+lKNJZd3F1DJp0RVBNlPZ NSEME4VvUXF4ufZXfQz5LhHEGgznAJkj9AWu/EowmY2ZvMZNoMCygDErfUTkqnwYVXPF WZwJ9qZZTkFPqrjsrwXw+O3qPdwzl4ZGmtfEB1Q4eDF5iGJINtunY0Eww5esuml7+TXC J4nej1T9IIwXhaLG8mGoYy2lRI+dASDGMCUPNds7dNcRj9oJRGa5erRYqtcbI/MXFYNv 50Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=R57hWvp4jFC+TiFbxEtHWQ3f36xe6SYj+0xCAlPJRuY=; b=IMYvglDf11zVer2uE+GqoNgty0oY++3ai+ljVyExm6Y+iFwdpDAr8lNmzI6micIylW RkDEvdDMtcaK0A4g5p9sRF1Lxt3GK59kiOq8JTsC1208sSC254aY/Tu9O+3QUySs8ZjK +wCkyJB/CDrmeowIB9uPq6rVXUgwUL+OtGIlT8Ty6gfSkiyhjY3LySoydQfk2HV3X18g yBupF7mxfrU93AiPa8NsV2HoBcB0E1aUiZkkRE86rleblBZBXyP0KAVS2OpQlcSJyB7b xqQCmx8vUf3r9Hnh93zPofHJo/T3LbYaAIT4NbjrlPb04fCLTwutf3vqByKUjiQBSNm6 BLow== 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 u20si9092563eda.569.2020.06.15.11.57.17; Mon, 15 Jun 2020 11:57:40 -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 S1731249AbgFOSza (ORCPT + 99 others); Mon, 15 Jun 2020 14:55:30 -0400 Received: from mga18.intel.com ([134.134.136.126]:26684 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729124AbgFOSza (ORCPT ); Mon, 15 Jun 2020 14:55:30 -0400 IronPort-SDR: PhvyGmyayz3iqNJYwVmFWTmtOB4+XuvmJ+R5Y3qbr8ozyD+7ADT6RSbrMHHeeMSt3w8T1gXS5d NMMI64KFzXhA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2020 11:55:29 -0700 IronPort-SDR: 7AOfFl+Q9Zk9+pLDv+ctsLfdexol4Ooa9fms1lqtuvgDaDmflZdjgu5bI2sLLO96QFzKhPty0n Vry9GVkoZi+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,515,1583222400"; d="scan'208";a="382630204" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga001.fm.intel.com with ESMTP; 15 Jun 2020 11:55:30 -0700 Date: Mon, 15 Jun 2020 11:55:29 -0700 From: Fenghua Yu To: Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , David Woodhouse , Lu Baolu , Frederic Barrat , Andrew Donnellan , Felix Kuehling , Joerg Roedel , Dave Hansen , Tony Luck , Ashok Raj , Jacob Jun Pan , Dave Jiang , Yu-cheng Yu , Sohil Mehta , Ravi V Shankar , linux-kernel , x86 , iommu@lists.linux-foundation.org, amd-gfx , linuxppc-dev Subject: Re: [PATCH v2 12/12] x86/traps: Fix up invalid PASID Message-ID: <20200615185529.GD13792@romley-ivt3.sc.intel.com> References: <1592008893-9388-1-git-send-email-fenghua.yu@intel.com> <1592008893-9388-13-git-send-email-fenghua.yu@intel.com> <20200615075649.GK2497@hirez.programming.kicks-ass.net> <20200615154854.GB13792@romley-ivt3.sc.intel.com> <20200615160357.GA2531@hirez.programming.kicks-ass.net> <20200615181259.GC13792@romley-ivt3.sc.intel.com> <20200615183116.GD2531@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200615183116.GD2531@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Peter, On Mon, Jun 15, 2020 at 08:31:16PM +0200, Peter Zijlstra wrote: > On Mon, Jun 15, 2020 at 11:12:59AM -0700, Fenghua Yu wrote: > > > I don't get why you need a rdmsr here, or why not having one would > > > require a TIF flag. Is that because this MSR is XSAVE/XRSTOR managed? > > > > My concern is TIF flags are precious (only 3 slots available). Defining > > a new TIF flag may be not worth it while rdmsr() can check if PASID > > is valid in the MSR. And performance here might not be a big issue > > in #GP. > > > > But if you think using TIF flag is better, I can define a new TIF flag > > and maintain it per thread (init 0 when clone()/fork(), set 1 in fixup()). > > Then we can avoid using rdmsr() to check valid PASID in the MSR. > > WHY ?!?! What do you need a TIF flag for? We need "a way" to check if the per thread MSR has a valid PASID. If yes, no need to fix up the MSR (wrmsr()), and let other handler to handle the #GP. Otherwise, apply the heuristics and fix up the MSR and exit the #GP. The way to check the valid PASID in the MSR is rdmsr() in this series. A TIF flag will be much faster than rdmsr() and seems a sutiable way to check valid PASID status per thread. That's why it could replace rdmsr() to check PASID in the MSR. Or do you suggest to add a random new flag in struct thread_info instead of a TIF flag? Thanks. -Fenghua