Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp860336pxb; Wed, 29 Sep 2021 11:09:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZEDXYr9aBHukwwcT+dgffX491r3ADjoDnHCr3RBatKcDF93CiA8JpbJMV6um7LiApAqC7 X-Received: by 2002:a05:6402:50cc:: with SMTP id h12mr1587303edb.216.1632938996310; Wed, 29 Sep 2021 11:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632938996; cv=none; d=google.com; s=arc-20160816; b=LLpptBNIgNxLf2QUvZ0IDwISgbDTafuZtGVgadQasKGlP7oYma3CbblSohwRCu8FCA E0r6Px9GmLzdQYTEUFWfP/ZbNVutjmEOIESCgAyqFDWN+gXl8JkHdHZyNCFgiomKhFRP 09Ibr+we45YaR1PR4xi7VlWzH9Uvo9P5fCGGcQ1oTMJdLVjX2ClzUL83oA+R6B+V1wOW RxPPn/xYySdXqKLrn7Q5+y/cPh3M1fKoOd4lqDTZ4EW60IzA1cGtEhBqTR2KOLfajcw7 rXwaP3Vmu+aJniQug8rAqwcKOqjm/8pUzJGRNDjSCfWfEilAO7jbR7Yxz0yR9dTZer4Z WJQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature; bh=joybO94woomQkn6HYZiL/cGxHbZzl+Z5Y5iGbXoYwRU=; b=I3Rk/BqS5Rt6r7itceZgvr/2RdWyVQCnyISD4m145fZhlgPTUWgCfgwz9K+sQo2Lz/ SqCiFVAmxSvnKZmsz3JjA1VmHHEOk+tVkURDlyEbZO0whd/yRjeSYeV0ls1/rzTj4nzr PEpuT8iaBEB1YxcP9KIiW/BEgKoFnbvwotdld2SG2G2V0L2c4DiR14HcjMBhVqpbPVtI oLa5oC+a6m05bKm4W6z75pCmws3qE3x6RcVZPAB4kV6uXbuEDn1L0GZXt0cyFrvU/NKQ WA4yaDLsQukytQoqMhym5CRaguU5Lqso9JUV4xid1yDByUr7jpLDCAWVz3uHgB4sRarq tRkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LM1gtvuF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si686588edf.579.2021.09.29.11.09.31; Wed, 29 Sep 2021 11:09:56 -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=@kernel.org header.s=k20201202 header.b=LM1gtvuF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343747AbhI2RtD (ORCPT + 99 others); Wed, 29 Sep 2021 13:49:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:44628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245131AbhI2RtB (ORCPT ); Wed, 29 Sep 2021 13:49:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8312F6135E; Wed, 29 Sep 2021 17:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632937640; bh=jEX9WfFfE7uc4opv3Isth3zecI1A32dpxFg6mdU08xM=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=LM1gtvuF6QTPazoRV7AFt66j4gUjzHljkibHjf3/NEsFv2QZO9rjpxZGFe8/KAHD0 riqHZLqqhJBcxYwr/VtdhRf5/H3W3qudXW+X1DfIR0wWVaYYaknxCnJRrYta4OSVFB EN0/wmE5CKyEHSKXmsREeDVezXzvHOuO+0MxFddJ51/+FBzyaDzys0EbVTvyMjn010 TTCf1YJNsh7cmLlhe7AbaDDTsgqQFs1v7bMoshfxq26wI/iUMTWFAPqYCm3slv2Ojr cRSgHKh5aEDvQu4yD/pdxIZtUpJQaaSUypxgrbKJCdMyqAAKZalvvMuKBZT1FaaAcL +kXeAY7LxnvUA== Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id A0D8C27C0054; Wed, 29 Sep 2021 13:47:18 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute6.internal (MEProxy); Wed, 29 Sep 2021 13:47:18 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekvddgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedftehn ugihucfnuhhtohhmihhrshhkihdfuceolhhuthhosehkvghrnhgvlhdrohhrgheqnecugg ftrfgrthhtvghrnheptdfhheettddvtedvtedugfeuuefhtddugedvleevleefvdetleff gfefvdekgeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprghnugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeiudek heeifedvqddvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlihhnuh igrdhluhhtohdruhhs X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6E53E21E0063; Wed, 29 Sep 2021 13:47:18 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1303-gb2406efd75-fm-20210922.002-gb2406efd Mime-Version: 1.0 Message-Id: In-Reply-To: References: <87y27nfjel.ffs@tglx> <87o88jfajo.ffs@tglx> <87k0j6dsdn.ffs@tglx> <87r1d78t2e.ffs@tglx> <75e95acc-6730-ddcf-d722-66e575076256@kernel.org> <877dez8fqu.ffs@tglx> Date: Wed, 29 Sep 2021 10:46:58 -0700 From: "Andy Lutomirski" To: "Tony Luck" , "Thomas Gleixner" Cc: "Peter Zijlstra (Intel)" , "Fenghua Yu" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "Lu Baolu" , "Joerg Roedel" , "Josh Poimboeuf" , "Dave Jiang" , "Jacob Jun Pan" , "Raj Ashok" , "Shankar, Ravi V" , iommu@lists.linux-foundation.org, "the arch/x86 maintainers" , "Linux Kernel Mailing List" Subject: Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 29, 2021, at 10:41 AM, Luck, Tony wrote: > On Wed, Sep 29, 2021 at 07:15:53PM +0200, Thomas Gleixner wrote: >> On Wed, Sep 29 2021 at 09:59, Andy Lutomirski wrote: >> > On 9/29/21 05:28, Thomas Gleixner wrote: >> >> Looking at that patch again, none of this muck in fpu__pasid_write() is >> >> required at all. The whole exception fixup is: >> >> >> >> if (!user_mode(regs)) >> >> return false; >> >> >> >> if (!current->mm->pasid) >> >> return false; >> >> >> >> if (current->pasid_activated) >> >> return false; >> > >> > <-- preemption or BH here: kaboom. >> >> Sigh, this had obviously to run in the early portion of #GP, i.e. before >> enabling interrupts. > > Like this? Obviously with some comment about why this is being done. > > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c > index a58800973aed..a848a59291e7 100644 > --- a/arch/x86/kernel/traps.c > +++ b/arch/x86/kernel/traps.c > @@ -536,6 +536,12 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection) > unsigned long gp_addr; > int ret; > > + if (user_mode(regs) && current->mm->pasid && !current->pasid_activated) { > + current->pasid_activated = 1; > + wrmsrl(MSR_IA32_PASID, current->mm->pasid | MSR_IA32_PASID_VALID); > + return; > + } > + This could do with a WARN_ON_ONCE(TIF_NEED_LOAD_FPU) imo. Is instrumentation allowed to touch FPU state? > cond_local_irq_enable(regs); > > if (static_cpu_has(X86_FEATURE_UMIP)) { > > -Tony