From patchwork Mon Feb 21 12:08:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 544500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9AB5C433EF for ; Mon, 21 Feb 2022 12:08:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357338AbiBUMJH (ORCPT ); Mon, 21 Feb 2022 07:09:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357332AbiBUMJF (ORCPT ); Mon, 21 Feb 2022 07:09:05 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 991F3201AC for ; Mon, 21 Feb 2022 04:08:42 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id c192so9393498wma.4 for ; Mon, 21 Feb 2022 04:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mrY/YH1b9s1O9jMerN3hmkMMZmwmjWK0cZUfx1sY+dQ=; b=EHxIl7XNaoQqifbAvm4pywi+Wi6IHmxkBODFSm+hpEkuqO2pcABRHVqZhfTEPj1C/x qh6elN871Df9GMwQuyaZdPJC3DxREktLEXIZvvlF0OV8gP3GwT0NsKoTwz65WJst/8T+ Jc6I9zU5zpMgjdlDS5KnRSSt+Pqg+BmmfkewzG/0DiGhzUSgxV0HMYXTaOW8wULF3qPX ZlGHJKkX0klQhkX6VeZciYbt82ixAoV6ySkls8QVrWpDNVBDuSBnlgHxWIJO0XM0hqLG 4CM/AUl9hfEj+n4UcteK6q2IVldLU4dmeJWbD1pH+2+6uaTjbF4hpUtFn66Vvd/UVwvy JWOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mrY/YH1b9s1O9jMerN3hmkMMZmwmjWK0cZUfx1sY+dQ=; b=ni1q/cwKzhMbT0fDKANkCPKOzVvEmAu3urftgeeZk45GKsKKBnaQL1gFz8Qwg4fcKi K2PeNcH7ngXPCkD4yQDU7F859vtBSmahm5q6zvGKpwxGK2HZ7Rr/4UBXplwz0jyrBdZJ LVOtZMkkKbjiiHlVFTTSZwnYfE4uCTSI5LEA1YmoeShWEFQkDOgri5M6L+RMKLPtnhLV m9gNkEJ/xJf3L5WDLTIR7o0sIp++7gfFaVcMxj+A6DIkVh2ag6y46lFEN9cvPRHIOpIE Sgxs5bN+HVdrWkHdDay6AXqQQLXhc4bvBWxfgKZIO10CqdkWWYmJlNDp6bboKNON6vTC w7ow== X-Gm-Message-State: AOAM531XozHttTczfRafCLfZcZ7SlfkC8ALq6wLVfciH7f9gwtzipgfA AmWNRrB1DetXk5T5wkFQYrBamA== X-Google-Smtp-Source: ABdhPJxZOj3bAaqzQpMpwIZwq1rULq8jrXuaL/D3GX2+h/JhGdZn8tGDnxnawe+BhPseDP53wiUJlg== X-Received: by 2002:a05:600c:1f16:b0:37b:c7f2:fbb4 with SMTP id bd22-20020a05600c1f1600b0037bc7f2fbb4mr20467582wmb.47.1645445321196; Mon, 21 Feb 2022 04:08:41 -0800 (PST) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a8sm11821546wra.0.2022.02.21.04.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 04:08:40 -0800 (PST) From: Corentin Labbe To: herbert@gondor.apana.org.au, jernej.skrabec@gmail.com, linus.walleij@linaro.org, narmstrong@baylibre.com, ulli.kroll@googlemail.com, wens@csie.org Cc: linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Corentin Labbe Subject: [PATCH 1/5] crypto: sun8i-ss: call finalize with bh disabled Date: Mon, 21 Feb 2022 12:08:29 +0000 Message-Id: <20220221120833.2618733-2-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221120833.2618733-1-clabbe@baylibre.com> References: <20220221120833.2618733-1-clabbe@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Doing ipsec produces a spinlock recursion warning. This is due to not disabling BH during crypto completion function. Fixes: f08fcced6d00 ("crypto: allwinner - Add sun8i-ss cryptographic offloader") Signed-off-by: Corentin Labbe --- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 3 +++ drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c index 9ef1c85c4aaa..554e400d41ca 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c @@ -11,6 +11,7 @@ * You could find a link for the datasheet in Documentation/arm/sunxi.rst */ +#include #include #include #include @@ -274,7 +275,9 @@ static int sun8i_ss_handle_cipher_request(struct crypto_engine *engine, void *ar struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); err = sun8i_ss_cipher(breq); + local_bh_disable(); crypto_finalize_skcipher_request(engine, breq, err); + local_bh_enable(); return 0; } diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c index d8c333fe5eb2..0c2ca296bede 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c @@ -9,6 +9,7 @@ * * You could find the datasheet in Documentation/arm/sunxi.rst */ +#include #include #include #include @@ -633,6 +634,8 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq) memcpy(areq->result, result, algt->alg.hash.halg.digestsize); theend: + local_bh_disable(); crypto_finalize_hash_request(engine, breq, err); + local_bh_enable(); return 0; } From patchwork Mon Feb 21 12:08:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 544499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D95DC433F5 for ; Mon, 21 Feb 2022 12:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357422AbiBUMJe (ORCPT ); Mon, 21 Feb 2022 07:09:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357332AbiBUMJI (ORCPT ); Mon, 21 Feb 2022 07:09:08 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B99C201B9 for ; Mon, 21 Feb 2022 04:08:45 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id d27so26702993wrc.6 for ; Mon, 21 Feb 2022 04:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eRwXQ22zhUvx1o2PZ7ENLpRDM+5TmK2L3Q+xebz6RZg=; b=qmw5zddLshVBKDNx9LmeyGeFD06unJdxUalh9qYp20aANFXunS0qfedH7kKreKAi1B TuZ66MDF1UKDbxZfJtTct+TBv4WAKrXribxlOnzuChMAnS3sDdKtTRU18+ju9/hFQSxs EhLx/h9ZR4eCkZxp1ViV4aDidIOXtwLywqNfVkjll1JeohtBMUWIZN98n1+RDri/GkOj vLCnqS9rwSkHDW6XYSZV9Oe834ro/eJCV+XoXF40hYLL4DMMubP/riKiaLy7jIuAEmp7 wi+n0NwOGdXFC6avheY2YvwGHhX3elgBsAo6php6McGHit+QF9Qq9ovwKve12Rs6xaT7 cVNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eRwXQ22zhUvx1o2PZ7ENLpRDM+5TmK2L3Q+xebz6RZg=; b=DkqN9wfyg+D7E+m2XpRkBHhSifUuMfHibvb6L8FjjM267HE0LkX/DfOhEuqdbK3rQr oQwOH1OCSakuFn+fweJNWaZiUiVMw1dsZ32YRlny5DRPtNepEDeW9ZtST2eOUetj/sVG BUgLrEbumCPUzN4PQFLXGA3FLSaVgujWkN94KCL/AVY78JmG/yY8sEH3tM2Xw9hvwV9b SqNFvcwUkU1tQxPEq/AAYSi3Mi3zq/2k3upK+OHsxpf10WsDgGs84d5n9U8+184PQoSm 8+BMdHhYBndj4Z/qO9LKusPalNvdmOFC2Hav5qRI1ikAyZGFZagUVemATX1cYbwRD4LE cjHw== X-Gm-Message-State: AOAM5327ZCvFvJN4o5W+ElQMqUr2uwr4lRpKdQ7E0/dp48wkrm9ol00l Tz3EKbMRoqYasf3RPNDmvfjoHQ== X-Google-Smtp-Source: ABdhPJy6vbpLlKF2o118HSZXUs4RfBWx6RmuHRbHpvyirVgJKBWwM1e3MmCtrMzPWWHPKMXOLsmeIQ== X-Received: by 2002:a05:6000:154e:b0:1ea:7622:64ec with SMTP id 14-20020a056000154e00b001ea762264ecmr676608wry.600.1645445323857; Mon, 21 Feb 2022 04:08:43 -0800 (PST) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a8sm11821546wra.0.2022.02.21.04.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 04:08:43 -0800 (PST) From: Corentin Labbe To: herbert@gondor.apana.org.au, jernej.skrabec@gmail.com, linus.walleij@linaro.org, narmstrong@baylibre.com, ulli.kroll@googlemail.com, wens@csie.org Cc: linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Corentin Labbe Subject: [PATCH 4/5] crypto: gemini: call finalize with bh disabled Date: Mon, 21 Feb 2022 12:08:32 +0000 Message-Id: <20220221120833.2618733-5-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221120833.2618733-1-clabbe@baylibre.com> References: <20220221120833.2618733-1-clabbe@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Doing ipsec produces a spinlock recursion warning. This is due to not disabling BH during crypto completion function. Fixes: 46c5338db7bd45b2 ("crypto: sl3516 - Add sl3516 crypto engine") Signed-off-by: Corentin Labbe --- drivers/crypto/gemini/sl3516-ce-cipher.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/gemini/sl3516-ce-cipher.c b/drivers/crypto/gemini/sl3516-ce-cipher.c index 53e3fefb81de..14d0d83d388d 100644 --- a/drivers/crypto/gemini/sl3516-ce-cipher.c +++ b/drivers/crypto/gemini/sl3516-ce-cipher.c @@ -264,7 +264,9 @@ static int sl3516_ce_handle_cipher_request(struct crypto_engine *engine, void *a struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); err = sl3516_ce_cipher(breq); + local_bh_disable(); crypto_finalize_skcipher_request(engine, breq, err); + local_bh_enable(); return 0; } From patchwork Mon Feb 21 12:08:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 544498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3BD9C43219 for ; Mon, 21 Feb 2022 12:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357313AbiBUMJg (ORCPT ); Mon, 21 Feb 2022 07:09:36 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357367AbiBUMJJ (ORCPT ); Mon, 21 Feb 2022 07:09:09 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DFC7205C0 for ; Mon, 21 Feb 2022 04:08:46 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id c192so9393586wma.4 for ; Mon, 21 Feb 2022 04:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1WbusBDevTL0id1+rC6qLSGi8eX9Tec+0gEdUp6beE0=; b=D/T2RPldzgpWaePTaWvFPRInmTGPvf5JQV2GkaAY4ibltSxUGvo267U3iNBvxTTNVf oXgkIEryAs8WFCi8dNoB0wHLcM4GAuZ02L1fSj+7wu84dKzey4l7F/ctcAAC+8Tncay7 2DXF7IOzXCF7JtZvr4rWoTOGYLmmotDBg/0Ij/PUQeZy86dO/RFVogFYAwxMuOQrAOjb FnDjxhbedsPEUBohewERqQvuUbkUKCqoQjT5JTMxy4ZbonuZwrfYj9TLXXW8yPeacSZd sOOx9U/UEXhXCV1h1mX+Mqz2OFFhsMbokU3w8p2zTaJOAngv0/lpFrKLeZ+Dg7U7rU3o LrDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1WbusBDevTL0id1+rC6qLSGi8eX9Tec+0gEdUp6beE0=; b=sg3cJa/PNyIvAb1p1a6s4BXJBCDtj8Lv+8sOHgI0eIi7s0AFb9r9+ZY/x570zfhktL Wrbi3lE+MRauibjIM4OobOGYp2ufJ+e1EO983VyRIIDmPv/qI80yP4QMSYAIO+WOVXaj +19yZjdAq42+t/Kf+/D9JtviPrd6jUqf/KMucMGTXxvqhuNOBWwjK5A5pgskg8X1AAe1 WyLt0fOxEbvEesB9dZpSdT3cL9ZTA11CCsEryRkyZpjsfa/kmLU8cGOJ9I4bXkiEU6im QuL0TKEPhB4Gac55/X3sH0pgs6SfZbf3tDa0nqiFxqy+aTVTV/AkZFLocM7xnS4Yr39V TlEw== X-Gm-Message-State: AOAM532kkMp59BbRgzMp6uxtA1Dxc0EucXSz8O4W2XoH0PBXKZmrzz41 UKBnuVGHBdu87On7YLdoAaHVow== X-Google-Smtp-Source: ABdhPJyA8PlOfDHHxH/OqNVLLFns7QOhkyM6XRROGBV6oQogaZvQ9JL5vuO0S3f6KL+yexhcV87zBQ== X-Received: by 2002:a1c:7c0d:0:b0:37d:1e29:5cc6 with SMTP id x13-20020a1c7c0d000000b0037d1e295cc6mr20767654wmc.31.1645445324664; Mon, 21 Feb 2022 04:08:44 -0800 (PST) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a8sm11821546wra.0.2022.02.21.04.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 04:08:44 -0800 (PST) From: Corentin Labbe To: herbert@gondor.apana.org.au, jernej.skrabec@gmail.com, linus.walleij@linaro.org, narmstrong@baylibre.com, ulli.kroll@googlemail.com, wens@csie.org Cc: linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Corentin Labbe Subject: [PATCH 5/5] crypto: engine: check if BH is disabled during completion Date: Mon, 21 Feb 2022 12:08:33 +0000 Message-Id: <20220221120833.2618733-6-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221120833.2618733-1-clabbe@baylibre.com> References: <20220221120833.2618733-1-clabbe@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org When doing iperf over ipsec with crypto hardware sun8i-ce, I hit some spinlock recursion bug. This is due to completion function called with enabled BH. Add check a to detect this. Fixes: 735d37b5424b ("crypto: engine - Introduce the block request crypto engine framework") Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index fb07da9920ee..6056a990c9f2 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -53,6 +53,7 @@ static void crypto_finalize_request(struct crypto_engine *engine, dev_err(engine->dev, "failed to unprepare request\n"); } } + lockdep_assert_in_softirq(); req->complete(req, err); kthread_queue_work(engine->kworker, &engine->pump_requests);