Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8925452rwb; Tue, 13 Dec 2022 12:17:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf6SVgR7Ce/7eqAF1SF4aznSwgnuHzn1Rk8WUuykniNh/bkK1KH8qM7spNaDCJTJUVymSMbI X-Received: by 2002:a17:906:6b13:b0:7ae:29fa:ba8f with SMTP id q19-20020a1709066b1300b007ae29faba8fmr23134819ejr.2.1670962631769; Tue, 13 Dec 2022 12:17:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670962631; cv=none; d=google.com; s=arc-20160816; b=rBkpM648zpba+9kizpQ12r9P5wDEOpPPf7pl4k7jOqs+64axBq6FdMp435VxvXy5A+ TyfszEVrZ9eh/ajRi3iquYvbgwhKOZquJPRjOvVeVK2VPPVMhpLjAiQ1XfVwbg4UQiCv l6je6f9yVE0YMw6Ai6n61N7GpIXk0KnKXsLZ6UYxynx6iNfCQsoJHp3t601nNdgbUyrs oppuBDnGvuP7w7pykvxPkjFyf/qROqBC0RJHiIVf2KfTAQnq2TiRwfOPRXxvkC9Aj8ub SBQBFce3gUtnmtZbP16W7QLqHfRXLdRtivia+i8Qna26T36uk81daLXXSFWOQ2hUHBQk YYUQ== 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=Wx5GNL2QL0Qib6V6uNAQnEGS2IyXPtm7Sql20WA48vE=; b=RMgEhN3OskAvo7d01xgLwIBuQ3cvYxt9BnItDK+u0VUobC9RXbUSTpGe5pvZ+BdBrz 0AjE/19LZ9VGE1de1X/tbaa1nRC9kvON7bT959/4uXqYj0Wi7UJyTzzusihDBm4ddZ4C fuQlhHiS/rDChk8a0Dv7YFyLDM5pXBVzcyp2XvFZ/lPcwtibJMUL8+lZQukZKMTYStTB VqYRSusopFMp97rUj0C/dyxYSfMSQT/xzKSsoQw9VNv0D2jcuej4ESLbMz5moftI5E6g 2qI7buzbTPZCEFqWUpnN8Qx+kitJbzar/iGE4JzzPjXENysHTM0SXTvzC1xsqcFTU+tV qg2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qUi+M03M; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv21-20020a17090760d500b007c0d4f96d8esi9820886ejc.566.2022.12.13.12.16.43; Tue, 13 Dec 2022 12:17:11 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=qUi+M03M; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235112AbiLMTvB (ORCPT + 99 others); Tue, 13 Dec 2022 14:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbiLMTvA (ORCPT ); Tue, 13 Dec 2022 14:51:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E87CA1FCF2 for ; Tue, 13 Dec 2022 11:50:56 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id AB5EBB81283 for ; Tue, 13 Dec 2022 19:50:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F4CDC433EF; Tue, 13 Dec 2022 19:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670961054; bh=hYXrulh1is+u82Hc6+D4w5TON+i41flRtmz2gYSnuFo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qUi+M03MnXrsaZ2gLoxtuN6a4ahQUF+Ovk8wl8zFSAPAHqLxe3nktMTMCa0FNhqdt lMuhfoGkgoL4NA51z9+a7gsDSAHs2AtlDVILZ9J7gzucHvoxqJQhNJegWCLPsGBoJK BNz2Ahd4njxChmQ8Vi3i3Ul+rc7d4NHtP9fxh0xlrMQZr4okBzYMbN4m1qw/aXrjkx wB6DalRKQ9WXwCnOwLnrb2GmVRKzEwIte9vfqZSpavdYmC0FFMx9wea6C1mJD/5j8E ArAOO1ufmjROg2c9fj4j/Eufs+EQT2tH1u57TuKMgQe/tBEZCrc2dw1ygDRrelarJv h7e9O9KQyPBBg== Date: Tue, 13 Dec 2022 11:50:52 -0800 From: Eric Biggers To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, Herbert Xu , "Elliott, Robert (Servers)" Subject: Re: [RFC PATCH] crypto: use kmap_local() not kmap_atomic() Message-ID: References: <20221213161310.2205802-1-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221213161310.2205802-1-ardb@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Tue, Dec 13, 2022 at 05:13:10PM +0100, Ard Biesheuvel wrote: > kmap_atomic() is used to create short-lived mappings of pages that may > not be accessible via the kernel direct map. This is only needed on > 32-bit architectures that implement CONFIG_HIGHMEM, but it can be used > on 64-bit other architectures too, where the returned mapping is simply > the kernel direct address of the page. > > However, kmap_atomic() does not support migration on CONFIG_HIGHMEM > configurations, due to the use of per-CPU kmap slots, and so it disables > preemption on all architectures, not just the 32-bit ones. This implies > that all scatterwalk based crypto routines essentially execute with > preemption disabled all the time, which is less than ideal. > > So let's switch scatterwalk_map/_unmap and the shash/ahash routines to > kmap_local() instead, which serves a similar purpose, but without the > resulting impact on preemption on architectures that have no need for > CONFIG_HIGHMEM. > > Cc: Eric Biggers > Cc: Herbert Xu > Cc: "Elliott, Robert (Servers)" > Signed-off-by: Ard Biesheuvel > --- > crypto/ahash.c | 4 ++-- > crypto/shash.c | 4 ++-- > include/crypto/scatterwalk.h | 4 ++-- > 3 files changed, 6 insertions(+), 6 deletions(-) > Thanks Ard, this looks good to me, especially given the broader effort to replace kmap_atomic() with kmap_local_page() in the kernel. One question: should the kmap_atomic() in crypto/skcipher.c be replaced as well? - Eric