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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED87AC43381 for ; Tue, 2 Mar 2021 07:42:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5C3F64DE4 for ; Tue, 2 Mar 2021 07:42:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231902AbhCBECJ (ORCPT ); Mon, 1 Mar 2021 23:02:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344146AbhCAWuE (ORCPT ); Mon, 1 Mar 2021 17:50:04 -0500 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2683C061793 for ; Mon, 1 Mar 2021 14:49:04 -0800 (PST) Received: by mail-ot1-x32e.google.com with SMTP id d9so18107368ote.12 for ; Mon, 01 Mar 2021 14:49:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lod5AV9stobf9YNREve+YsqCj5E/GdBeQLdaIwH06w8=; b=J+1SzQlP7bzH6srtUJ5VsXzAJWbsJC91YMbGucsxFWtvOoqjiUQJuvFiOKPPGAFbZn uBGKb2TP1MBkakw/ZKMPRyJkNQwAYQHx5IaBzczl+N4CdBPVv2HgVh+WLOvUWGXMTwUQ 7T997WUnCUbqgoyxLmeMmGEH//xMy3QoEfirU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lod5AV9stobf9YNREve+YsqCj5E/GdBeQLdaIwH06w8=; b=sxN9jJUl+ofGxrvucbCkFj6SHwsfzWsgsAdni4Cg2Vhl07nYBFUyVIkUsVh8scxkzg bKc9YERpvubG1sMXIUOlOqwPaWlyiy07A/iVVoWzVdNVBgF4VUnpbu4S69ygGSvQuQt1 AYqbJ4LfBe9pArYXRqZ+XLer2WZ84cy8MfjtgY7wHS18XPL97eODzGxwolR2uDWafZC1 FkhA33djfTH+A/R2osk7CwB/foit0jMXVtbXxdNxGwoBYDk3fW94HgQLWlBAAEuHMXe0 j/T8RSga22Q/tTUkTJ91eJOuUFRtT96QwVBTRtvgX3km1U+mPSzwVgW52bFp1Al5wq12 G7hw== X-Gm-Message-State: AOAM531QGQ4XwxxGgjMxa/vP6r0YYfbVbNLhxGUYKjdqQ/iNYPhj/SJg HnEgJ8E0Nxc6ds3dBMLObzwhJa6n97AOAw== X-Google-Smtp-Source: ABdhPJwUOo++neB0BP/4q3CHEHVHNTA4eY41BNy1m9/MkWGCUn7HU7QGyfuu81nIDU4pnRtOVC26Hg== X-Received: by 2002:a9d:7459:: with SMTP id p25mr15230204otk.316.1614638943891; Mon, 01 Mar 2021 14:49:03 -0800 (PST) Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com. [209.85.210.53]) by smtp.gmail.com with ESMTPSA id 109sm3891280otj.8.2021.03.01.14.49.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Mar 2021 14:49:03 -0800 (PST) Received: by mail-ot1-f53.google.com with SMTP id v12so17039589ott.10 for ; Mon, 01 Mar 2021 14:49:03 -0800 (PST) X-Received: by 2002:a25:ab54:: with SMTP id u78mr27378505ybi.276.1614638632804; Mon, 01 Mar 2021 14:43:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Doug Anderson Date: Mon, 1 Mar 2021 14:43:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv2 3/4] coresight: etm4x: Add support to exclude kernel mode tracing To: Sai Prakash Ranjan Cc: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Leo Yan , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, Stephen Boyd , Denis Nikitin , Mattias Nissler , Al Grant , linux-arm-msm , LKML , Linux ARM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Hi, On Mon, Mar 1, 2021 at 11:05 AM Sai Prakash Ranjan wrote: > > On production systems with ETMs enabled, it is preferred to exclude > kernel mode(NS EL1) tracing for security concerns and support only > userspace(NS EL0) tracing. Perf subsystem interface uses the newly > introduced kernel config CONFIG_EXCLUDE_KERNEL_PMU_TRACE to exclude > kernel mode tracing, but there is an additional interface via sysfs > for ETMs which also needs to be handled to exclude kernel > mode tracing. So we use this same generic kernel config to handle > the sysfs mode of tracing. This config is disabled by default and > would not affect the current configuration which has both kernel and > userspace tracing enabled by default. > > Tested-by: Denis Nikitin > Signed-off-by: Sai Prakash Ranjan > --- > drivers/hwtracing/coresight/coresight-etm4x-core.c | 6 +++++- > drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 6 ++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) Not that I'm an expert in the perf subsystem, but the concern I had with v1 is now addressed. FWIW this seems fine to me now. Reviewed-by: Douglas Anderson > --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c > @@ -296,6 +296,12 @@ static ssize_t mode_store(struct device *dev, > if (kstrtoul(buf, 16, &val)) > return -EINVAL; > > + if (IS_ENABLED(CONFIG_EXCLUDE_KERNEL_PMU_TRACE) && (!(val & ETM_MODE_EXCL_KERN))) { > + dev_warn(dev, > + "Kernel mode tracing is not allowed, check your kernel config\n"); slight nit that I think your string needs to be indented by 1 space. ;-)