From patchwork Fri Jun 8 07:05:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10453905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 62AA960234 for ; Fri, 8 Jun 2018 07:05:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ECA02939B for ; Fri, 8 Jun 2018 07:05:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 422F029423; Fri, 8 Jun 2018 07:05:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED3132939B for ; Fri, 8 Jun 2018 07:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=OroWb4TXT9BJvjR5isN76ZNDoBIxp6jZ44NFBoTvXfA=; b=pcs Vtc/7SntqFME4BzhreZdFridWEYPGZPpAud038W8KfoEIHI4zjy7J6HvlfIVx+CN8eJxdPNPX4QFA yO47tA3PK4YVe0u+qy+GMTbGQ4SDACne36eW4/gxEZw7YBTen4A1IbXEOdS8egQEO0gTO7fJOXuAu GRv/kmtvgC9HEjXAzj2l8IHn4zBU+eQsmk2U7HAXil5ba96wjdsUlyhr8qnN6l3Jm5npEberi/pnp QCKEsOi7DVSrUPqOQ5oBWiUneGkhHLglw0CvLra9vNrnW0NDsOgnzSMmqeMzjsUHoRve70k+pHCET cxhrjCXNlYMmZZLIE8iPBB/VMV/O16Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fRBSq-00040N-In; Fri, 08 Jun 2018 07:05:36 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fRBSl-0003WJ-EO for linux-arm-kernel@lists.infradead.org; Fri, 08 Jun 2018 07:05:34 +0000 Received: by mail-pf0-x244.google.com with SMTP id z24-v6so6163680pfe.7 for ; Fri, 08 Jun 2018 00:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LHL0UECHJ24BrLTz8hu3oQlxD3ARE+CVXen9dRGUPRg=; b=tzvIDeax9YO1xtwwbN6Ys2jI9OTdCFRbIExsfLpHLY3kj7yX6/jioZ/Y8pDLbxDs3/ RUwU3y4Ph0HtA2h8AEpCEOrpA77KLMNodBsAjEkkKf0QFrNjRZ5FuFW7iB6qgMaXfkwm h10uc0AtK4STjJa8e6i8kjVfCBVZklCQVBYb6gwL4YQW+5mjjBcCuJGiKRsxwcVadSRe fLQsCcHECzEFBbUJyDBwzOzj+JUXb2Vw2wqHmFJes79/hxO4seaImoWPFZ/NtuXbt61v vU/bTMF4cWlRVvnfjlvkZddUm5OLNvnYVQ9HOPmMP3TDU7+T8rN1Qar0WhyDH6zNO4Da pSNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LHL0UECHJ24BrLTz8hu3oQlxD3ARE+CVXen9dRGUPRg=; b=k+C6SJnmR/NL3BFOxxKEU9uQQ8je/9SGoZxnwSGx0zoP2leRnoHPMJToQSUuvE3aat qtVgEvgVz21G0hgaTlfI7VnqsrPS3MWPBdLgLyMx/Z0LoO++hFg9OdZ1D7Vp0hHrgu8O KJl8etmEBVhbNSDUsKnwXB0Al2rW30qTc1a3vpoZ8LXBlPYQEHHp5gWyc+XgbWNlhE7K NVMgcgDoR0zddQJtR8Sjm7w6kvVIy/RRKx7EUqH42s/vwZ3vMWMMilU0L5yPBLRkmrHV wzrao+LecZgU0ZrSWRtuXBW6DsDsE7MyGkQnIQKXqNClycrIAeR9CjdXa6WJtivb0Mbw MU4g== X-Gm-Message-State: APt69E2PP/2d8BlkiI8xzj2F7VQSRPfsphRJwekhZA0HeVwI3kmXbMhG VL0ZcRNgXblHs37XpDWHSAA= X-Google-Smtp-Source: ADUXVKKbqWudQils/l2NgsbWJ1GbH/YRZHcVKxaACvswuyOj6hdCjhaSyL06Pv1RjmDu3mnnHIK2Xg== X-Received: by 2002:a62:b02:: with SMTP id t2-v6mr4803492pfi.36.1528441520242; Fri, 08 Jun 2018 00:05:20 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id v27-v6sm12400836pfi.23.2018.06.08.00.05.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 00:05:19 -0700 (PDT) From: Jia He To: Herbert Xu , "David S. Miller" , Catalin Marinas , Will Deacon Subject: [PATCH] crypto: arm64/aes-blk - fix and move skcipher_walk_done out of kernel_neon_begin, _end Date: Fri, 8 Jun 2018 15:05:02 +0800 Message-Id: <1528441502-26425-1-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180608_000531_506386_9F178895 X-CRM114-Status: GOOD ( 11.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jia.he@hxt-semitech.com, Jia He , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In a arm64 server(QDF2400),I met a similar might-sleep warning as [1]: [ 7.019116] BUG: sleeping function called from invalid context at ./include/crypto/algapi.h:416 [ 7.027863] in_atomic(): 1, irqs_disabled(): 0, pid: 410, name: cryptomgr_test [ 7.035106] 1 lock held by cryptomgr_test/410: [ 7.039549] #0: (ptrval) (&drbg->drbg_mutex){+.+.}, at: drbg_instantiate+0x34/0x398 [ 7.048038] CPU: 9 PID: 410 Comm: cryptomgr_test Not tainted 4.17.0-rc6+ #27 [ 7.068228] dump_backtrace+0x0/0x1c0 [ 7.071890] show_stack+0x24/0x30 [ 7.075208] dump_stack+0xb0/0xec [ 7.078523] ___might_sleep+0x160/0x238 [ 7.082360] skcipher_walk_done+0x118/0x2c8 [ 7.086545] ctr_encrypt+0x98/0x130 [ 7.090035] simd_skcipher_encrypt+0x68/0xc0 [ 7.094304] drbg_kcapi_sym_ctr+0xd4/0x1f8 [ 7.098400] drbg_ctr_update+0x98/0x330 [ 7.102236] drbg_seed+0x1b8/0x2f0 [ 7.105637] drbg_instantiate+0x2ac/0x398 [ 7.109646] drbg_kcapi_seed+0xbc/0x188 [ 7.113482] crypto_rng_reset+0x4c/0xb0 [ 7.117319] alg_test_drbg+0xec/0x330 [ 7.120981] alg_test.part.6+0x1c8/0x3c8 [ 7.124903] alg_test+0x58/0xa0 [ 7.128044] cryptomgr_test+0x50/0x58 [ 7.131708] kthread+0x134/0x138 [ 7.134936] ret_from_fork+0x10/0x1c Seems there is a bug in Ard Biesheuvel's commit. Fixes: 683381747270 ("crypto: arm64/aes-blk - move kernel mode neon en/disable into loop") [1] https://www.spinics.net/lists/linux-crypto/msg33103.html Signed-off-by: jia.he@hxt-semitech.com Acked-by: Ard Biesheuvel --- arch/arm64/crypto/aes-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index 253188f..e3e5095 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c @@ -223,8 +223,8 @@ static int ctr_encrypt(struct skcipher_request *req) kernel_neon_begin(); aes_ctr_encrypt(walk.dst.virt.addr, walk.src.virt.addr, (u8 *)ctx->key_enc, rounds, blocks, walk.iv); - err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE); kernel_neon_end(); + err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE); } if (walk.nbytes) { u8 __aligned(8) tail[AES_BLOCK_SIZE];