Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8971369rwb; Tue, 13 Dec 2022 12:59:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf4EYPYb334rh7G9zmOoXJmNS7FtmlpzxwpmMVz53ryU4p/KrvmBuih1Fc+dlxLGoBNmlfjR X-Received: by 2002:a05:6402:194a:b0:464:4604:f9d4 with SMTP id f10-20020a056402194a00b004644604f9d4mr12833479edz.24.1670965184043; Tue, 13 Dec 2022 12:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670965184; cv=none; d=google.com; s=arc-20160816; b=OsU0WsWFT/0uSuhFj+gWKNQ7wXfmdCG3LQfuumdCsw3alU/IK8nNtgIXrfQyXpwLyC GngR7nCVEEknN1UKVk8s9Il84puitpV9Kdxz2OdzNj54Q0QIpLUGzQwonZ4XkjgFtHwS YP+1gxsOPNDti7fxW8f1frOgdJDDZYZ3vmXLeX3E2LC21IprgmbvOYFq09EUz6LXYwFn 8Ika2XDrtpDK+Yb76P3VJ6jFsGFzqNtezQdaSQkumCvQR1ooAWeKHnjJGb03y7AKhy7K FQ2vSCLKF7ohUb+C/qHP7cujPAt3EBE7cuiDxBLSx5keCX/26GNgr6EKFYvsucc0qKpL lWHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=R39+NfUhgarK3tKmHCzEwkimmjHqJW+fvpsH/oFUjuU=; b=hCrbLPAegzA8UQfKvvvqqqxUlN3rNrZIwU2vtzHfS0n2MM5504qebG9cMFlaUMJWrG OvT7Mrx0RriUErEE3VEZOzC/pM2lBf2eRpEvStHG2LN7nZ4tVCKMCE2LrggKhK83L5Dj cT5Duy6GQVYdwNGnjxx+EGgwWBZ+6T8gOYeAgE8FqAHv+1+B50prZNLPoXed3erJXHHA W5KWoQhV34WMdbjgjMbOwgOsy0lpvMea/Ys3TIIyehHQl2gNVPKL6QlNzP6hOaRXmdGZ +DUM4d1VCT2adf5hmID7/rWMM0Tb8pXWRBMj+bnjz4RDixlwUKLhY2YpCTrw9GnmkxgC wHGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZvUY+XmH; 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 r12-20020a05640251cc00b004615937b174si12134599edd.480.2022.12.13.12.59.06; Tue, 13 Dec 2022 12:59:44 -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=ZvUY+XmH; 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 S237315AbiLMU7D (ORCPT + 99 others); Tue, 13 Dec 2022 15:59:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237313AbiLMU7C (ORCPT ); Tue, 13 Dec 2022 15:59:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF49420F5A for ; Tue, 13 Dec 2022 12:59:00 -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 9DE61B815BE for ; Tue, 13 Dec 2022 20:58:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EE8EC433EF for ; Tue, 13 Dec 2022 20:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670965138; bh=vZjfMJv+YQaExGmli9Ja2HeEpcwcey5Y8WObXJ817ww=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZvUY+XmHRtfKkPpKtbKp6OZ+5hnFbKFl5476PWHKY+X6/MZag7tOf4pEjHDTP8rWk B3B77NEi7KUOIT9iWhvbJXbMSMEk6HPKlLs/zHvOM6Ryv4+GvNJsBFEfUcO094p9Sk rV8Cl2GJcwQFGcwdn3X4rcyXEoGuEFh1ykT2ytRkux6s4ruVwuVBn9lAuFD+EOW006 zKhH/rn7vkIQnsGuVPDpRRhiIhpusrM9bpxkgatu4YOE65+Hy/2L7I/EwwTYfhGzcX C2hgXy+nTRjJUh7BEmw60vXcd0mx/25pLl1N6G6UUVzK7/OZdZTbpfmB771j1wzytC zSyP9+If/L+Tw== Received: by mail-lj1-f178.google.com with SMTP id v11so4647846ljk.12 for ; Tue, 13 Dec 2022 12:58:58 -0800 (PST) X-Gm-Message-State: ANoB5plY0JPZDbxbjQi19T3Y8/K0nLpiv9NP29n7qbw/N2ccPYZ3DPje xVuZ2XIoRNkXYs2JPprL29NWwlT+vWUu8kiHL0A= X-Received: by 2002:a05:651c:153:b0:279:bbff:a928 with SMTP id c19-20020a05651c015300b00279bbffa928mr12041866ljd.415.1670965136065; Tue, 13 Dec 2022 12:58:56 -0800 (PST) MIME-Version: 1.0 References: <20221213161310.2205802-1-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Tue, 13 Dec 2022 21:58:45 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] crypto: use kmap_local() not kmap_atomic() To: Eric Biggers Cc: linux-crypto@vger.kernel.org, Herbert Xu , "Elliott, Robert (Servers)" Content-Type: text/plain; charset="UTF-8" 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, 13 Dec 2022 at 20:50, Eric Biggers wrote: > > 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? > Yeah, probably, but that one does not actually affect 64-bit at the moment, so it matters less.