From patchwork Mon Dec 13 12:13:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695891 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 E2465C433EF for ; Mon, 13 Dec 2021 12:16:13 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3ZUSFNdxelrweEVtBTV3SrFaqmGpC6zjToSW9idBLFI=; b=FLOsSo6IM5NzYv UzHhLpgAvvcJS/eK/q8vNrjcWplrsNhFd1Xp5Hv+tVEE5aOkHi2d1NowZqmnoMrlChtqeuG0GyTg6 aLc05F8kgBbyaVn+Ak0x1hZarqrAvHw9PW2ks0LZ4IqOT9wprqTieG3TwxPHcAV47QbC7mXj05hSq wOy1b0knvOAkYWTmAvPlssDMi6MI0f4xg6I8kz4OBTcCAdYI4LtlZ5E7MiEuByry/F3/AvO3pR6IA 1UpSGxWIY3pPyAHq5QLelZWN/QwVq6UgKJeXMG05X2xNBR68Wc4BEXhz3lhwTsCCTomkoYhR2Iar9 qJF7eb+RJYmgBq4a5WBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwkE4-009R4K-9q; Mon, 13 Dec 2021 12:14:40 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwkDQ-009Qtc-Ix for linux-arm-kernel@lists.infradead.org; Mon, 13 Dec 2021 12:14:02 +0000 Received: by mail-ed1-x529.google.com with SMTP id r11so50761855edd.9 for ; Mon, 13 Dec 2021 04:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CP130Joo5LnzHA5fd0JPgyy8qzQq4QiMmlbo4WSc/bc=; b=PSS1H3WXFIMfkQxsIWTWwPkYK0wcqIk2+76oPkMNGMZ0qSS0iW+g1XjW6KXrKR+L62 VZEOcDtuRohjJWGX17jBc1X1QFF5D6QVXy/07L0sCzejVVBUVGun7Rdp3RacKI13kR+G lnFNiTYewYD7lmVCYatZZ2L7DrabtOQEcTGNOeVyK1b3JHPBeBBD5Qqsb3I3H0eVDNfW nHM6svD7D9x/YbKj3k4Yi9DfY+ceccgIxldW8uXVMXTfC3lKetcPIu8unIGmQo70yGvX it9eh/YrirQGva1/nfhawMjYtC5hJ2btu4n/JGYDt9CK30DoC8JabmNh9qmyfMpoXleB g3FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CP130Joo5LnzHA5fd0JPgyy8qzQq4QiMmlbo4WSc/bc=; b=bt3p8DNODvaWkC6RYR+4TooR6osamu0KDaOyvcf7wbF/xvHj00y0H3bzcV2QnCjFVq T+1t+YxxbhPvAuUXWffDAqfs0wStzwUcbowo4TG+hUCRzZi6K/R1zImb75ub7/q+cN4U EZ6+9LSi78gv8XfRIf5zho+4Xo2Ip29TRTMLwKCyrWo6o3zmM9uG229rSavbjjsXdWOm IUFiATm9C1ObH8O74WAG0EldWRt09eazU9hie4hq+CzVwGgw7uFBexfU1xT7RLKota2g aZJohcFsFrhDk2USRQ1hTp+d41zLhU4mqTIiIQvPqa6OQjDM17ZzqfRj6O+VL3Sr1ehH mD9Q== X-Gm-Message-State: AOAM5310qRmr77UUl0kogxRrVj5Dck+Eprp3iTo2CV3om71f+seZf8E2 unamKWFRmB8nHHlApU5cJi6hT+AZlNrWVfK22mI= X-Google-Smtp-Source: ABdhPJzEjrG8YHO4P2YfYwddzrc1l59/YSf3cTyU7Z/e8XhYhxdxpkf6MgfH65sMs/AbT7XDZH+LtA== X-Received: by 2002:a17:907:3c6:: with SMTP id su6mr46285599ejb.255.1639397638590; Mon, 13 Dec 2021 04:13:58 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id d19sm6273171edt.34.2021.12.13.04.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 04:13:58 -0800 (PST) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 4/4] coresight: etm3x: Don't trace PID for non-root PID namespace Date: Mon, 13 Dec 2021 20:13:23 +0800 Message-Id: <20211213121323.1887180-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213121323.1887180-1-leo.yan@linaro.org> References: <20211213121323.1887180-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_041400_648665_B645CE94 X-CRM114-Status: GOOD ( 12.19 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ETMv3 driver enables PID tracing by directly using perf config from userspace, this means the tracer will capture PID packets from root namespace but the profiling session runs in non-root PID namespace. Finally, the recorded packets can mislead perf reporting with the mismatched PID values. This patch changes to only enable PID tracing for root PID namespace. Note, the hardware supports VMID tracing from ETMv3.5, but the driver never enables VMID trace, this patch doesn't handle VMID trace (bit 30 in ETMCR register) particularly. Signed-off-by: Leo Yan Reported-by: kernel test robot --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c index cf64ce73a741..7d413ba8b823 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -340,6 +340,10 @@ static int etm_parse_event_config(struct etm_drvdata *drvdata, config->ctrl = attr->config; + /* Don't trace contextID when runs in non-root PID namespace */ + if (!task_is_in_init_pid_ns(current)) + config->ctrl &= ~ETMCR_CTXID_SIZE; + /* * Possible to have cores with PTM (supports ret stack) and ETM * (never has ret stack) on the same SoC. So if we have a request