Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5531359rwb; Wed, 7 Sep 2022 04:28:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR7E0+nhhs0qXbFt2VadOeVBPFT14xtShBvlCoiOcGD60KwUENqffPw6fQ9OEKYGOzWO4Miw X-Received: by 2002:a17:902:cf11:b0:172:6437:412e with SMTP id i17-20020a170902cf1100b001726437412emr3082249plg.77.1662550107633; Wed, 07 Sep 2022 04:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662550107; cv=none; d=google.com; s=arc-20160816; b=zzIoK/+MR4/XthENOcz/OvF4EbMcq+Ows0CWktCdKDIDDXbdvsBlP1n0X1QGLCWCOZ UrHwFVXuySg4pkTqun6bHRCl3BdLrqPoFgh1jB1myvELtYXNKqLd/eGOG2EFgKzHqUQ3 Rq6FAfB9cKQuyTOjkQo41WGLdUCB+5b+GT/OPq30cO4dvV8mcw6zhnflUXFHxhNNyp2R vInSRDcztdEN2NraAwldhSm9IdaEaIKHnWPeg7YFKC0YIEprcXenPxtQCf+/loGmuXag eLbeTTWxCbD1/mNihQuLyh7eSdSv5O60tMfs6suo+Pza8PrtyFwOSTOgjhsSVLiPBZ8I YEeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=E7vxwU40HUYshwmePO78Qp0LeiOo7O5DJ6XxyHsrB3M=; b=kO8OxUjVptfmYCznilU0YpdBKQ8BjqaqgYs1b1ZtHB5yxBN7BTN+c/QdW4NfORhfjG Ap98eNYotu9DH3ltUkUOsQ8s2jPVcSJUxKDLJT6ad6jNMQ5d6GfDKOuhB6BUI3JiK2xd 4ynoZl466XudKz/jFFgLHbgZem3XSzcIz6uwsYkH+5rje9p2dRpGlN1yDwT8KXtR+BvP hEOrGYuKmbKxFzqhQ7s4v2lTL4SrfJBu0hjktHBWzunbNlHNPfhVeCOKe/lzU4nrcl4w HN+H5CuntAkj0QOW+MkaUR7yUZiTtHU4SfXsxGcs3HukZoAmbM0z5EAW2Fjb5DfojCyC xC5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a634801000000b00415fcde211asi16442496pga.556.2022.09.07.04.28.15; Wed, 07 Sep 2022 04:28:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbiIGKK4 (ORCPT + 99 others); Wed, 7 Sep 2022 06:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiIGKKz (ORCPT ); Wed, 7 Sep 2022 06:10:55 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58DA04DB32 for ; Wed, 7 Sep 2022 03:10:54 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MMyg42hXcz67vlM; Wed, 7 Sep 2022 18:10:08 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Wed, 7 Sep 2022 12:10:51 +0200 Received: from [10.202.227.197] (10.202.227.197) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 7 Sep 2022 11:10:51 +0100 Message-ID: Date: Wed, 7 Sep 2022 11:10:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v2 1/2] iova: Remove some magazine pointer NULL checks To: Ethan Zhao , Robin Murphy , , CC: , , References: <1662369083-238529-1-git-send-email-john.garry@huawei.com> <1662369083-238529-2-git-send-email-john.garry@huawei.com> <1d80f56c-bef7-6e5f-0bca-dad35f5e5a8e@linux.intel.com> <3fa23318-6fa7-eba0-30b8-1fb71e6c327e@huawei.com> <555fa5aa-a575-d783-dc97-79f63dcf2f57@arm.com> From: John Garry In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.202.227.197] X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On 07/09/2022 10:58, Ethan Zhao wrote: Hi Ethan, >> Or also add this: >> >> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c >> index 0d6d8edf782d..e8f0b8f47f45 100644 >> --- a/drivers/iommu/dma-iommu.c >> +++ b/drivers/iommu/dma-iommu.c >> @@ -578,6 +578,12 @@ static int iommu_dma_init_domain(struct >> iommu_domain *domain, dma_addr_t base, >>              goto done_unlock; >>          } >> >> +        if (!iovad->rcaches) { >> +            pr_warn("IOVA domain rcache not properly initialised\n"); >> +            ret = -EFAULT; >> +            goto done_unlock; >> +        } >> + >>          ret = 0; >>          goto done_unlock; >> > If the iovad->rcaches allocation failed, will skip iommu domain dma ops, > so no need *any* iovad,->rcaches check, right ? > > and there is already warning about the fallback. It's not as simple as that. We use the iovad->start_pfn member as a flag for the IOVA domain being initialized. However that does not mean always properly initialized. As above, the rcache init may fail, but in this case we still set start_pfn. This comes into play when we have multiple devices in the same IOMMU group, for example, as I mentioned yesterday. Thanks, John