Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3254821rwb; Fri, 30 Sep 2022 00:26:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DyCfNKUrqhA3Ih5WKpzAeHTYpjz4m3/vRoB6ihg3rk5voNf+L4gJMvAPu3f0hYKdJm+vq X-Received: by 2002:a17:907:a0c6:b0:783:88a3:55a3 with SMTP id hw6-20020a170907a0c600b0078388a355a3mr5676489ejc.648.1664522782522; Fri, 30 Sep 2022 00:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664522782; cv=none; d=google.com; s=arc-20160816; b=P5aw1OdHdeN9QD7Y960KzVh+SgCW5d2MSlDqqyyXf68TzGi7X5LoM8GHXg+w+Yba8k A1Ab/iXdbskCXXbtgQxxCruFlalL7NZq/Asa00LulyYr2Ar6phR7BniXIA+IE/lfHpJ6 BmVrErrbt1P9mWBOAGtINRLpe0uUCjYOkxgsX1IUTQZTA5v5s2GWRhGLsArzbgkJds+6 +6u/DVv1F7AxLBu9CEZmp++dz8FM4aBcso4iOQy6znf5tr6CvWJqaJg6/raQQ2dx+27w 2lzqsCH7LFwmIlBSMh7w6DSyRxghCzUjAavm3Cyph+VedQg77RVqM7+ulhU/jKxrIJ9a KO9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ce6qzD/at4zR9edKOTj2Q83MniQXqsQCng5IyJdFnpY=; b=Wy+5tFXfrBAwS2YPSLp05D0t43A8Ebkwg2i7SVBo5dK9LcD99hGp2gaByEtb/LFjtB dp09VitWpxk40P2HKDf5+OdhblN0AbXEvqAzmwiGZnz5JccmZ12GtQWYTDM3g/LPYla1 mTSSbYtvnaeVHa16rLS9xLSt4jBig628sXxeui2+uBiS0/OMnN4koegWmLdiGjGBa4Mw egJDI5vCtfkQxLA7Fg/P9S5ZXf3eZtzlRUQ1mEu13T4x/JQbwEch39qxCnb8UAV7MJRt 9DF+69+puuqN+Mq6OUWsdB/YbabjJbEUeuKd4XactiIjCjvlRz0bRrDVZJMMzZTouEw4 lbbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nv4Wo1KM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402084800b00456f2b66376si1707480edz.448.2022.09.30.00.25.56; Fri, 30 Sep 2022 00:26:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nv4Wo1KM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbiI3Gc6 (ORCPT + 99 others); Fri, 30 Sep 2022 02:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbiI3Gcz (ORCPT ); Fri, 30 Sep 2022 02:32:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D461F8C09 for ; Thu, 29 Sep 2022 23:32:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7EF91B8242D for ; Fri, 30 Sep 2022 06:32:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1036C433D6; Fri, 30 Sep 2022 06:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664519569; bh=8d0GTDlEDmWyR/tsAL8f28K9BeG0QlXD4nZBVLr4Du4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nv4Wo1KMxmXelaaWQbeUASxSgXqrJW9FOn+QTYw09LLPIzb1ana1M/QhFZNHRYtqF Zwpje9BIG9PoOPXs2WbcJO0IbMcCs5455RZR5WfX6MIwYwcHbPXEl0wSpcz0o6Cjtf AebpYzZaWD3ZTGsf2NLdyinZCZ9CX/RGBhyVBi0k= Date: Fri, 30 Sep 2022 08:32:46 +0200 From: Greg KH To: Jack Rosenthal Cc: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev, Stephen Boyd , Tzung-Bi Shih , Guenter Roeck , Julius Werner Subject: Re: [PATCH v11] firmware: google: Implement cbmem in sysfs driver Message-ID: References: <20220929234432.3711480-1-jrosenth@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929234432.3711480-1-jrosenth@chromium.org> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 29, 2022 at 05:44:32PM -0600, Jack Rosenthal wrote: > The CBMEM area is a downward-growing memory region used by coreboot to > dynamically allocate tagged data structures ("CBMEM entries") that > remain resident during boot. > > This implements a driver which exports access to the CBMEM entries > via sysfs under /sys/firmware/cbmem/. > > This implementation is quite versatile. Examples of how it could be > used are given below: > > * Tools like util/cbmem from the coreboot tree could use this driver > instead of finding CBMEM in /dev/mem directly. Alternatively, > firmware developers debugging an issue may find the sysfs interface > more ergonomic than the cbmem tool and choose to use it directly. > > * The crossystem tool, which exposes verified boot variables, can use > this driver to read the vboot work buffer. > > * Tools which read the BIOS SPI flash (e.g., flashrom) can find the > flash layout in CBMEM directly, which is significantly faster than > searching the flash directly. > > Write access is provided to all CBMEM regions via > /sys/firmware/cbmem//mem, as the existing cbmem tooling updates > this memory region, and envisioned use cases with crossystem > can benefit from updating memory regions. > > Link: https://issuetracker.google.com/239604743 > Cc: Stephen Boyd > Cc: Tzung-Bi Shih > Reviewed-by: Guenter Roeck > Reviewed-by: Julius Werner > Tested-by: Jack Rosenthal > Signed-off-by: Jack Rosenthal > --- > Changes in v11: > * Changed /sys/firmware/coreboot/cbmem -> /sys/firmware/cbmem > * cbmem.c uses attribute groups to initialize files, which is much > cleaner. The attributes are added under the device kobject, which > is now symlinked into /sys/firmware/cbmem. symlink? Ick, no, do not do that at all please. As these are device attributes, just stick with them. Don't do a crazy symlink into a non-device-attribute portion of the sysfs tree, by doing that you break all userspace tools and stuff like libudev will never even see these attributes. > * Changed documentation text as suggested by greg k-h > > .../ABI/testing/sysfs-firmware-cbmem | 43 +++++ > drivers/firmware/google/Kconfig | 8 + > drivers/firmware/google/Makefile | 3 + > drivers/firmware/google/cbmem.c | 180 ++++++++++++++++++ > drivers/firmware/google/coreboot_table.h | 16 ++ > 5 files changed, 250 insertions(+) > create mode 100644 Documentation/ABI/testing/sysfs-firmware-cbmem > create mode 100644 drivers/firmware/google/cbmem.c > > diff --git a/Documentation/ABI/testing/sysfs-firmware-cbmem b/Documentation/ABI/testing/sysfs-firmware-cbmem > new file mode 100644 > index 000000000000..f769104ac4cd > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-firmware-cbmem > @@ -0,0 +1,43 @@ > +What: /sys/firmware/cbmem/ > +Date: August 2022 > +Contact: Jack Rosenthal > +Description: > + Coreboot provides a variety of data structures in CBMEM. This > + directory contains each CBMEM entry, which can be found via > + Coreboot tables. What happened to the coreboot name? Why cbmem? What is CBMEM? And just stick with the attributes under the cbmem coreboot device in the device tree, don't use /sys/firmware/. Also, I asked before, but some note about "exposing all of these bios values to userspace is not a security issue at all" would be nice, if only to point at in a few years and say "wow we were naive"... thanks, greg k-h