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 8690DC00528 for ; Fri, 4 Aug 2023 13:17:03 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eqXJ7sY+2J4H6dDy71dwx3FmfV5a5Sh9T3ZS2wVdkuM=; b=p0RJytFc0de3ZX /BCXUzDCocop+A0I1Jl/J4uT4Poe/9X/U0NaHSS0sFvox4jUveTlYVEvNaZiOOC6kkGazBjGXiXs/ Icy5LHJ16YIHEzujbKnJ35yRJIxrBqZtWn5QZA9pUJtBywryWO4y36B0CAFRvVRoZsQOAF4cZ/l0J k/qFOeMIoxg9Il9mTsi801fegpBpnY7lWxmCLfNrMZEinyet9/WnkN/Lxst0l0zPMXnKaksebHw1y LqCf6jDnyeZy2KBXpk/dyDdg3fibjm9aW21Goz34y/w+AuNWrRJGylki5qS1+K9mM2/DqFKtSqMcV kryPIcrZooWrlPNTBdew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRufY-00CTWd-0S; Fri, 04 Aug 2023 13:16:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRufU-00CTVa-2Q for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2023 13:16:38 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 223851007; Fri, 4 Aug 2023 06:17:15 -0700 (PDT) Received: from [10.1.197.1] (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 668A33F5A1; Fri, 4 Aug 2023 06:16:31 -0700 (PDT) Message-ID: Date: Fri, 4 Aug 2023 14:16:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 1/1] coresight: tmc: Explicit type conversions to prevent integer overflow Content-Language: en-US To: Ruidong Tian , linux-kernel@vger.kernel.org Cc: alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org, james.clark@arm.com References: <20230714084349.31567-1-tianruidong@linux.alibaba.com> <20230804081514.120171-1-tianruidong@linux.alibaba.com> <20230804081514.120171-2-tianruidong@linux.alibaba.com> From: Suzuki K Poulose In-Reply-To: <20230804081514.120171-2-tianruidong@linux.alibaba.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230804_061636_834898_FB903B28 X-CRM114-Status: GOOD ( 11.90 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 04/08/2023 09:15, Ruidong Tian wrote: > Perf cs_etm session executed unexpectedly when AUX buffer > 1G. > > perf record -C 0 -m ,2G -e cs_etm// -- > [ perf record: Captured and wrote 2.615 MB perf.data ] > > Perf only collect about 2M perf data rather than 2G. This is becasuse > the operation, "nr_pages << PAGE_SHIFT", in coresight tmc driver, will > overflow when nr_pages >= 0x80000(correspond to 1G AUX buffer). The > overflow cause buffer allocation to fail, and TMC driver will alloc > minimal buffer size(1M). You can just get about 2M perf data(1M AUX > buffer + perf data header) at least. > > Explicit convert nr_pages to 64 bit to avoid overflow. > > Fixes: 22f429f19c41 ("coresight: etm-perf: Add support for ETR backend") > Signed-off-by: Ruidong Tian > Reviewed-by: James Clark > --- > drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- > drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +++-- > drivers/hwtracing/coresight/coresight-tmc.h | 2 +- > 3 files changed, 5 insertions(+), 4 deletions(-) Added additional Fixes tags as required and pushed it here : https://git.kernel.org/coresight/c/fd380097cdb3 Thanks! Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel