Received: by 2002:a05:6a10:5c7:0:0:0:0 with SMTP id p7csp895354pxt; Wed, 22 Sep 2021 14:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypBMSdNLvcpli5z9rRWLYRQGGhLO1i3kyZEQHoM422UmZg9ULY6DX3fLWNFqpguduZXZyM X-Received: by 2002:a17:907:2064:: with SMTP id qp4mr1436774ejb.317.1632345156749; Wed, 22 Sep 2021 14:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632345156; cv=none; d=google.com; s=arc-20160816; b=Z+5ugcNwVJFFW0OIrZtnNEUNt8J+aWnivh1CQaWE1it/okJQGtIGH4OArBrwgfhPB7 /wX418T6UQsPv/1wC3wvRUevQaEUKBR8UsWMx+EH404O4dfaun9qPsua8ukY+sFhiSVa 1R/GHW0qYd+TdvIrFDnX627+FLAW+jmQ9F57fHlNhamd1TRynIqHZdlbAkz+jwSAsd31 BC1GYeXFTIBYQbRTx+knPcAN8TThv4QsjccyoyjHDLddTCc1rNo0fWNodgupP/rFLLzV s/0zzOHDu6Mi2dwj39EAUhGPg63/GU1XCpV80/fhPUajyB95lhMVK0XfqNzp72Znn+IM luOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AUrxzWHUDiIkVe0pCul4am+eYMocI+xR3IVu4etN2ik=; b=y/wklritW3O+pxJun+9hZlgzC5Enoqqi4FkSmO0DYhCAGejthgdESLtLDAGxBg9ric C7ZOR+Wpmm21C6csBwwGnEipy60BkVl0BheAV1ip1x5B27wS7yDWK6YZFdA+fxVukEfA aQKpu9h0kgldDIASlUG0fN+4AsSBfAbXKWpsbR+Zh42el7nCv1U/FPUZh6qjKm3SoE3g L1jSf44+HoUkVaU005MWvKlr50iyHFveVbGV65PcM6+zmdw5SeyzsDprGkPZ7DwVULGn flpg3ctaSg+0f9Mof9/CHQKwSa1uJyTg2ebju0sLBDcY7ZfBMS5oe14RTDmaY09cKILY xpnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="cI/HH1n9"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f17si4232612ejt.20.2021.09.22.14.12.12; Wed, 22 Sep 2021 14:12:36 -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; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="cI/HH1n9"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237883AbhIVVJH (ORCPT + 99 others); Wed, 22 Sep 2021 17:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237759AbhIVVJG (ORCPT ); Wed, 22 Sep 2021 17:09:06 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 522E2C061574 for ; Wed, 22 Sep 2021 14:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=AUrxzWHUDiIkVe0pCul4am+eYMocI+xR3IVu4etN2ik=; b=cI/HH1n9IHnS59Vwg4T3USPEJy yqf8pBFHwg5vfUgTgEbWExme4EnKhpOAMEInsYDmvANFsP+4IFDpZy8B/KKofwXXSYwJNFosQIUKK Sq4v1oBqKCyYTjDAPP70tg2LZi0Ykv/MjflLLrp98W7O7cvK98g6kUOZnM7Tz8rmGSdSx7I6xhelB oArJi2a4PuonEOFbhGyovGkihF/0RPvq/uDaJm3WxcEWJ/xo/gu3Q1jr62MEc2B3P1DuIGer9jrH/ 7iX/qmRLNvBaOG8girQUCSEhXtJ3Mtqwu8xEdFEGb5Ok2+ia36YjIMITMl6al/VCXvrv/a6wgd+QV cG1qUw7Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT9Sc-0054ul-PD; Wed, 22 Sep 2021 21:07:23 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 3E7FD9811F0; Wed, 22 Sep 2021 23:07:22 +0200 (CEST) Date: Wed, 22 Sep 2021 23:07:22 +0200 From: Peter Zijlstra To: Fenghua Yu Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Dave Hansen , Tony Luck , Lu Baolu , Joerg Roedel , Josh Poimboeuf , Dave Jiang , Jacob Jun Pan , Ashok Raj , Ravi V Shankar , iommu@lists.linux-foundation.org, x86 , linux-kernel Subject: Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP Message-ID: <20210922210722.GV4323@worktop.programming.kicks-ass.net> References: <20210920192349.2602141-1-fenghua.yu@intel.com> <20210920192349.2602141-5-fenghua.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210920192349.2602141-5-fenghua.yu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 20, 2021 at 07:23:45PM +0000, Fenghua Yu wrote: > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c > index a58800973aed..a25d738ae839 100644 > --- a/arch/x86/kernel/traps.c > +++ b/arch/x86/kernel/traps.c > @@ -61,6 +61,7 @@ > #include > #include > #include > +#include > > #ifdef CONFIG_X86_64 > #include > @@ -526,6 +527,14 @@ static enum kernel_gp_hint get_kernel_gp_address(struct pt_regs *regs, > return GP_CANONICAL; > } > > +static bool fixup_pasid_exception(void) > +{ > + if (!cpu_feature_enabled(X86_FEATURE_ENQCMD)) > + return false; > + > + return __fixup_pasid_exception(); > +} > + > #define GPFSTR "general protection fault" > > DEFINE_IDTENTRY_ERRORCODE(exc_general_protection) > @@ -538,6 +547,9 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection) > > cond_local_irq_enable(regs); > > + if (user_mode(regs) && fixup_pasid_exception()) > + goto exit; > + > if (static_cpu_has(X86_FEATURE_UMIP)) { > if (user_mode(regs) && fixup_umip_exception(regs)) > goto exit; So you're eating any random #GP that might or might not be PASID related. And all that witout a comment... Enlighten?