Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp911720iob; Wed, 4 May 2022 10:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKYMee14BoePiN+QHuwVqfvrApxd3zvyNlo2rjEos2ljrjCdnIB0reNXAYP8wXfHXzkkYz X-Received: by 2002:a17:906:2991:b0:6cc:fc18:f10c with SMTP id x17-20020a170906299100b006ccfc18f10cmr20758315eje.744.1651685285950; Wed, 04 May 2022 10:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651685285; cv=none; d=google.com; s=arc-20160816; b=D5l9OZsBBvl14JWj2qu0FsTpWeXcW08b8PmOpWPjBd+8P0eO6yF835g2OzcOfsWXHl gRIpjDzk0VRujp4EqwqrJXSDOFlc2XX9zzN3QhoCq1RC7XpDpryATrswRZslMprTvs/Q ptiigaNYOo1QV5X4H9CtezG0m5L3wm2BJEnBAUS+RGHwGsghd8d5LKOnIZDHq4VtVGKG DJVii73WHvqvx//MCBBkOx8/C64BjB4vS/74WMootugt+BEtSrBOHLFGR2n8Q/6M6bPM mGORdZnx7jhHdS5YGpDCrdRAwcxaZsC/fFwxpoj5JGVpXDhSuVnyKNZDyDf2mCTvO1BZ L9Yg== 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=6yyJ0k9BpvAv3H7drBawcClMMXzihm3exQEpiGY4xDM=; b=QfbOO9Z0pCzG5RR9dU/JqzMN4RTBIHk1JQO/sEcm0ZM+ydh3WbHiWv/OKjSFjHrPIV /XIXlRrEYYyXBLpT61hOsNWxyEbRPIJuH7n9NEed7+AuDgFfvnQQFkleDBhR7vaIk2Ek z/Syyu1pY7XR+QGGHHBx7oPZXa9RcVW/POy/zh95m9j/xMFVyeKA9BF1AKc8ruX4oT/+ i51ulPU/UsXl860hKrpOF3HyqnMjLPF22pDsS06mcHZNE5rVDHeKmvJfziDVrMtPP1H3 Q3yu+xieYZArsWWZoVUZde7kRPiTlDSM74gdzxUUtUAj3l5uNKVs3XSjHTzkpKb7vD4B lIcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=JYkvInkD; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc14-20020a170906f90e00b006e021f4c201si16610943ejb.271.2022.05.04.10.27.39; Wed, 04 May 2022 10:28:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@zx2c4.com header.s=20210105 header.b=JYkvInkD; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352613AbiEDP7U (ORCPT + 99 others); Wed, 4 May 2022 11:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352928AbiEDP7T (ORCPT ); Wed, 4 May 2022 11:59:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 939E113D28; Wed, 4 May 2022 08:55:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 371E161777; Wed, 4 May 2022 15:55:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC9ECC385A5; Wed, 4 May 2022 15:55:40 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="JYkvInkD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1651679739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6yyJ0k9BpvAv3H7drBawcClMMXzihm3exQEpiGY4xDM=; b=JYkvInkDkMu4DwG+axf7VkN0haw5B9+vh2KIgA9FtRpMP/P+uj58tA0EY5CX5HZi9hXxsC yWmjh1j06JEiIt+t8K2rzYnNZs8GWZr5Bq0IUPfY+awCBsG28xNUJ5LA1l1sYLDV5pRLRS 4ijeE3RUiOvxmrqyP/rF9609ptPild0= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id bf1403c7 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Wed, 4 May 2022 15:55:38 +0000 (UTC) Date: Wed, 4 May 2022 17:55:35 +0200 From: "Jason A. Donenfeld" To: Thomas Gleixner Cc: Peter Zijlstra , Borislav Petkov , LKML , x86@kernel.org, Filipe Manana , linux-crypto@vger.kernel.org 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> <87fslpjomx.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87fslpjomx.ffs@tglx> X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,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-crypto@vger.kernel.org Hi Thomas, On Wed, May 04, 2022 at 05:36:38PM +0200, Thomas Gleixner wrote: > But the only use case which utilizes FPU from hard interrupt context is > the random generator via add_randomness_...(). > > I did a benchmark of these functions, which invoke blake2s_update() > three times in a row, on a SKL-X and a ZEN3. The generic code and the > FPU accelerated code are pretty much on par vs. execution time of the > algorithm itself plus/minus noise. > > IOW, using the FPU blindly for this kind of computations is not > necessarily a good plan. I have no idea how these things are analyzed > and evaluated if at all. Maybe the crypto people can shed some light on > this. drivers/net/wireguard/{noise,cookie}.c makes pretty heavy use of BLAKE2s in hot paths where the FPU is already being used for other algorithms, and so there the save/restore is worth it (assuming restore finally works lazily). In benchmarks, the SIMD code made a real difference. But this presumably regards mix_pool_bytes() in the RNG. If it turns out that supporting the FPU in hard IRQ context is a major PITA, and the RNG is the only thing making use of it, then sure, drop hard IRQ context support for it. However... This may be unearthing a larger bug. Sebastian and I put in a decent amount of work during 5.18 to remove all calls to mix_pool_bytes() (and hence to blake2s_compress()) from add_interrupt_randomness(). Have a look: https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git/tree/drivers/char/random.c#n1289 It now accumulates in some per-CPU buffer, and then every 64 interrupts a worker runs that does the actual mix_pool_bytes() from kthread context. So the question is: what is still hitting mix_pool_bytes() from hard IRQ context? I'll investigate a bit and see. Jason