Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3256028rwo; Fri, 4 Aug 2023 01:46:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqToOPvtJCXwFcUARlME0eN4MRpEYTxIGM7KnSH/ghb50PYWl7uT2LAVFiB1o0GMRGpKHU X-Received: by 2002:a17:903:1107:b0:1b8:4f93:b210 with SMTP id n7-20020a170903110700b001b84f93b210mr1280102plh.45.1691138791284; Fri, 04 Aug 2023 01:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691138791; cv=none; d=google.com; s=arc-20160816; b=vhp6u5mFi8xWEjhKHKyXb9wwk3sozuhKV1zZjL8rIg0WnWpQYWQ0/ist1HnpYypsbi n5K8rHgdwzg82Xg+Ne2FsBXvLT84+3cOi90Fzfa5ZOohr6i7sFYUrFQmfYWwdOWoyXdG ofRtWMtenrwFOfnQRn8+iy6yofrkLaJSCSoNuPk7MsC4CIdYbMwWOZjrshaqIQbwci2L EZteJGZaxgwi6E0WZFO+8WlTAwL1o4K7thPMWy/EkTWvPkynArePyeP2g0sbGB0pF3OT 7dI1jix2U5GwD6OuoqMr1qrwmfF/w6YBTxWgAo/fZv1JFr3/7oeFYcy5kmnM+wlCZ5HN hhQg== 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=bBcIF0QEdydGl3/FGdQPiiI4OhWY5eIJvMgJGB6mCm4=; fh=LKLX59HcJ2CQdeGZoBuQOQ27p+qXqfA7CYen3cQobjs=; b=Ao9Ar2ENV1197g2/y2AANeFHICZw33jik3rzdQFOmdR3kZddRkQgcIvVaBgtEz5lh8 DbKQpFgAyXc1iPy/IBCVfhYUcn8RPqMQE1+AvZGd3zM8L/yr2u0SDqAHWmAfa3BLzEGZ dex2y2WbOC/NKMjB6DXMo3HpAG2aWjV0KwVpQ/8m7BRWmIWCC+Fgn6CYWtIaC/6Kibj0 3TFnLQyy/k2mEzn8vTeTIXdI9jujt9lgQGlfiVCBsu1t0rV1qQgHljm1CzMpX9m9wXri Q9NNO6+al2S4XQxDIxNI6JigBZSPuNChXjAS/b2GXO2Vof2nwKhhsMgotrO8lKV1MsTG dFEA== 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=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a170902d4c500b001b9e8ebe5a0si1502660plg.613.2023.08.04.01.46.19; Fri, 04 Aug 2023 01:46:31 -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=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234425AbjHDIP1 (ORCPT + 99 others); Fri, 4 Aug 2023 04:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbjHDIP0 (ORCPT ); Fri, 4 Aug 2023 04:15:26 -0400 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E01912B for ; Fri, 4 Aug 2023 01:15:24 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R791e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=tianruidong@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vp.kW45_1691136918; Received: from localhost(mailfrom:tianruidong@linux.alibaba.com fp:SMTPD_---0Vp.kW45_1691136918) by smtp.aliyun-inc.com; Fri, 04 Aug 2023 16:15:20 +0800 From: Ruidong Tian To: linux-kernel@vger.kernel.org Cc: tianruidong@linux.alibaba.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org, suzuki.poulose@arm.com, james.clark@arm.com Subject: [PATCH v3 0/1] coresight: tmc: Explicit type conversions to Date: Fri, 4 Aug 2023 16:15:13 +0800 Message-Id: <20230804081514.120171-1-tianruidong@linux.alibaba.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20230714084349.31567-1-tianruidong@linux.alibaba.com> References: <20230714084349.31567-1-tianruidong@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_IN_DEF_SPF_WL 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 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 in tmc driver to avoid overflow. Changes in V2: Suzuki K Poulose: Add another 2 places where needed to fix. Changes in V1: James Clark: Use a more accurate commit message. Ruidong Tian (1): coresight: tmc: Explicit type conversions to prevent integer overflow 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(-) -- 2.33.1