Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1219626ybt; Thu, 25 Jun 2020 00:13:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG5klgFhW6mXsXBDDAMHTcN/TalYD6fFToGOiXfdRoc7huR6n25suDcqlGk7Q+Kx/mKWvk X-Received: by 2002:a17:907:1059:: with SMTP id oy25mr7426065ejb.90.1593069225327; Thu, 25 Jun 2020 00:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593069225; cv=none; d=google.com; s=arc-20160816; b=N5Wteor11cIPl79TidBYGvt0U5Qd/bjjdi4pbpgDP8TZMkSRBGH3cXPc8mR2M8s7BG 3ckgt66Iqmt0I8ka+nBIQgiv7/pVbKRlZMBPIxxJcJbZPmHcmd/damy/rPceXALMnZnz OCAIKjt7OJyZp0xmYs+14wxbz32SQ8dgw/EygEUtOq/U/6OsIzHeSVNXmWTy9yzeIdlF 8mBXphbCz+jX+iAKrFNIj68Cp/6EyRufLvDHhJsS48UD3ckeCUMbtK5lwd4ljJvNlz6S nETnSsnzBr+2lFQC028hodY3TO41z5pWKAGoCoG0O1kB2Ffh+PWAVvkVXB5965jICupO JY6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=C3E5bCblfbs30r1XU315yBgD8126admDm8YrzZcdpZQ=; b=nNr8Ffl6o8BYeIqt5axqeNRVrVLLAIB/VhjuXyvk7WzKRNee4Pt1QQuTSoyoL9JFPD cnSnVx0twc7pNKSN/dY8q2syAYqpzFgua3G2yeAzGIhLbIxxGq1qtcU6aewhSMv59YVi /yfL1Rv0mlvremZ/fLBfHym68XTorhbeXDEgRyQEmjXOAbD+0wLiUy5uCofVi5Iwzndh 5fhpMbYy31Hc6/9Vtoknc6NDvVAdo5qZvqdtf5dRnJYdez3Jv7Kr7lDQuZqciCfi1PYT Wz84Xf19SdxEg0YB0NRN9vzQP8OlJAa4CILRo91+Ke4Ci2SDP2v1BmjvIVm+oBtjlSFE 1Fdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bZ8LS7yT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc19si2730084ejb.584.2020.06.25.00.13.21; Thu, 25 Jun 2020 00:13:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bZ8LS7yT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390116AbgFYHKy (ORCPT + 99 others); Thu, 25 Jun 2020 03:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389406AbgFYHKx (ORCPT ); Thu, 25 Jun 2020 03:10:53 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC88BC061573 for ; Thu, 25 Jun 2020 00:10:53 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id ne5so2611712pjb.5 for ; Thu, 25 Jun 2020 00:10:53 -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=C3E5bCblfbs30r1XU315yBgD8126admDm8YrzZcdpZQ=; b=bZ8LS7yTnULtax1NcyW5j3SUSeKma0z8ZN0iy9LPxIkk4QD5z7HhLb/NCyjdh7UieJ 8AWCtvJPFYGTwRx2aFo306oT2qqvXCB6SUgTM9cRKwq70o89CFn1jQUYci2E15raGFNW d8bOEPTlBJ9SXDOvMm6CleakfzGN3MOmarRrg= 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=C3E5bCblfbs30r1XU315yBgD8126admDm8YrzZcdpZQ=; b=YyMJySALXIsUyEScihO4417Tp5Y07dFBFnjU+RK32BsqIHkrD/rcGcDS4YdeB5BkFu FroDqzFUGcvSlT9QX+NaVsz8QQcNTD+29g7rNKIM02v9EXr33DWOOisBZa/oYYBMV/9c c2URtZtWVRxPQ0MoKQGnaqeKjesrJFKsoNcZ3sF7Uty/sT2v3Qous2BmrJCoxOl0SYLD YYQv5gPio51XYKUQrbQHNq57zsuZk5OxEEcPK2dISbDrFTyO/l/67xTPAVc3UtkoLXqK hXBlt7aM493GncFiuU0LWd7VJBz6sXX6ugfELwBxWKR1+wCFWrxRY0675xWSUz29ZWhr z/Iw== X-Gm-Message-State: AOAM532H6dKErXcqeiMY48j9Tp5G9GbTqcV4mnNxTHLqVZtZiw1uYJ7y CvA5KvVink8XW0Tof5OYtZmdYQ== X-Received: by 2002:a17:90b:3105:: with SMTP id gc5mr1789808pjb.36.1593069053316; Thu, 25 Jun 2020 00:10:53 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id c141sm7254944pfc.167.2020.06.25.00.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 00:10:52 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200407082923.2001556-3-patrick.rudolph@9elements.com> References: <20200407082923.2001556-1-patrick.rudolph@9elements.com> <20200407082923.2001556-3-patrick.rudolph@9elements.com> Subject: Re: [PATCH v4 2/2] firmware: google: Expose coreboot tables over sysfs From: Stephen Boyd Cc: coreboot@coreboot.org, Patrick Rudolph , Greg Kroah-Hartman , Thomas Gleixner , Allison Randal , Alexios Zavras , Julius Werner , Samuel Holland To: linux-kernel@vger.kernel.org, patrick.rudolph@9elements.com Date: Thu, 25 Jun 2020 00:10:51 -0700 Message-ID: <159306905194.62212.10204515187655751787@swboyd.mtv.corp.google.com> User-Agent: alot/0.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting patrick.rudolph@9elements.com (2020-04-07 01:29:07) > From: Patrick Rudolph >=20 > Make all coreboot table entries available to userland. This is useful for > tools that are currently using /dev/mem. >=20 > Besides the tag and size also expose the raw table data itself. >=20 > Update the ABI documentation to explain the new sysfs interface. >=20 > Tools can easily scan for the right coreboot table by reading > /sys/bus/coreboot/devices/coreboot*/attributes/id > The binary table data can then be read from > /sys/bus/coreboot/devices/coreboot*/attributes/data >=20 > Signed-off-by: Patrick Rudolph > --- Reviewed-by: Stephen Boyd Minor nits below: > -v2: > - Add ABI documentation > - Add 0x prefix on hex values > - Remove wrong ioremap hint as found by CI > -v3: > - Use BIN_ATTR_RO > -v4: > - Updated ABI documentation > --- > Documentation/ABI/stable/sysfs-bus-coreboot | 30 +++++++++++ > drivers/firmware/google/coreboot_table.c | 58 +++++++++++++++++++++ > 2 files changed, 88 insertions(+) >=20 > diff --git a/Documentation/ABI/stable/sysfs-bus-coreboot b/Documentation/= ABI/stable/sysfs-bus-coreboot > index 6055906f41f2..328153a1b3f4 100644 > --- a/Documentation/ABI/stable/sysfs-bus-coreboot > +++ b/Documentation/ABI/stable/sysfs-bus-coreboot > diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/= google/coreboot_table.c > index 0205987a4fd4..d0fc3eb93f4f 100644 > --- a/drivers/firmware/google/coreboot_table.c > +++ b/drivers/firmware/google/coreboot_table.c > @@ -3,9 +3,11 @@ > * coreboot_table.c > * > * Module providing coreboot table access. > + * Exports coreboot tables as attributes in sysfs. > * > * Copyright 2017 Google Inc. > * Copyright 2017 Samuel Holland > + * Copyright 2019 9elements Agency GmbH > */ > =20 > #include > @@ -84,6 +86,60 @@ void coreboot_driver_unregister(struct coreboot_driver= *driver) > } > EXPORT_SYMBOL(coreboot_driver_unregister); > =20 > +static ssize_t id_show(struct device *dev, > + struct device_attribute *attr, char *buffer) > +{ > + struct coreboot_device *device =3D CB_DEV(dev); Wouldn't hurt to throw const in front of these. > + > + return sprintf(buffer, "0x%08x\n", device->entry.tag); > +} > + > +static ssize_t size_show(struct device *dev, > + struct device_attribute *attr, char *buffer) > +{ > + struct coreboot_device *device =3D CB_DEV(dev); And these. But the function is so short probably doesn't really matter. > + > + return sprintf(buffer, "%u\n", device->entry.size); > +} > + > +static DEVICE_ATTR_RO(id); > +static DEVICE_ATTR_RO(size); > + > +static struct attribute *cb_dev_attrs[] =3D { > + &dev_attr_id.attr, > + &dev_attr_size.attr, > + NULL > +}; > + > +static ssize_t data_read(struct file *filp, struct kobject *kobj, > + struct bin_attribute *bin_attr, > + char *buffer, loff_t offset, size_t count) > +{ > + struct device *dev =3D kobj_to_dev(kobj); > + struct coreboot_device *device =3D CB_DEV(dev); > + > + return memory_read_from_buffer(buffer, count, &offset, > + &device->entry, device->entry.size= ); > +} > + > +static BIN_ATTR_RO(data, 0); Still no way to figure out the actual size? Can we add the bin_attribute at runtime? > + > +static struct bin_attribute *cb_dev_bin_attrs[] =3D { > + &bin_attr_data, > + NULL > +}; > +