From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0291CC433F5 for ; Tue, 18 Jan 2022 07:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HDgh48V4+MutaDBaX4O3nhUFNfic+ziLkVNgZ958w8M=; b=uFtgLNHdN/58VQ c3YuThQchpPvH18hNuDF/RV/qt6bhMKvDS1tpnp6LvFh+dhHX/P+FPkNqoCMoxZmEh+g7gyBO/mBe S+DHllCQ6R7WBmJiqCsUIGMha3dLy9SErQrkWIsG7M1r4E5eYkgx9MymGKkGK0sycNOLN3Wu8Nb1k rXuA3cPrBfbXmsVdt1aWS7TrYvsynJa2n/9oVbl+ZB/mFD6tuZx1V8chxpxSMfky15z2KF02v4iRl lbGF4CzVvYVqsIGURDs7y9t92b/DnvWDs+a8aErOnOYnB/aiUm5x1N8p0vTQGOUVV7VE/R0L3EBHm qRwDgoOIx6ImDtPTAxug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9jIr-000e55-QL; Tue, 18 Jan 2022 07:53:17 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9jIn-000e1k-Nv for linux-arm-kernel@lists.infradead.org; Tue, 18 Jan 2022 07:53:15 +0000 Received: by mail-wm1-x330.google.com with SMTP id p18so25658672wmg.4 for ; Mon, 17 Jan 2022 23:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=44gDUy5K3yK/LK4CWy+8U+XmfAKikin5v6yugPO1Ses=; b=ahdRawPXnNwZHQJ7XdWYHeN8ha0g7ktxwX4TqGc1Q96DuaKS9IIZGSt/GQwRtlRzgz jY2TU0FA6Pau7F/lSiiQ758/fXd/GgdWrT6hpk6+E0nK47CsoyUhd6uRM8+imohlV2pW mnBdC6TE9/abfA3PxXSRt05p8pAVlLtK7vbfjkEScjBJfHmE6GovLpxL3m9/y/9S8LAU NxGKtC5FQVSsl4hrkMQO5XtG397tcMFM1CrSXHWDQPYA3cbTBjq+1mz+3vTZUchV+t6Q 2AFvMB5K43jqXI9UIQ96zrgdA/2ZirZAmwPgaDdt0cUptzKVUJulgWblRiwsD3qvHMvU 1J2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=44gDUy5K3yK/LK4CWy+8U+XmfAKikin5v6yugPO1Ses=; b=RcAOL7/RgfvPn4AAAD2p/oOdVr4lUo6XGC2lxZI+GQfg6L3Bmag207zz8qwv2hYB+1 DHyxryS3GcV9qCy7KY162a5aEuvNpkmQn8RqYxGTwFSjaxwz5dKxywjKOvRQetJ3LEdx HQoxxWuoY5/Js5rp/4ikEtcfIXZe3ZFbogKap1gbliEp6FasHgGlihOZIW0JaBqnwMmr A829qzAn18n2RKXGMDRj72xbetDah88FcFnJCwWK9IWnOvpOBNmcJDzHa23rsOj7BzEc IIaQ8SZG2KZbbTHKdf6bcJiOcCflBLvuYNY4bjePdFaPMvmb0jjPcnEyWShbK7zqoq+F 6JzA== X-Gm-Message-State: AOAM530+fJ0+FF36BagF6VC4WHlvOepslEsBAIXFOVIRX3OqhHHzzu3H lU+hgmbjxPcBklXfQdJYjl4= X-Google-Smtp-Source: ABdhPJxuyCwEFsb4U7fwu4plIZDcfgaLFcVBLRDOZi4dnWLUdxTtxoKSOwiT8sVgD2qQgVIpkihQsA== X-Received: by 2002:a05:600c:2113:: with SMTP id u19mr23489123wml.16.1642492375722; Mon, 17 Jan 2022 23:52:55 -0800 (PST) Received: from Red ([2a01:cb1d:3d5:a100:264b:feff:fe03:2806]) by smtp.googlemail.com with ESMTPSA id r19sm1542277wmh.42.2022.01.17.23.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 23:52:55 -0800 (PST) Date: Tue, 18 Jan 2022 08:52:53 +0100 From: Corentin Labbe To: Herbert Xu Cc: davem@davemloft.net, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: crypto: BUG: spinlock recursion when doing iperf over ipsec with crypto hardware device Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220117_235313_809630_2CA0ADD2 X-CRM114-Status: GOOD ( 21.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Le Fri, Jan 14, 2022 at 08:12:26AM +0100, Corentin Labbe a =E9crit : > Le Fri, Jan 14, 2022 at 03:23:26PM +1100, Herbert Xu a =E9crit : > > On Fri, Jan 14, 2022 at 03:14:38PM +1100, Herbert Xu wrote: > > > On Tue, Jan 11, 2022 at 10:47:12AM +0100, Corentin Labbe wrote: > > > > > > > > [ 44.646050] [] (__irq_svc) from [] (xfrm_rep= lay_advance+0x11c/0x3dc) > > > > [ 44.654143] [] (xfrm_replay_advance) from []= (xfrm_input+0x4d0/0x1304) > > > > [ 44.662408] [] (xfrm_input) from [] (crypto_= finalize_request+0x5c/0xc4) > > > > [ 44.670766] [] (crypto_finalize_request) from [] (sun8i_ce_cipher_run+0x34/0x3c) > > > > [ 44.679900] [] (sun8i_ce_cipher_run) from []= (crypto_pump_work+0x1a8/0x330) > > > = > > > So did sun8i_ce_cipher_run ensure that BH is disabled before > > > invoking xfrm_input? If not then this explains the dead-lock. > > = > > The issue appears to be with crypto_engine. It needs to ensure > > that completion functions are called with BH disabled, not IRQ > > disabled and definitely not BH enabled. > > = > = > Hello > = > This minimal patch fix my issue, does it is the rigth way ? > = > Thanks for your help > Regards > = > diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c > index fb07da9920ee..b3844f6d98a3 100644 > --- a/crypto/crypto_engine.c > +++ b/crypto/crypto_engine.c > @@ -7,6 +7,7 @@ > * Author: Baolin Wang > */ > = > +#include > #include > #include > #include > @@ -53,7 +54,9 @@ static void crypto_finalize_request(struct crypto_engin= e *engine, > dev_err(engine->dev, "failed to unprepare= request\n"); > } > } > + local_bh_disable(); > req->complete(req, err); > + local_bh_enable(); > = > kthread_queue_work(engine->kworker, &engine->pump_requests); > } > = Hello With my patch, I got: [ 38.515668] BUG: sleeping function called from invalid context at crypto= /skcipher.c:482 [ 38.523708] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 84, n= ame: 1c15000.crypto- [ 38.532176] preempt_count: 200, expected: 0 [ 38.536381] CPU: 6 PID: 84 Comm: 1c15000.crypto- Not tainted 5.16.0-next= -20220115-00124-g13473e8fac33-dirty #116 [ 38.546551] Hardware name: Allwinner A83t board [ 38.551100] unwind_backtrace from show_stack+0x10/0x14 [ 38.556358] show_stack from dump_stack_lvl+0x40/0x4c [ 38.561428] dump_stack_lvl from __might_resched+0x118/0x154 [ 38.567107] __might_resched from skcipher_walk_virt+0xe8/0xec [ 38.572955] skcipher_walk_virt from crypto_cbc_decrypt+0x2c/0x170 [ 38.579147] crypto_cbc_decrypt from crypto_skcipher_decrypt+0x38/0x5c [ 38.585680] crypto_skcipher_decrypt from authenc_verify_ahash_done+0x18= /0x34 [ 38.592825] authenc_verify_ahash_done from crypto_finalize_request+0x6c= /0xe4 [ 38.599974] crypto_finalize_request from sun8i_ss_hash_run+0x73c/0xb98 [ 38.606602] sun8i_ss_hash_run from crypto_pump_work+0x1a8/0x330 [ 38.612616] crypto_pump_work from kthread_worker_fn+0xa8/0x1c4 [ 38.618550] kthread_worker_fn from kthread+0xf0/0x110 [ 38.623701] kthread from ret_from_fork+0x14/0x2c [ 38.628414] Exception stack(0xc2247fb0 to 0xc2247ff8) [ 38.633468] 7fa0: 00000000 00000000 = 00000000 00000000 [ 38.641640] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 = 00000000 00000000 [ 38.649809] 7fe0:i 00000000 00000000 00000000 00000000 00000013 00000000 This is when testing hmac(sha1) on my crypto driver sun8i-ss and crypto tes= ting authenc(hmac-sha1-sun8i-ss,cbc(aes-generic)). Do you have any idea to better fix my issue ? Regards _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel