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=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 8800EC433B4 for ; Fri, 2 Apr 2021 01:10:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EC14610C7 for ; Fri, 2 Apr 2021 01:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234067AbhDBBKh (ORCPT ); Thu, 1 Apr 2021 21:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234029AbhDBBKe (ORCPT ); Thu, 1 Apr 2021 21:10:34 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70324C0613E6 for ; Thu, 1 Apr 2021 18:10:33 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id x7-20020a17090a2b07b02900c0ea793940so3937863pjc.2 for ; Thu, 01 Apr 2021 18:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=jXgYMA7YCHDSkhxOIGN+mMtiGXJRf6IQGVRpfhafWXA=; b=N19112hWdtQxyfgCcDt0DhZfb4+8mWmRhR7MM3//DSDFmb7rUMs4igONxhRatjxPTM SMnEZFtr0w8IPyC7jGOXxGxC/AF/flItO5xuXKily40SRRJ/ncXAZrgBU0IK9oZfkSCC KZa7fdxQyGtuy2tZGJUzNeRH8VGT6mkRha5Sw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=jXgYMA7YCHDSkhxOIGN+mMtiGXJRf6IQGVRpfhafWXA=; b=WJVwvIUQa36ZAEaAQIdvV1UO7m2780TscOOl8k0n6PQt5SHFwIVVsHyBb2awr3LRfN 1+YHYq0oghJXwSQuG45srDR+NInAwfdEQzivACXlGOURpf/u5jAEmIgfZiBRyqczdvaf 86M63ymleovP79ll4iRJqNhCK+FHGHmLU71QfxpePIaigPbufEjXB3GicHf+7F2FC1zp Pfq0GkQ/GlVbs4e26HVJA4wePQbVPoz/a9kZ5A6da7sNX1pAMhLUno891FUUsYR1JgKo 0WWIsQSfrFilPKJsYcXCIwrexq0X18Gmi66jzzdbGKXCy5YZA/8upko4dRqu0thIgVE5 /l0g== X-Gm-Message-State: AOAM532TqYOqEEBNdFaZR1lbNCsghPkoPRm/gsMUjilNOJ5t6tAr2jOQ 9DpYPe4WzOYtiZoAajUWEGop9A== X-Google-Smtp-Source: ABdhPJycw1gGh96FUFq87p46EFqj1fP4tEKbORG/9YP8Yqh+ZkzZ0UsUt+GcKzZ8k5FI1ilZH1VkJQ== X-Received: by 2002:a17:90a:6e44:: with SMTP id s4mr10949129pjm.112.1617325832870; Thu, 01 Apr 2021 18:10:32 -0700 (PDT) Received: from chromium.org ([2620:15c:202:201:450:f2a9:b3ca:879f]) by smtp.gmail.com with ESMTPSA id r23sm6764940pje.38.2021.04.01.18.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 18:10:32 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <56a657ebc4b843575037e3ba9ec9cb9a@codeaurora.org> References: <161704857307.3012082.499264834486221320@swboyd.mtv.corp.google.com> <56a657ebc4b843575037e3ba9ec9cb9a@codeaurora.org> Subject: Re: [PATCH V2 3/5] DCC: Added the sysfs entries for DCC(Data Capture and Compare) driver From: Stephen Boyd Cc: Andy Gross , Bjorn Andersson , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Sai Prakash Ranjan , Sibi Sankar , Rajendra Nayak , vkoul@kernel.org To: schowdhu@codeaurora.org Date: Thu, 01 Apr 2021 18:10:31 -0700 Message-ID: <161732583102.2260335.10112716468679763483@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Quoting schowdhu@codeaurora.org (2021-04-01 08:42:50) > On 2021-03-30 01:39, Stephen Boyd wrote: > > Quoting Souradeep Chowdhury (2021-03-25 01:02:34) > >> The DCC is a DMA engine designed to store register values either in > >> case of a system crash or in case of software triggers manually done > >> by the user.Using DCC hardware and the sysfs interface of the driver > >> the user can exploit various functionalities of DCC.The user can=20 > >> specify > >> the register addresses,the values of which is stored by DCC in it's > >> dedicated SRAM.The register addresses can be used either to read from, > >> write to,first read and store value and then write or to loop.All=20 > >> these > >> options can be exploited using the sysfs interface given to the user. > >> Following are the sysfs interfaces exposed in DCC driver which are > >> documented > >> 1)trigger > >> 2)config > >> 3)config_write > >> 4)config_reset > >> 5)enable > >> 6)rd_mod_wr > >> 7)loop > >>=20 > >> Signed-off-by: Souradeep Chowdhury > >> --- > >> Documentation/ABI/testing/sysfs-driver-dcc | 114=20 > >> +++++++++++++++++++++++++++++ > >=20 > > Please combine this with the driver patch. >=20 > Ack >=20 > >=20 > >> 1 file changed, 114 insertions(+) > >> create mode 100644 Documentation/ABI/testing/sysfs-driver-dcc > >=20 > > Perhaps this should be an ioctl interface instead of a sysfs interface? >=20 > The reasons for choosing sysfs over ioctl is as follows Cool, please add these details to the commit text. >=20 >=20 > i) As can be seen from the sysfs attribute descriptions, most of it does = > basic hardware manipulations like dcc_enable, dcc_disable, config reset=20 > etc. As a result sysfs is preferred over ioctl as we just need to enter=20 > a 0 or 1 > signal in such cases. >=20 > ii) Existing similar debug hardwares are there for which drivers have=20 > been written using sysfs interface. One such example is the=20 > coresight-etm-trace driver. Following is the link for reference >=20 > https://www.kernel.org/doc/html/latest/trace/coresight/coresight-etm4x-re= ference.html I wasn't deeply involved but I recall that the whole coresight sysfs interface was disliked and it mostly got rewritten to go through the perf tool instead. Pointing to the coresight sysfs API is not the best approach here. Maybe a closer analog would be the watchdog subsystem, which is ioctl based and uses a character device like /dev/watchdog. Watchdogs are simple debug features that reboot the system when everything goes wrong. This looks like a hardware block that can be used to gather information when the watchdog fires. Reading the doc closer it is quite frightening that a device like this can let you read registers in the hardware on-demand and even store values of registers over time. This is like /dev/mem on steroids. This needs to be highly restricted as it sounds like it could be used to snoop on security keys that are set in the hardware or secrets stored in memory. Is the hardware restricted at all in what it can read? 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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 6DBFCC433ED for ; Fri, 2 Apr 2021 01:12:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 06621610C7 for ; Fri, 2 Apr 2021 01:12:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06621610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:Date:To:Cc:From:Subject:References: In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PG1vvIHvWb97lDWJbgeoOtLtcER3Oa8ePvLkPx2f69k=; b=RmiPobFHPOfGookMjJ8P6SfHO 1nvdUD4HxYmlU23IB4YikxjGq1FuiqKQLkK+GpaqyWf8CQdSfmq6yC3NX5dZxizNO56AWE+FhxBUp KrSLPHoOCFxITYQ7wfdix23eRW0AKZdJUCZjDFizVm6/L7MDtOI3SPSmnkZTs3/hN9W5zB1Mrottm ERfk9wW3l4czKSLbW4WOmrYUjKwDsqVA2y30PjCJckhMqIndUZTdVZlxUFPSRxQfKn25/tSE81Ttm nGWF5TsHXQ73Nd12gywWoLO2009fPbYjd2SCSP7E/XTspPnJbN2/p5ZQyRwC1eVSMbik1leiEX9+w J6fge44jQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS8Ke-00Bblk-VN; Fri, 02 Apr 2021 01:10:44 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS8KY-00Bbki-Bb for linux-arm-kernel@lists.infradead.org; Fri, 02 Apr 2021 01:10:37 +0000 Received: by mail-pj1-x1034.google.com with SMTP id w8so2007500pjf.4 for ; Thu, 01 Apr 2021 18:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=jXgYMA7YCHDSkhxOIGN+mMtiGXJRf6IQGVRpfhafWXA=; b=N19112hWdtQxyfgCcDt0DhZfb4+8mWmRhR7MM3//DSDFmb7rUMs4igONxhRatjxPTM SMnEZFtr0w8IPyC7jGOXxGxC/AF/flItO5xuXKily40SRRJ/ncXAZrgBU0IK9oZfkSCC KZa7fdxQyGtuy2tZGJUzNeRH8VGT6mkRha5Sw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=jXgYMA7YCHDSkhxOIGN+mMtiGXJRf6IQGVRpfhafWXA=; b=td9gTEteVH84WVJqNB2c3exKxKLCTsM1o6pn/4dlR2DLsnRN7sdorvPf9XYvoc7g5i aaWdqiAmZIA5ZDhzWHh8gCGZTWbLSJV3T/86/ZDIU+KGWGGz1Pc33czDogUwslH1MLxW jCmj1APhAkcMhEyUzSpO32aIxhZvPRvwNxj/YFI49WvBAtZ1JH/BqMzKczAdyEP1Zv5s NSMdupbSP/hjtSsknfnyzJWiCKsXa2r6OYJxacOoehIHeV90+26Vg7Vmu+P9sgtgqhPn mgy+4iRr38OEc+1dR9PFVaOYD0QXPXnLa/QQ9a9qbEe4wWyHdgn8dF0IMCSRs8J/+9cF bvVQ== X-Gm-Message-State: AOAM5330G/XLoXCxahLYCeG4rLaTZPW7iwHGtd3/ZVAHa7O/ovYk1nXp t1FQxZyuUydWvc5gBV904jup8Q== X-Google-Smtp-Source: ABdhPJycw1gGh96FUFq87p46EFqj1fP4tEKbORG/9YP8Yqh+ZkzZ0UsUt+GcKzZ8k5FI1ilZH1VkJQ== X-Received: by 2002:a17:90a:6e44:: with SMTP id s4mr10949129pjm.112.1617325832870; Thu, 01 Apr 2021 18:10:32 -0700 (PDT) Received: from chromium.org ([2620:15c:202:201:450:f2a9:b3ca:879f]) by smtp.gmail.com with ESMTPSA id r23sm6764940pje.38.2021.04.01.18.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 18:10:32 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <56a657ebc4b843575037e3ba9ec9cb9a@codeaurora.org> References: <161704857307.3012082.499264834486221320@swboyd.mtv.corp.google.com> <56a657ebc4b843575037e3ba9ec9cb9a@codeaurora.org> Subject: Re: [PATCH V2 3/5] DCC: Added the sysfs entries for DCC(Data Capture and Compare) driver From: Stephen Boyd Cc: Andy Gross , Bjorn Andersson , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Sai Prakash Ranjan , Sibi Sankar , Rajendra Nayak , vkoul@kernel.org To: schowdhu@codeaurora.org Date: Thu, 01 Apr 2021 18:10:31 -0700 Message-ID: <161732583102.2260335.10112716468679763483@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210402_021035_225178_BBAB627A X-CRM114-Status: GOOD ( 32.78 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Quoting schowdhu@codeaurora.org (2021-04-01 08:42:50) > On 2021-03-30 01:39, Stephen Boyd wrote: > > Quoting Souradeep Chowdhury (2021-03-25 01:02:34) > >> The DCC is a DMA engine designed to store register values either in > >> case of a system crash or in case of software triggers manually done > >> by the user.Using DCC hardware and the sysfs interface of the driver > >> the user can exploit various functionalities of DCC.The user can > >> specify > >> the register addresses,the values of which is stored by DCC in it's > >> dedicated SRAM.The register addresses can be used either to read from, > >> write to,first read and store value and then write or to loop.All > >> these > >> options can be exploited using the sysfs interface given to the user. > >> Following are the sysfs interfaces exposed in DCC driver which are > >> documented > >> 1)trigger > >> 2)config > >> 3)config_write > >> 4)config_reset > >> 5)enable > >> 6)rd_mod_wr > >> 7)loop > >> > >> Signed-off-by: Souradeep Chowdhury > >> --- > >> Documentation/ABI/testing/sysfs-driver-dcc | 114 > >> +++++++++++++++++++++++++++++ > > > > Please combine this with the driver patch. > > Ack > > > > >> 1 file changed, 114 insertions(+) > >> create mode 100644 Documentation/ABI/testing/sysfs-driver-dcc > > > > Perhaps this should be an ioctl interface instead of a sysfs interface? > > The reasons for choosing sysfs over ioctl is as follows Cool, please add these details to the commit text. > > > i) As can be seen from the sysfs attribute descriptions, most of it does > basic hardware manipulations like dcc_enable, dcc_disable, config reset > etc. As a result sysfs is preferred over ioctl as we just need to enter > a 0 or 1 > signal in such cases. > > ii) Existing similar debug hardwares are there for which drivers have > been written using sysfs interface. One such example is the > coresight-etm-trace driver. Following is the link for reference > > https://www.kernel.org/doc/html/latest/trace/coresight/coresight-etm4x-reference.html I wasn't deeply involved but I recall that the whole coresight sysfs interface was disliked and it mostly got rewritten to go through the perf tool instead. Pointing to the coresight sysfs API is not the best approach here. Maybe a closer analog would be the watchdog subsystem, which is ioctl based and uses a character device like /dev/watchdog. Watchdogs are simple debug features that reboot the system when everything goes wrong. This looks like a hardware block that can be used to gather information when the watchdog fires. Reading the doc closer it is quite frightening that a device like this can let you read registers in the hardware on-demand and even store values of registers over time. This is like /dev/mem on steroids. This needs to be highly restricted as it sounds like it could be used to snoop on security keys that are set in the hardware or secrets stored in memory. Is the hardware restricted at all in what it can read? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel