Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp464958iob; Tue, 3 May 2022 02:27:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv5zGRcXzp7FMGLjAGz0ifWaIZhq7SW6ENnCBjNT9zn81gvVI3QW6ESQVqpfmDbhDrcrAq X-Received: by 2002:a63:2a53:0:b0:3c1:5f80:a14c with SMTP id q80-20020a632a53000000b003c15f80a14cmr13270572pgq.279.1651570034723; Tue, 03 May 2022 02:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651570034; cv=none; d=google.com; s=arc-20160816; b=w9MY0V3Oj+RLY9JJMPO+yJ57pU6/i1tXc235uFEJbrsy6XXbIUDDxjxnFmtrhHu2Xm WusqM0A4nH2tS6cbnhwzRlm4VOHpt4rNWeNxxAGoxXtUuKPpx1Du9a07c9SUYNOKy12T dcV12D5HnphqofGlHh7MkFVddFBc2K7qoG83xLHCGFofuB45FjMx+vOTl13Gm6P7Hl6T 2cul4o1tRFUbwFmx/q+380OLHr7V/eAXoNXen9IgplQatnzHv3xbY89eUm7ikprZNN47 Jjim82moZB0+QKOWamLWrYFnrlot/3ovag4Pr3m+9z1vM9391jf5DcF2e4HcuVUcwzNX e1AQ== 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=eqK1xi56ux6pqK7FTWNtDH04KbxWFX0qsAS2KOydu0M=; b=gmp4gupq5s0TD2gUC1c7oxlxPclTusoAjJCe6JUFyeH20SNYlPZERIXG7Qk0CM5/tQ IvXUkoBcbeA6rsOuYXmkpjWxqgl0HeB4ST1OIcIjcgC0kElJb9Aexx9TfSnxW0ZLr0NK 6htHKqPpbcstSCSdsqJSsztn5b1q+JQ2wjUrJhveFgCC/t0uM2nIiHs4xOl0RSKDMjBO yDr624cKMn6JU1V4Xs4H+Eh+uaq08C+X59r7qKepp0riwuQeVs68MojWJShM4grVWgv3 N9pdGhHYnZJNhSBwgylGpE8Dhn9mhSeORKsuwwdyhOAy2t6RouP4liL4J/jhw/PjvpXF oWDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=ksS6OnqM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a655247000000b0039e59307c86si16478834pgp.617.2022.05.03.02.26.58; Tue, 03 May 2022 02:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=ksS6OnqM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233244AbiECJKJ (ORCPT + 99 others); Tue, 3 May 2022 05:10:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbiECJKI (ORCPT ); Tue, 3 May 2022 05:10:08 -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 D1A7822BF0 for ; Tue, 3 May 2022 02:06: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=eqK1xi56ux6pqK7FTWNtDH04KbxWFX0qsAS2KOydu0M=; b=ksS6OnqMEgvJfZzNYtO6y901OY SL5iu1tTQ6bgjR9FH6jk5EnJwsqr6b6Y6pq3WBahFp48E2iQ3j4XjNacsXPkFD+Inc6Gw0SUvkdyd /IJ3K+H2xJJ1nCV7zoBTNvKHmP8ncWRLX5uPhoWwNJkKpUpFGJaY24zXSG2pEynXa4KbEqnL9QImR /kk1AaC+8g81prxdylyNxE7NmrH2T2WOHfwsYRFEdoxujzHcktbNKdJrXIuV5Jka2VGoLWKeAHQeT npva4nepUROXwUlnixBu5pIbDTb1Pi7BU1EdE3RS70YLhFwAqL/Zv8wwNItIahZ4jGLq01tFk5ku1 nNsd5qeQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nloUC-00AjV7-9V; Tue, 03 May 2022 09:06:24 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2693F30047E; Tue, 3 May 2022 11:06:22 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1344820288CED; Tue, 3 May 2022 11:06:22 +0200 (CEST) Date: Tue, 3 May 2022 11:06:22 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Borislav Petkov , LKML , x86@kernel.org, Filipe Manana Subject: Re: [patch 3/3] x86/fpu: Make FPU protection more robust Message-ID: References: <20220501192740.203963477@linutronix.de> <20220501193102.704267030@linutronix.de> <87k0b4lydr.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k0b4lydr.ffs@tglx> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 02, 2022 at 05:58:40PM +0200, Thomas Gleixner wrote: > >> +void fpregs_lock(void) > >> +{ > >> + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) > >> + local_bh_disable(); > >> + else > >> + preempt_disable(); > > > > So I'm wondering: can we get rid of this distinction and simply do > > preempt_disable()? > > > > Or can FPU be used in softirq processing too so we want to block that > > there? > > Yes, FPU can be used legitimately in softirq processing context. > > > But even if, fpu_in_use will already state that fact... > > Right, though currently it's guaranteed that softirq processing context > can use the FPU. Quite some of the network crypto work runs in softirq > context, so this might cause a regression. If so, then this needs to be > an explicit commit on top which is easy to revert. Let me stare at it > some more. Right, so with the: preempt_disable(); this_cpu_write(fpu_in_use, true); barrier(); sequence it is safe against both softirq and hardirq fpu usage. The only concern is performance not correctness when dropping that local_bh_disable() thing. So what Thomas proposes makes sense to me.