From patchwork Sun Oct 31 14:42:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12595167 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFDBAC4332F for ; Sun, 31 Oct 2021 14:44:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 90A1360EB1 for ; Sun, 31 Oct 2021 14:44:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 90A1360EB1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=PdYw5P3adP8YwIkWyYm6BDlzaWZfl64Jeojv43hnWRE=; b=Llv37hnmlMF/o+ sTBFJsKxg3qkfWI3POkoEE1pSpAWkAhwS2kpgEML183+167UO9ovaJxZWVSNiu0IKoWmX+pBC1VuN BOpZzHSGopLGnojp1NgE2Y12O+oM65AqvJ4gc+6MPT0rr7i3NTufS7pQ9fl2r3DUDMz2Z3JdwgYSf S2Uo5g2MWsAbkA9lVvPH3Bj/6a9iJYDKwMQrVLLHC/9T2eh3v30alVoyFFyIVCb/n8J+9aprfvyyB UVIT7A3mnCj/mzLnblSOjpway1hlt990Uuisx8Fyhd7oiMkoz+cfwcrz8gQuGpyjX/v2Sn44f2CGf yj3pTE+jtC/Xf5pZ5a8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhC2j-00ECSy-VC; Sun, 31 Oct 2021 14:42:42 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhC2g-00ECSF-5A for linux-arm-kernel@lists.infradead.org; Sun, 31 Oct 2021 14:42:39 +0000 Received: by mail-pl1-x636.google.com with SMTP id l13so4925792pls.3 for ; Sun, 31 Oct 2021 07:42:35 -0700 (PDT) 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=i6H6287i+DjjUNpGz7HtTUgvvz9yWh2H4PyJ0+2Kvp8=; b=JFvI1eirbYasDAIAIp8fku73Jw6qMRBAXMhCiczj+SU/pApF2A/9NGYK9qO3Jyy0r6 CSnMbSKysddKsrUjqwHANCVT7NM2g5yUxNgkvexXDAMk+c5bcdFcMXvTg77xcqXxUZQp SyJmceLnjX6oiEj41re2YFmlL65fczMZsRAZPzVLp64Vuiup5lEiL8HLIg549UsHqrXB 1A8Kl8LltRstO9E61Aaq66qw2BNJByCDhE0Zfh/DhWNttGgIesgkMd2pMslmKi3oTRv1 dM0PEVCHrjFYBJRBQiuYPNJBcDtS7/r8hgBjQyfp93w1akCPG26IaQxIcFEk+I1BHr1J aPVw== 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=i6H6287i+DjjUNpGz7HtTUgvvz9yWh2H4PyJ0+2Kvp8=; b=pvwJ8pqsT/yvFdi2X+KLzlxbAb05J0kDbyv+Yvo7h7vyPZC6ehleMVFKWHDH5TjW1C wLOGddM+5ZENzcpSdMs7ki8G/Ao1Fdhhcgue9ipwR4iroUIvbGwCsQnuGAGH6Vy9foYm p9q80oeewzCk5IuLO7fPtdKb45mlsofGc2euFPF7ySZrblyC8U9pWmxMYVsPzNlzR3YD bRMpVWGALDwkajCLhOBwM9VTjqT8Wc/DnsfXjfiE2skrvACybU8bdcuohDce6bh9VXi0 E50yYS4yY3PK41M1BAhqiimNacd6NsZhoNwWY3POIlZ52m++P6/BIF12k4Og9CogvNji PPmw== X-Gm-Message-State: AOAM533G2s+3xNuxLkRolOGfejm11hFKunucvPT9gxrfYG9zgX8FZfEP QLAFf/J/QeNWlkIAFoQ/tkO8ag== X-Google-Smtp-Source: ABdhPJwUaHa6ScAVFIXNXWD1AbYqv3PQT7nyR/b1A0TaxK+NB2OJxON3WMOzXqJThSnI/Kv4h2YRAg== X-Received: by 2002:a17:90b:4a50:: with SMTP id lb16mr2652865pjb.37.1635691354787; Sun, 31 Oct 2021 07:42:34 -0700 (PDT) Received: from localhost ([134.195.101.46]) by smtp.gmail.com with ESMTPSA id k1sm10937185pjj.54.2021.10.31.07.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 07:42:34 -0700 (PDT) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , James Clark , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 0/4] coresight: etm: Correct (virtual) contextID tracing for namespace Date: Sun, 31 Oct 2021 22:42:10 +0800 Message-Id: <20211031144214.237879-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-20211031_074238_251365_FE470904 X-CRM114-Status: GOOD ( 11.69 ) 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 contextID tracing, it can lead to mismatching issue between the context ID in hardware trace data and the allocated PID in the non-root namespace. CoreSight driver has tried to address this issue for the contextID related interfaces under sysfs, but it misses other parts: it doesn't prevent user to set VMID (virtual contextID) for kernel runs in EL2 with VHE, and furthermore, it misses to handle the perf mode when the profiling tool (e.g. perf) doesn't run in root PID namespace. For this reason, this patch series is to correct contextID tracing for non-root namespace. Patch 01 is to use spinlock to protect reading virtual context ID comparator. Patch 02 corrects the virtual contextID tracing for non-root PID namespace. Patch 03/04 are used to fix the contextID tracing for perf mode. I only verified this patch series on Juno board in the root PID namespace and confirmed the patches don't introduce any regression for root PID namespace. 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 contextID for non-root namespace in perf mode coresight: etm3x: Don't trace contextID for non-root namespace in perf mode .../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(-)