Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2438988rdh; Wed, 27 Sep 2023 02:40:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFZ/iZuX5oN8hDEKt+W3rkPPO9jzmnyGN8B1+nTSvqBRRSPY93SfsURthSDKtdxpHnRz/U X-Received: by 2002:a05:6808:2a78:b0:3ae:251f:923f with SMTP id fu24-20020a0568082a7800b003ae251f923fmr1870624oib.28.1695807621515; Wed, 27 Sep 2023 02:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695807621; cv=none; d=google.com; s=arc-20160816; b=lIZUqR7T3YJ5uorNz/cM77njWw+LUIScZp2gkgxRq4C3RvdbJiRcYSQSboXUECsw/6 KOYpGJ5NcSdZhkMhhZk+IASXIfb8S2oJwqS5bzGFFt4NttSVfnN7QgLIhuSd8CYHjH+O Ojvzrvsen0ge2bOdl5m92/A3Gu4ZAHHFkzQltnWL4xT+D+fvzWKBUh/oxRgnBm0lxbAJ RINHoIwBUVODy4Ku+QndB+yDxAm1ERzGB1AdyISxxaY77vmtGvDEvMyKMmb+xXAFNqKq nuBqq9LmfFz71M5NEm39YXCESM1TDuveHjn0SQ/5Y7zC6x5BHtTYuqKVXXOvhjccH6bB DKSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=h9kTIuLPzANy/zGz7zIwzLLPdRWQDpJHsXRzyRuV2WQ=; fh=24qff62n/Jk8sVhv4mu+WWcmTNFnM1pGNRqpBhGH1c8=; b=pOYAXp+2vouz1YplFqYll1Sbr/jAfYC0hG1gevLmj5FG9NuR+GI1BfYezBHICHwpMc lk2TJTVLX4yDmE2A+xeSj42z7QZ+QNaNgoqc4b7/IiS80rieE3JJW8wL/6lH72/+oFsm 1UEC1Kt5/9ihLhAO1blLHPn7Zc013LSMcmpmHKRJoxlNFOkgp+5aVjIUT1nir0tZ2rmI bIdEziit/Byu4kqs/Y8DmWGK/fUFT+jkeLUGFNViaY2rkCdf5u7HN8atZgQlgIIjhoxr lJQgabRRtFQIiQGsBaDddz1HgcvJF9t45dAo5JhEehfmX2DFt8lp8oiJyGGwZOo74T7T 3YPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id n190-20020a6327c7000000b005637e28270fsi15312077pgn.243.2023.09.27.02.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 02:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9077880203C0; Wed, 27 Sep 2023 02:24:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbjI0JYP convert rfc822-to-8bit (ORCPT + 99 others); Wed, 27 Sep 2023 05:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjI0JYO (ORCPT ); Wed, 27 Sep 2023 05:24:14 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D278E97; Wed, 27 Sep 2023 02:24:12 -0700 (PDT) Received: from kwepemd200001.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RwWKJ6NZGztT57; Wed, 27 Sep 2023 17:19:48 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by kwepemd200001.china.huawei.com (7.221.188.2) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.23; Wed, 27 Sep 2023 17:24:09 +0800 Received: from dggpemm500006.china.huawei.com ([7.185.36.236]) by dggpemm500006.china.huawei.com ([7.185.36.236]) with mapi id 15.01.2507.031; Wed, 27 Sep 2023 17:24:09 +0800 From: "Gonglei (Arei)" To: "Michael S. Tsirkin" , Halil Pasic CC: Herbert Xu , "linux-crypto@vger.kernel.org" , Marc Hartmayer , Jason Wang , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "pizhenwei@bytedance.com" , Cornelia Huck Subject: RE: [PATCH] crypto: virtio-crypto: call finalize with bh disabled Thread-Topic: [PATCH] crypto: virtio-crypto: call finalize with bh disabled Thread-Index: AdnvwZyqMOU4LXJLQHSIVFGYJFXR5QAk7LIAAAEdD4AAMnHjIA== Date: Wed, 27 Sep 2023 09:24:09 +0000 Message-ID: <9564c220c8344939880bb805c5b3cac9@huawei.com> References: <1914739e2de14ed396e5674aa2d4766c@huawei.com> <20230926184158.4ca2c0c3.pasic@linux.ibm.com> <20230926130521-mutt-send-email-mst@kernel.org> In-Reply-To: <20230926130521-mutt-send-email-mst@kernel.org> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.149.11] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 02:24:26 -0700 (PDT) > -----Original Message----- > From: Michael S. Tsirkin [mailto:mst@redhat.com] > Sent: Wednesday, September 27, 2023 1:14 AM > To: Halil Pasic > Cc: Gonglei (Arei) ; Herbert Xu > ; linux-crypto@vger.kernel.org; Marc > Hartmayer ; Jason Wang > ; virtualization@lists.linux-foundation.org; > linux-kernel@vger.kernel.org; pizhenwei@bytedance.com; Cornelia Huck > > Subject: Re: [PATCH] crypto: virtio-crypto: call finalize with bh disabled > > On Tue, Sep 26, 2023 at 06:41:58PM +0200, Halil Pasic wrote: > > [..] > > > --- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c > > > +++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c > > > @@ -61,8 +61,9 @@ static void virtio_crypto_akcipher_finalize_req( > > > vc_akcipher_req->src_buf = NULL; > > > vc_akcipher_req->dst_buf = NULL; > > > virtcrypto_clear_request(&vc_akcipher_req->base); > > > - > > > + local_bh_disable(); > > > > > > crypto_finalize_akcipher_request(vc_akcipher_req->base.dataq->engine > > > , req, err); > > > + local_bh_enable(); > > > > Thanks Gonglei! > > > > I did this a quick spin, and it does not seem to be sufficient on s390x. > > Which does not come as a surprise to me, because > > > > #define lockdep_assert_in_softirq() > \ > > do > { > \ > > WARN_ON_ONCE(__lockdep_enabled && > \ > > (!in_softirq() || in_irq() || in_nmi())); \ > > } while (0) > > > > will still warn because in_irq() still evaluates to true (your patch > > addresses the !in_softirq() part). > > > > I don't have any results on x86 yet. My current understanding is that > > the virtio-pci transport code disables interrupts locally somewhere in > > the call chain (actually in vp_vring_interrupt() via > > spin_lock_irqsave()) and then x86 would be fine. But I will get that verified. > > > > On the other hand virtio_airq_handler() calls vring_interrupt() with > > interrupts enabled. (While vring_interrupt() is called in a (read) > > critical section in virtio_airq_handler() we use read_lock() and not > > read_lock_irqsave() to grab the lock. Whether that is correct in it > > self (i.e. disregarding the crypto problem) or not I'm not sure right > > now. Will think some more about it tomorrow.) If the way to go forward > > is disabling interrupts in virtio-ccw before vring_interrupt() is > > called, I would be glad to spin a patch for that. > > > > Copying Conny, as she may have an opinion on this (if I'm not wrong > > she authored that code). > > > > Regards, > > Halil > > On a related note, config change callback is also handled incorrectly in this > driver, it takes a mutex from interrupt context. Good catch. Will fix it. Thanks. -Gonglei