From patchwork Mon Dec 13 12:13:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695887 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 0469EC433EF for ; Mon, 13 Dec 2021 12:15:25 +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: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:In-Reply-To:References: List-Owner; bh=41MR0nLtm2VRhyj6OTLBzy+R4ol2bl8VUwBedfiLZcg=; b=cAByPje+KMIc8y RqooRxht/y0bteR2kmJR9ThLOeoqkxeQLUyKH8cbxMpRJJL6M5+0LdaXcrg1eznpylxGHSQn7LN3i nhskN7nUTbq/X83TMxEB/nSGp7i6QkyREOlrEQYaG5nmFnTKPa+k6MaaMnNqh8eo6BUtDiL/JcEuk l7o75MFEmXijAkEIh5qFbXbUL0UJVshihHCQwNR58ZNim/KTIkyu8y/bXrk5Y+2IUi2M4SRQpc80f CiFQdJT/8FxQRjnYfP9hOkWDrxuWauKl4KWZ5+fhhnSXGTim2OHm600XbWec573TCF62LsDSn6B1s s8gigSN1zYTsTpS5/sHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwkDJ-009Qqd-OR; Mon, 13 Dec 2021 12:13:53 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwkDF-009QpR-HH for linux-arm-kernel@lists.infradead.org; Mon, 13 Dec 2021 12:13:51 +0000 Received: by mail-ed1-x52d.google.com with SMTP id t5so51030559edd.0 for ; Mon, 13 Dec 2021 04:13:49 -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:mime-version :content-transfer-encoding; bh=C3YHcdlMvuKgq7HaJmpfp0QyKXxqSrxecQL/MMOxBX8=; b=hgSnPAnmPDu+2DHilBic/sXva+two2ZfG9arjT6Aq9Q2DBR0lh/VsBO1WMXWl2vIVl P0QvHeE6UohrBzAL8C3rUo2zGHWUvpFZvfwrUiO/bkntfA6TBxhj7vDi2pEmQH4iou8Q ufjf5cIkm205uDOtYBln1aTtRv6aKaqdjQ5cQF80xiHc6I5fJysUNifRBKqz2pLAHM3i aSDEo6s1juDd3yHByMTe/OIhBVUquhCKnCaVx+QmhPii6cDN3FMGRQqayCFRo1EpZ8kd x0tgHrD1/su/TaSHu9EbneK65K2u6TxgJgLq0hTrSwiI3IflkUG++uxPsEYYnM1LEKvu zlRw== 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:mime-version :content-transfer-encoding; bh=C3YHcdlMvuKgq7HaJmpfp0QyKXxqSrxecQL/MMOxBX8=; b=1s8JPPUuNviYGNyt5wCbRXJPb0ONMr4fsM1x2Kqsr27CFj/xRBic7pXAJLREjOpzAJ 3YMhncE9ynSo+f9BX4dSh5yJ1rDU/0hPlUIqcJZqThdhEeSTkRcaEWTkM0+Wzonx7o5P J4/4TIIC1CR0tkE6mSeMZkS5HgZstQPLe5Or8a6k5QVjcmkcfy0kabAWHoB/n8aVQypz RumdE49aH+jovZAQJg68gwBr7PWOqiYO1CqoeX8TS/OH6+zrXr2RqrG96YuYZoLVR/z/ DJuqia2zSNpeVDdWRyuSVam60viYdSsE/jvutDvco6yInQRhyxa2V7WqPsEEkQdFiZ0m aHGA== X-Gm-Message-State: AOAM530T14v4ze4Tz68oZuHk0a7hDnIbl/PsQgzyDK/jRg21IEFJ4LyH A2UelQ2122jkujrxY6pkwN7cWA== X-Google-Smtp-Source: ABdhPJy0KIN7Gv+pjJ0V1cN7GadCR23vOqjlswFJhkPKhj+o88vyEwM+f99Mb5hfYuYxJ2EqDLrZhw== X-Received: by 2002:a50:ee19:: with SMTP id g25mr65845189eds.162.1639397627880; Mon, 13 Dec 2021 04:13:47 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id gn26sm5725814ejc.14.2021.12.13.04.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 04:13:47 -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 0/4] coresight: etm: Correct PID tracing for non-root namespace Date: Mon, 13 Dec 2021 20:13:19 +0800 Message-Id: <20211213121323.1887180-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_041349_658394_06BD7DFD X-CRM114-Status: GOOD ( 11.47 ) 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 If a profiling program runs in a non-root PID namespace, if CoreSight driver enables PID tracing (with contextID), it can lead to mismatching issue between the context ID traced in hardware (from the root namespace) and the PIDs gathered by profiling tool (e.g. perf) in its non-root namespace. CoreSight driver has tried to address this issue for the contextID related interfaces under sysfs, but it misses to prevent user to set VMID (virtual contextID) for kernel runs in EL2 with VHE; furthermore, it misses to handle the case when the profiling tool runs in the non-root PID namespace. For this reason, this patch series is to correct contextID tracing for non-root namespace. After applied this patchset, patch 02 doesn't permit users to access virtual contextID via sysfs nodes in the non-root PID namespace, patch 03 and 04 stop to trace PID packet for non-root PID namespace. This patch is dependent on the patchset "pid: Introduce helper task_is_in_root_ns()" [1]. [1] https://lore.kernel.org/lkml/20211208083320.472503-1-leo.yan@linaro.org/ Leo Yan (4): coresight: etm4x: Add lock for reading virtual context ID comparator coresight: etm4x: Don't use virtual contextID for non-root PID namespace coresight: etm4x: Don't trace PID for non-root PID namespace coresight: etm3x: Don't trace PID for non-root PID namespace .../coresight/coresight-etm3x-core.c | 4 +++ .../coresight/coresight-etm4x-core.c | 10 +++++-- .../coresight/coresight-etm4x-sysfs.c | 30 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) Reviewed-by: Suzuki K Poulose