From mboxrd@z Thu Jan 1 00:00:00 1970 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 675F5C77B73 for ; Thu, 27 Apr 2023 22:11:59 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ie1ri6v9PCLb6GFMtrOaxxb8CP3e/vDzEytawbtPaW8=; b=2OvmM8Ba4jh9Tk F5gr9/8SRET8rLBaDgfRf158BsFHTkhm4Jg3o9pUk2C/GzzkvwOM5LgKIHbJP/JsbayxCT1P74/Ik lJUcaTiEggtWGFJUKopzfrwM0ebtzO8ZPc96BLy1zcI/zQ7qa413LGkagFjYNEIR8RTMGCotwYoYw +XnUhL8X2Uhz2vUgOE+bRUyNxcORXtNPvQLrKSpcSFUTKJDMKIqlquWf718FS+yQqXLZokAXXOd53 8pHrfYY0W4WcAn8VYZtF0ak4aKIFvYAY2+rJVW68HozxwOaa7nvT8FUP4jlzDAnnqEyq7d6dZZG0S Bod6UlXbOOzmRC9shG8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ps9pG-007fRE-32; Thu, 27 Apr 2023 22:10:54 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ps9pD-007fPu-2D for linux-arm-kernel@lists.infradead.org; Thu, 27 Apr 2023 22:10:53 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-50674656309so13944008a12.0 for ; Thu, 27 Apr 2023 15:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682633450; x=1685225450; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Oyoa/O+xLiuZWHEuPVWItqEbSS644YOhbq3/kpsTdWI=; b=uIkFDXD7Gl/5Hged7cy5WzDVEKQLJdxQEgEsJ1xG0dt//zGEZ5cf/fWM5ZrvvknWw7 MKEC9kJsNz6NlMHXpjgbBicFkyB7nyfyy7UO9UeHBQcQE/chBKOvcZrMBm98w8ldGdYW HOqP/UaJUCXG2mZsHlp+NOMZHlATpTFSQXMfXoYrzxfzb1JhvsWHRnHj13kK4uO220s+ Da/4UKrw12aOt9TdO24U2SLVIAGcQXRPY9X4O7w0hAHmvMm6lruS5PMvqzf/EKS16dqN o6xsG3K2AHYaZuHGdlu1z27vpSg2pjsncIWA+oRxD7Vy/qJ7XpEdDt5PM/rahjNBDk5J OP+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682633450; x=1685225450; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Oyoa/O+xLiuZWHEuPVWItqEbSS644YOhbq3/kpsTdWI=; b=domkOjcHXhyfRF+CS68Mj0HgfA6PwUAPojXfnXw9iMUTjX8woVpnJQFtLNRKDANaP1 7e91baxwKUzfvzsJeT7WvFYWYAK+WPwZe4FeAYVbRnuxhkSYusoC2z9/3GssQnToUItN Lsqgt6uWW+hChkY9Jgs4tXckmBgm8GohkzKKq9dqN8IIevL6m/V2LeDbjJoEUkOpc8uB rYWbFnHvUhfr2lSQuhAdD8AfYU40GwzWYJgoJ052XbY44JLPUEBPfq6HRCtBKGe1Kfjr 5913ban5IzJO5BQb9rBvWFKbJfNmA2VYlrJ/LMLcpP2E6jkdCoShJzJ4/IhIwEz1zKV8 /o+g== X-Gm-Message-State: AC+VfDyumomanAHesjN6gIw3+KWnAoiZacr8ruw2jrhyZlsr1NJmy3wR epv07B27ThtfNRUhHlJYFvnp+w== X-Google-Smtp-Source: ACHHUZ4DJDiASltZaBlAGInmkmTC8QVWuBREO5qpOYmqWvjKalZg/u0vzUfmhyTrDWjgz8+QGDtm8g== X-Received: by 2002:a17:907:701:b0:94f:865d:fb8d with SMTP id xb1-20020a170907070100b0094f865dfb8dmr3486711ejb.11.1682633449563; Thu, 27 Apr 2023 15:10:49 -0700 (PDT) Received: from leoy-huanghe ([195.167.132.10]) by smtp.gmail.com with ESMTPSA id pv22-20020a170907209600b0094f0025983fsm10330876ejb.84.2023.04.27.15.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 15:10:49 -0700 (PDT) Date: Fri, 28 Apr 2023 06:10:47 +0800 From: Leo Yan To: James Clark Cc: linux-perf-users@vger.kernel.org, coresight@lists.linaro.org, shy828301@gmail.com, denik@google.com, Mathieu Poirier , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/7] perf: cs-etm: Validate options after applying themperf_pmu__format_bits Message-ID: <20230427221047.GA174797@leoy-huanghe> References: <20230424134748.228137-1-james.clark@arm.com> <20230424134748.228137-5-james.clark@arm.com> <20230427151228.GA152865@leoy-huanghe> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230427_151051_743359_D9101AF4 X-CRM114-Status: GOOD ( 25.72 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 27, 2023 at 04:52:06PM +0100, James Clark wrote: [...] > >> -static int cs_etm_set_context_id(struct auxtrace_record *itr, > >> - struct evsel *evsel, int cpu) > >> +static int cs_etm_validate_context_id(struct auxtrace_record *itr, > >> + struct evsel *evsel, int cpu) > >> { > >> - struct cs_etm_recording *ptr; > >> - struct perf_pmu *cs_etm_pmu; > >> + struct cs_etm_recording *ptr = > >> + container_of(itr, struct cs_etm_recording, itr); > >> + struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; > >> char path[PATH_MAX]; > >> - int err = -EINVAL; > >> + int err; > >> u32 val; > >> - u64 contextid; > >> + u64 contextid = > >> + evsel->core.attr.config & > >> + (perf_pmu__format_bits(&cs_etm_pmu->format, "contextid1") | > >> + perf_pmu__format_bits(&cs_etm_pmu->format, "contextid2")); > > > > Seems to me, this would break backward compability. > > > > The old kernel (before 5.11) doesn't provide 'contextid1' and > > 'contextid2', so we always check the entry 'contextid' rather than > > 'contextid1' and 'contextid2'. > > > > With this change, if a kernel doesn't contain 'contextid1' and > > 'contextid2' formats, will perf tool never trace for contexid? > > > > No because I changed to to be purely validation, so the format flags > would still be applied. But yes I think you are right there is a small > issue. > > Now validation of 'contextid' isn't done on pre 5.11 kernels. But that > only checks for ETMv3 anyway. IIUC, 'contextid' is not only used for ETMv3. Just quotes the comments from drivers/hwtracing/coresight/coresight-etm-perf.c: 73 /* 74 * contextid always traces the "PID". The PID is in CONTEXTIDR_EL1 75 * when the kernel is running at EL1; when the kernel is at EL2, 76 * the PID is in CONTEXTIDR_EL2. 77 */ ETMv4 uses 'contextid' as well, since the user space needs to know which exception level's PID should be traced, e.g. when CPU runs in EL2 'contextid' is set as ETM_OPT_CTXTID2, the perf tool will set 'contextid2' to tell driver to trace CONTEXTIDR_EL2. We can only verify 'contextid', and set 'contextid1' or 'contextid2' based on CPU running exception level, finally driver knows how to trace PID. Thanks, Leo > Validation of 'contextid1' and > 'contextid2' isn't a problem, because if the kernel doesn't support them > they can't be applied on the command line anyway. > > I can fix it by checking for 'contextid' and ETMv3 first and then doing > 'contextid1' and 'contextid2' after. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel