Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1798755pxv; Sat, 26 Jun 2021 00:31:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYS1j/ISiyUVGwg4m2ohJPjvm2/PlIV3Xx7kyzu5G4onMwIguO29XszaHPIbaAO33rKfUZ X-Received: by 2002:a05:6402:1355:: with SMTP id y21mr20335777edw.136.1624692687560; Sat, 26 Jun 2021 00:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624692687; cv=none; d=google.com; s=arc-20160816; b=CknkAdyVesX/zdudjpZLkSVD+FwqZ7GywEgvgvilfX50+dbja0h0bXv5OVqHkGN7n5 GP5FakmjHSNfyo8KnWKFv6rFGjkQ6pe0K5aJe80W538qSU4pGxCieZVQFSqVhKdr69kf j8KjlfJDFsMN71el0lvD9Me2nwZsofNWXUluUoVnkR7mOPKDv7RtDUag7AQ5vcvGbTO4 6KsAi+wrb0FpucwSQdj19iodIGCsC3gWV8m4v3+fcSVtfU0r1/2ddpSyftMKn/Ph4k98 y++43XE94u7IUAC5ggTn7cnBYKmOtF+U4Tgrn19XqMKh+j2sNePyqWbQgYNrAmPNk9OT wqBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mjDLP5821su1Co5TNqUMJ6V2htgKy7XU9YSgJBp4Dx0=; b=K4REzmRZJ/1TmoSbA+Uau9FIt04Oe//o4nH8rEJkAzGVB7JKRf+pejCEpPTIXf2Kb8 5iIDRzi15ea/cx+3+Ohweb60cLJgIouN7ehtihKeTHr69c1kSIv9IWu8+v5Voz2pqUzx aMk/neVQMIC4JmXeW0VQbodRFng8BfUXbY4rQv7VpwtJ9aosOIVL1sq0ieHX+cODF+Kz LbkEotoKdt0CQXUgG+trSz66e7sCi8EZcVgZB+cWEHcZk3g1TK7Qdr7M6ds4O++fTKxU dFMiswvTX5sClSepMhou5Ziu+gzGchwnN4q55162eZcUPGpYGetRv18cBRtLGkOW6hNZ 7ZPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si8809011edy.555.2021.06.26.00.31.04; Sat, 26 Jun 2021 00:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbhFZH3u (ORCPT + 99 others); Sat, 26 Jun 2021 03:29:50 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:5437 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbhFZH33 (ORCPT ); Sat, 26 Jun 2021 03:29:29 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GBljH58MFz74Wq; Sat, 26 Jun 2021 15:23:47 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 26 Jun 2021 15:27:02 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 26 Jun 2021 15:27:01 +0800 From: Kefeng Wang To: Arnd Bergmann , , CC: Kefeng Wang , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Subject: [PATCH 9/9] dma-debug: Use memory_intersects() directly Date: Sat, 26 Jun 2021 15:34:39 +0800 Message-ID: <20210626073439.150586-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210626073439.150586-1-wangkefeng.wang@huawei.com> References: <20210626073439.150586-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use memory_intersects() directly instead of private overlap() function. Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: iommu@lists.linux-foundation.org Signed-off-by: Kefeng Wang --- kernel/dma/debug.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c index 14de1271463f..8ef737223999 100644 --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -1066,20 +1066,10 @@ static void check_for_stack(struct device *dev, } } -static inline bool overlap(void *addr, unsigned long len, void *start, void *end) -{ - unsigned long a1 = (unsigned long)addr; - unsigned long b1 = a1 + len; - unsigned long a2 = (unsigned long)start; - unsigned long b2 = (unsigned long)end; - - return !(b1 <= a2 || a1 >= b2); -} - static void check_for_illegal_area(struct device *dev, void *addr, unsigned long len) { - if (overlap(addr, len, _stext, _etext) || - overlap(addr, len, __start_rodata, __end_rodata)) + if (memory_intersects(_stext, _etext, addr, len) || + memory_intersects(__start_rodata, __end_rodata, addr, len)) err_printk(dev, NULL, "device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len); } -- 2.26.2