From patchwork Fri Feb 4 15:23:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12735223 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 241E8C433F5 for ; Fri, 4 Feb 2022 15:26:03 +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=VXrjUL1AaLrxCNj8Vyvmc6P4FajzF3taBrahFuiFQDQ=; b=L5mA+WdPOKnpIz 7Bm5PMYq/W4fyBQLVYru8CpoHm6IpZqi+nqydaZSTT5vCGTtN0Xx7QLh8hIGzZN22uP28ow2mdXUL U3j7YH3KyhnKNldY667/T9k965N1TFwktgDgwaLHojWePdfSXeke7ctYfxd/3DKlL2cZKzGiF90AP X9wtxJg5/GhdZrbB9fSIHGqUH40cCcF9grE+9jOvhs7J57440ZCJVUr2/iUtzh+0sANpdqeoDAODk tVGU2qD1YOQr3MthOD6qTItBWtyXIHMv2Nw9XojlFnUoOh+lQzJtjLC2p1Ew6JW4xogHlhX5HjN8+ YTO3a+SEHryOTORJzy0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG0Ro-004ilN-3h; Fri, 04 Feb 2022 15:24:28 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG0Rk-004ikn-Ae for linux-arm-kernel@lists.infradead.org; Fri, 04 Feb 2022 15:24:25 +0000 Received: by mail-pf1-x42f.google.com with SMTP id i17so5349530pfq.13 for ; Fri, 04 Feb 2022 07:24:23 -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=GkiUUzVe9i6a+fIe7hk2GiLZxTBYFSj52q9QJFu9QnI=; b=foc/ui1c4BJKma1LKd5zOOnJH+mPze1ao2DbylYdX/0nYGsd6480mFYgd+FVOWx35l PS6Ld5328J8MTOA8hx9L3xZeBXcwoIbjBo2OXHozNZUoQAO4oAbkP+DfrrtHd70dSTSy dkdZAmn6w2GhMGUQlEpUp89NoeVI2s+IHInUcPVzUTq4l5kEvbEfHtnmveTTwf9WSfxQ gH0NIVFREsgOt6s772SSlG3cWoFg8CKDG9AeYGrp3Kv3uMqjiqn3blKac9P6+jBCRv5F pQ169oQ+EFFA+KuD7e31e2ngFbGkFiCHXib2WlI1VYQvSd7KNXeM7Eut/wWsEOlgILD+ +xzQ== 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=GkiUUzVe9i6a+fIe7hk2GiLZxTBYFSj52q9QJFu9QnI=; b=yGoBRtXY2azmLu3fFSBPvk7Cg5Z+AsbjPeCVhAnGEid2fqt4OrqFtg+BLjZyHacMXx /BqrCW1qfZtlGsR4ZcxU/mDk6iVYWc2zgQF5JVIlaI9lnQgDXIsaAN5N7jXb+PpyUTld 5MyyZcCBmyWneWL51eO3djNSVEB7mi/P/OfBXCycBkMaraWF98gXS5wHk+2kx99Usph0 CZu6zG98pw6f1OJMG+Lyzr6tILgkMXSeiR2xmc2HyMON4gP5cCBBH7eiNnk60RNHMh43 rtNN9zAC3GNVdnrQVk2PRPhMHEwBzUPE42IpiAQq3eGT07saTM0Me11tiFO8Sjn0xe// pFgg== X-Gm-Message-State: AOAM532eDX5QfuwsCY65Pbbr6rHBd/I3GBcfLOB0Z854g3esEAuog/J9 Foe/sSZtcXRqrfQpGluuN5gqtLruzUPZ1QU83Kw= X-Google-Smtp-Source: ABdhPJxQTBk63Vvx4oy3McBFhLF0eUpHd3o6yJJxbrx1IcK15Pg2Rnh3RlZ1DlSTf96iEx9KyTrK5g== X-Received: by 2002:a62:7a50:: with SMTP id v77mr3595642pfc.4.1643988263135; Fri, 04 Feb 2022 07:24:23 -0800 (PST) Received: from localhost.localdomain ([134.195.101.46]) by smtp.gmail.com with ESMTPSA id me4sm14237079pjb.26.2022.02.04.07.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 07:24:22 -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 RESEND 0/4] coresight: etm: Correct PID tracing for non-root namespace Date: Fri, 4 Feb 2022 23:23:59 +0800 Message-Id: <20220204152403.71775-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-20220204_072424_396681_061BC122 X-CRM114-Status: GOOD ( 12.29 ) 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 and 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 series has been rebased on the mainline kernel and applied cleanly on latest commit dcb85f85fa6f ("gcc-plugins/stackleak: Use noinstr in favor of notrace"). 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(-)