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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 7E2F3C433EF for ; Wed, 22 Sep 2021 21:07:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 663C6611C4 for ; Wed, 22 Sep 2021 21:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237898AbhIVVJI (ORCPT ); Wed, 22 Sep 2021 17:09:08 -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?