2024-01-12 13:21:19

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 0/7] Allow coreboot modules to autoload and enable cbmem in the arm64 defconfig


This series adds the missing pieces to the coreboot bus and the module
alias generation to allow coreboot modules to be automatically loaded
when matching devices are detected.

The configs for cbmem coreboot entries are then enabled in the arm64
defconfig, as modules, to allow reading logs from coreboot on arm64
Chromebooks, which is useful for debugging the boot process.

Changes in v2:
- Added commits for vpd, memconsole and framebuffer drivers to add them
to the module device table

Nícolas F. R. A. Prado (7):
firmware: coreboot: Generate modalias uevent for devices
firmware: coreboot: Generate aliases for coreboot modules
firmware: google: cbmem: Add to module device table
firmware: google: vpd: Add to module device table
firmware: google: memconsole: Add to module device table
firmware: google: framebuffer: Add to module device table
arm64: defconfig: Enable support for cbmem entries in the coreboot
table

arch/arm64/configs/defconfig | 3 +++
drivers/firmware/google/cbmem.c | 7 +++++++
drivers/firmware/google/coreboot_table.c | 9 +++++++++
drivers/firmware/google/framebuffer-coreboot.c | 7 +++++++
drivers/firmware/google/memconsole-coreboot.c | 7 +++++++
drivers/firmware/google/vpd.c | 7 +++++++
include/linux/mod_devicetable.h | 8 ++++++++
scripts/mod/devicetable-offsets.c | 3 +++
scripts/mod/file2alias.c | 10 ++++++++++
9 files changed, 61 insertions(+)

--
2.43.0



2024-01-12 13:21:35

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 1/7] firmware: coreboot: Generate modalias uevent for devices

Generate a modalias uevent for devices in the coreboot bus to allow
userspace to automatically load the corresponding modules.

Acked-by: Brian Norris <[email protected]>
Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
---

(no changes since v1)

drivers/firmware/google/coreboot_table.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
index 2a4469bf1b81..c1b9a9e8e8ed 100644
--- a/drivers/firmware/google/coreboot_table.c
+++ b/drivers/firmware/google/coreboot_table.c
@@ -53,11 +53,20 @@ static void coreboot_bus_remove(struct device *dev)
driver->remove(device);
}

+static int coreboot_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
+{
+ struct coreboot_device *device = CB_DEV(dev);
+ u32 tag = device->entry.tag;
+
+ return add_uevent_var(env, "MODALIAS=coreboot:t%08X", tag);
+}
+
static struct bus_type coreboot_bus_type = {
.name = "coreboot",
.match = coreboot_bus_match,
.probe = coreboot_bus_probe,
.remove = coreboot_bus_remove,
+ .uevent = coreboot_bus_uevent,
};

static void coreboot_device_release(struct device *dev)
--
2.43.0


2024-01-12 13:21:50

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

Generate aliases for coreboot modules to allow automatic module probing.

Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
---

(no changes since v1)

include/linux/mod_devicetable.h | 8 ++++++++
scripts/mod/devicetable-offsets.c | 3 +++
scripts/mod/file2alias.c | 10 ++++++++++
3 files changed, 21 insertions(+)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index f458469c5ce5..24e0dcfde809 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -960,4 +960,12 @@ struct vchiq_device_id {
char name[32];
};

+/**
+ * struct coreboot_device_id - Identifies a coreboot table entry
+ * @tag: tag ID
+ */
+struct coreboot_device_id {
+ __u32 tag;
+};
+
#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index e91a3c38143b..518200813d4e 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -274,5 +274,8 @@ int main(void)
DEVID(vchiq_device_id);
DEVID_FIELD(vchiq_device_id, name);

+ DEVID(coreboot_device_id);
+ DEVID_FIELD(coreboot_device_id, tag);
+
return 0;
}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 4829680a0a6d..5d1c61fa5a55 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1494,6 +1494,15 @@ static int do_vchiq_entry(const char *filename, void *symval, char *alias)
return 1;
}

+/* Looks like: coreboot:tN */
+static int do_coreboot_entry(const char *filename, void *symval, char *alias)
+{
+ DEF_FIELD(symval, coreboot_device_id, tag);
+ sprintf(alias, "coreboot:t%08X", tag);
+
+ return 1;
+}
+
/* Does namelen bytes of name exactly match the symbol? */
static bool sym_is(const char *name, unsigned namelen, const char *symbol)
{
@@ -1575,6 +1584,7 @@ static const struct devtable devtable[] = {
{"ishtp", SIZE_ishtp_device_id, do_ishtp_entry},
{"cdx", SIZE_cdx_device_id, do_cdx_entry},
{"vchiq", SIZE_vchiq_device_id, do_vchiq_entry},
+ {"coreboot", SIZE_coreboot_device_id, do_coreboot_entry},
};

/* Create MODULE_ALIAS() statements.
--
2.43.0


2024-01-12 13:22:05

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 3/7] firmware: google: cbmem: Add to module device table

Create an id table and add it to the module device table to allow the
cbmem driver to be automatically loaded when a matching device is found.

Acked-by: Brian Norris <[email protected]>
Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
---

(no changes since v1)

drivers/firmware/google/cbmem.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/firmware/google/cbmem.c b/drivers/firmware/google/cbmem.c
index 88e587ba1e0d..ceb89b4cdbe0 100644
--- a/drivers/firmware/google/cbmem.c
+++ b/drivers/firmware/google/cbmem.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/module.h>
+#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
@@ -114,6 +115,12 @@ static int cbmem_entry_probe(struct coreboot_device *dev)
return 0;
}

+static const struct coreboot_device_id cbmem_ids[] = {
+ { .tag = LB_TAG_CBMEM_ENTRY },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(coreboot, cbmem_ids);
+
static struct coreboot_driver cbmem_entry_driver = {
.probe = cbmem_entry_probe,
.drv = {
--
2.43.0


2024-01-12 13:22:38

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 4/7] firmware: google: vpd: Add to module device table

Create an id table and add it to the module device table to allow the
vpd driver to be automatically loaded when a matching device is found.

Suggested-by: Brian Norris <[email protected]>
Signed-off-by: Nícolas F. R. A. Prado <[email protected]>

---

Changes in v2:
- Added this commit

drivers/firmware/google/vpd.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index ee6e08c0592b..9e9fe9ca1920 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -14,6 +14,7 @@
#include <linux/kobject.h>
#include <linux/list.h>
#include <linux/module.h>
+#include <linux/mod_devicetable.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -306,6 +307,12 @@ static void vpd_remove(struct coreboot_device *dev)
kobject_put(vpd_kobj);
}

+static const struct coreboot_device_id vpd_ids[] = {
+ { .tag = CB_TAG_VPD },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(coreboot, vpd_ids);
+
static struct coreboot_driver vpd_driver = {
.probe = vpd_probe,
.remove = vpd_remove,
--
2.43.0


2024-01-12 13:22:55

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 5/7] firmware: google: memconsole: Add to module device table

Create an id table and add it to the module device table to allow the
memconsole driver to be automatically loaded when a matching device is
found.

Suggested-by: Brian Norris <[email protected]>
Signed-off-by: Nícolas F. R. A. Prado <[email protected]>

---

Changes in v2:
- Added this commit

drivers/firmware/google/memconsole-coreboot.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/firmware/google/memconsole-coreboot.c b/drivers/firmware/google/memconsole-coreboot.c
index 74b5286518ee..b8e65b9d8cc0 100644
--- a/drivers/firmware/google/memconsole-coreboot.c
+++ b/drivers/firmware/google/memconsole-coreboot.c
@@ -11,6 +11,7 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/mod_devicetable.h>

#include "memconsole.h"
#include "coreboot_table.h"
@@ -96,6 +97,12 @@ static void memconsole_remove(struct coreboot_device *dev)
memconsole_exit();
}

+static const struct coreboot_device_id memconsole_ids[] = {
+ { .tag = CB_TAG_CBMEM_CONSOLE },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(coreboot, memconsole_ids);
+
static struct coreboot_driver memconsole_driver = {
.probe = memconsole_probe,
.remove = memconsole_remove,
--
2.43.0


2024-01-12 13:23:11

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 6/7] firmware: google: framebuffer: Add to module device table

Create an id table and add it to the module device table to allow the
framebuffer driver to be automatically loaded when a matching device is
found.

Suggested-by: Brian Norris <[email protected]>
Signed-off-by: Nícolas F. R. A. Prado <[email protected]>

---

Changes in v2:
- Added this commit

drivers/firmware/google/framebuffer-coreboot.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/firmware/google/framebuffer-coreboot.c b/drivers/firmware/google/framebuffer-coreboot.c
index 5c84bbebfef8..b33e9c6f97d7 100644
--- a/drivers/firmware/google/framebuffer-coreboot.c
+++ b/drivers/firmware/google/framebuffer-coreboot.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/module.h>
+#include <linux/mod_devicetable.h>
#include <linux/platform_data/simplefb.h>
#include <linux/platform_device.h>

@@ -80,6 +81,12 @@ static void framebuffer_remove(struct coreboot_device *dev)
platform_device_unregister(pdev);
}

+static const struct coreboot_device_id framebuffer_ids[] = {
+ { .tag = CB_TAG_FRAMEBUFFER },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(coreboot, framebuffer_ids);
+
static struct coreboot_driver framebuffer_driver = {
.probe = framebuffer_probe,
.remove = framebuffer_remove,
--
2.43.0


2024-01-12 13:23:27

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: [PATCH v2 7/7] arm64: defconfig: Enable support for cbmem entries in the coreboot table

Enable the cbmem driver and dependencies in order to support reading
cbmem entries from the coreboot table, which are used to store logs from
coreboot on arm64 Chromebooks, and provide useful information for
debugging the boot process on those devices.

Signed-off-by: Nícolas F. R. A. Prado <[email protected]>

---

(no changes since v1)

arch/arm64/configs/defconfig | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 0b0ef6877a12..cd94d55b23b2 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -255,6 +255,9 @@ CONFIG_INTEL_STRATIX10_RSU=m
CONFIG_MTK_ADSP_IPC=m
CONFIG_QCOM_QSEECOM=y
CONFIG_QCOM_QSEECOM_UEFISECAPP=y
+CONFIG_GOOGLE_FIRMWARE=y
+CONFIG_GOOGLE_CBMEM=m
+CONFIG_GOOGLE_COREBOOT_TABLE=m
CONFIG_EFI_CAPSULE_LOADER=y
CONFIG_IMX_SCU=y
CONFIG_IMX_SCU_PD=y
--
2.43.0


2024-01-14 17:09:48

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Fri, Jan 12, 2024 at 10:18:31AM -0300, N?colas F. R. A. Prado wrote:
> Generate aliases for coreboot modules to allow automatic module probing.

..

> (no changes since v1)

Same Q as per v1.

--
With Best Regards,
Andy Shevchenko



Subject: Re: [PATCH v2 0/7] Allow coreboot modules to autoload and enable cbmem in the arm64 defconfig

Il 12/01/24 14:18, Nícolas F. R. A. Prado ha scritto:
>
> This series adds the missing pieces to the coreboot bus and the module
> alias generation to allow coreboot modules to be automatically loaded
> when matching devices are detected.
>
> The configs for cbmem coreboot entries are then enabled in the arm64
> defconfig, as modules, to allow reading logs from coreboot on arm64
> Chromebooks, which is useful for debugging the boot process.
>

For the entire series:

Reviewed-by: AngeloGioacchino Del Regno <[email protected]>

> Changes in v2:
> - Added commits for vpd, memconsole and framebuffer drivers to add them
> to the module device table
>
> Nícolas F. R. A. Prado (7):
> firmware: coreboot: Generate modalias uevent for devices
> firmware: coreboot: Generate aliases for coreboot modules
> firmware: google: cbmem: Add to module device table
> firmware: google: vpd: Add to module device table
> firmware: google: memconsole: Add to module device table
> firmware: google: framebuffer: Add to module device table
> arm64: defconfig: Enable support for cbmem entries in the coreboot
> table
>
> arch/arm64/configs/defconfig | 3 +++
> drivers/firmware/google/cbmem.c | 7 +++++++
> drivers/firmware/google/coreboot_table.c | 9 +++++++++
> drivers/firmware/google/framebuffer-coreboot.c | 7 +++++++
> drivers/firmware/google/memconsole-coreboot.c | 7 +++++++
> drivers/firmware/google/vpd.c | 7 +++++++
> include/linux/mod_devicetable.h | 8 ++++++++
> scripts/mod/devicetable-offsets.c | 3 +++
> scripts/mod/file2alias.c | 10 ++++++++++
> 9 files changed, 61 insertions(+)
>


2024-01-23 22:18:31

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Sun, Jan 14, 2024 at 07:09:29PM +0200, Andy Shevchenko wrote:
> On Fri, Jan 12, 2024 at 10:18:31AM -0300, N?colas F. R. A. Prado wrote:
> > Generate aliases for coreboot modules to allow automatic module probing.
>
> ...
>
> > (no changes since v1)
>
> Same Q as per v1.

I don't have v1 in my inbox, and this wasn't addressed in v3 either. But
copy/pasted off the archives:

"Don't you want to have a driver data or so associated with this?"

These drivers are super simple, and I doubt they will end up with
multiple tags per driver, so it seems unlikely we'd ever need it.
Additionally, struct coreboot_device already includes the tag
information, so anything that could be included in driver data could be
parsed out by the driver at probe time, if absolutely needed.

Brian

2024-01-30 23:51:38

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Tue, Jan 23, 2024 at 02:06:14PM -0800, Brian Norris wrote:
> On Sun, Jan 14, 2024 at 07:09:29PM +0200, Andy Shevchenko wrote:
> > On Fri, Jan 12, 2024 at 10:18:31AM -0300, N?colas F. R. A. Prado wrote:
> > > Generate aliases for coreboot modules to allow automatic module probing.
> >
> > ...
> >
> > > (no changes since v1)
> >
> > Same Q as per v1.
>
> I don't have v1 in my inbox, and this wasn't addressed in v3 either. But
> copy/pasted off the archives:
>
> "Don't you want to have a driver data or so associated with this?"
>
> These drivers are super simple, and I doubt they will end up with
> multiple tags per driver, so it seems unlikely we'd ever need it.
> Additionally, struct coreboot_device already includes the tag
> information, so anything that could be included in driver data could be
> parsed out by the driver at probe time, if absolutely needed.

But why limit yourself to 32bits now? Why not make it 64? It is going
to be sent to userspace, so you have to be very careful about it.

thanks,

greg k-h

2024-01-31 00:02:28

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Tue, Jan 30, 2024 at 3:51 PM Greg Kroah-Hartman
<[email protected]> wrote:
> On Tue, Jan 23, 2024 at 02:06:14PM -0800, Brian Norris wrote:
> > "Don't you want to have a driver data or so associated with this?"
..
> But why limit yourself to 32bits now? Why not make it 64? It is going
> to be sent to userspace, so you have to be very careful about it.

Is that question related to the question I pasted/replied to, about
driver data? Or a new topic? Sorry if I'm misunderstanding.

Anyway, for the size of the tag field: I don't have a strong opinion.
But FWIW, they're coming from this project:

https://review.coreboot.org/plugins/gitiles/coreboot/+/269b23280f928510bcadd23182294e5b9dad11ec/payloads/libpayload/include/coreboot_tables.h#36

As you can see there, we're extremely far from exhausting 16 bits, let alone 32.

Brian

2024-01-31 00:23:18

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Tue, Jan 30, 2024 at 04:01:57PM -0800, Brian Norris wrote:
> On Tue, Jan 30, 2024 at 3:51 PM Greg Kroah-Hartman
> <[email protected]> wrote:
> > On Tue, Jan 23, 2024 at 02:06:14PM -0800, Brian Norris wrote:
> > > "Don't you want to have a driver data or so associated with this?"
> ...
> > But why limit yourself to 32bits now? Why not make it 64? It is going
> > to be sent to userspace, so you have to be very careful about it.
>
> Is that question related to the question I pasted/replied to, about
> driver data? Or a new topic? Sorry if I'm misunderstanding.

Same question, driver data, you make it 32 bits.

> Anyway, for the size of the tag field: I don't have a strong opinion.
> But FWIW, they're coming from this project:
>
> https://review.coreboot.org/plugins/gitiles/coreboot/+/269b23280f928510bcadd23182294e5b9dad11ec/payloads/libpayload/include/coreboot_tables.h#36
>
> As you can see there, we're extremely far from exhausting 16 bits, let alone 32.

We've run into running out of bits in other subsystems before, it's
"free" now, just be safe and make it 64 like I think Andy is suggesting.

thanks,

greg k-h

2024-02-01 22:45:46

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Tue, Jan 30, 2024 at 04:23:02PM -0800, Greg Kroah-Hartman wrote:
> On Tue, Jan 30, 2024 at 04:01:57PM -0800, Brian Norris wrote:
> > On Tue, Jan 30, 2024 at 3:51 PM Greg Kroah-Hartman
> > <[email protected]> wrote:
> > > On Tue, Jan 23, 2024 at 02:06:14PM -0800, Brian Norris wrote:
> > > > "Don't you want to have a driver data or so associated with this?"
> > ...
> > > But why limit yourself to 32bits now? Why not make it 64? It is going
> > > to be sent to userspace, so you have to be very careful about it.
> >
> > Is that question related to the question I pasted/replied to, about
> > driver data? Or a new topic? Sorry if I'm misunderstanding.
>
> Same question, driver data, you make it 32 bits.
>
> > Anyway, for the size of the tag field: I don't have a strong opinion.
> > But FWIW, they're coming from this project:
> >
> > https://review.coreboot.org/plugins/gitiles/coreboot/+/269b23280f928510bcadd23182294e5b9dad11ec/payloads/libpayload/include/coreboot_tables.h#36
> >
> > As you can see there, we're extremely far from exhausting 16 bits, let alone 32.
>
> We've run into running out of bits in other subsystems before, it's
> "free" now, just be safe and make it 64 like I think Andy is suggesting.

Either you and Andy are suggesting different things, or I still don't quite get
what you mean.

Andy was suggesting we added a driver_data field, that is:

struct coreboot_device_id {
__u32 tag;
kernel_ulong_t driver_data;
};

You're suggesting we make the tag 64 bits long:

struct coreboot_device_id {
__u64 tag;
};

Like Brian, I'm not sure I see the benefit of either change. As he said, it's
unlikely that having a driver_data would provide any benefit and won't ever be
required anyway, and 32 bits is already a generous space to give to coreboot
tags. That said, I'm also not against either change, and can apply both of them
to the next version if that's indeed what your experience says will work best.
I'll wait another week or so before following up though to make sure we're all
on the same page.

(To be honest I also still don't see how this struct makes it to userspace and
is considered ABI, I only see the generated modalias being ABI and hence 32 vs
64 bit tag is ABI breakage but not adding driver_data, but I'll take your word
for it for now)

Thanks,
Nícolas

2024-02-02 02:22:09

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Thu, Feb 01, 2024 at 05:45:19PM -0500, Nícolas F. R. A. Prado wrote:
> On Tue, Jan 30, 2024 at 04:23:02PM -0800, Greg Kroah-Hartman wrote:
> > On Tue, Jan 30, 2024 at 04:01:57PM -0800, Brian Norris wrote:
> > > On Tue, Jan 30, 2024 at 3:51 PM Greg Kroah-Hartman
> > > <[email protected]> wrote:
> > > > On Tue, Jan 23, 2024 at 02:06:14PM -0800, Brian Norris wrote:
> > > > > "Don't you want to have a driver data or so associated with this?"
> > > ...
> > > > But why limit yourself to 32bits now? Why not make it 64? It is going
> > > > to be sent to userspace, so you have to be very careful about it.
> > >
> > > Is that question related to the question I pasted/replied to, about
> > > driver data? Or a new topic? Sorry if I'm misunderstanding.
> >
> > Same question, driver data, you make it 32 bits.
> >
> > > Anyway, for the size of the tag field: I don't have a strong opinion.
> > > But FWIW, they're coming from this project:
> > >
> > > https://review.coreboot.org/plugins/gitiles/coreboot/+/269b23280f928510bcadd23182294e5b9dad11ec/payloads/libpayload/include/coreboot_tables.h#36
> > >
> > > As you can see there, we're extremely far from exhausting 16 bits, let alone 32.
> >
> > We've run into running out of bits in other subsystems before, it's
> > "free" now, just be safe and make it 64 like I think Andy is suggesting.
>
> Either you and Andy are suggesting different things, or I still don't quite get
> what you mean.
>
> Andy was suggesting we added a driver_data field, that is:
>
> struct coreboot_device_id {
> __u32 tag;
> kernel_ulong_t driver_data;
> };
>
> You're suggesting we make the tag 64 bits long:
>
> struct coreboot_device_id {
> __u64 tag;
> };

Yeah, I'm confused, sorry.

Yes, add some driver_data, and if you are SURE your tag will NEVER be
larger than 32 bits, stick with that, but really, you are using the
space in empty padding anyway, so just make it 64bits please.

thanks,

greg k-h

2024-02-06 20:53:55

by Nícolas F. R. A. Prado

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] firmware: coreboot: Generate aliases for coreboot modules

On Thu, Feb 01, 2024 at 06:21:03PM -0800, Greg Kroah-Hartman wrote:
> On Thu, Feb 01, 2024 at 05:45:19PM -0500, Nícolas F. R. A. Prado wrote:
> > On Tue, Jan 30, 2024 at 04:23:02PM -0800, Greg Kroah-Hartman wrote:
> > > On Tue, Jan 30, 2024 at 04:01:57PM -0800, Brian Norris wrote:
> > > > On Tue, Jan 30, 2024 at 3:51 PM Greg Kroah-Hartman
> > > > <[email protected]> wrote:
> > > > > On Tue, Jan 23, 2024 at 02:06:14PM -0800, Brian Norris wrote:
> > > > > > "Don't you want to have a driver data or so associated with this?"
> > > > ...
> > > > > But why limit yourself to 32bits now? Why not make it 64? It is going
> > > > > to be sent to userspace, so you have to be very careful about it.
> > > >
> > > > Is that question related to the question I pasted/replied to, about
> > > > driver data? Or a new topic? Sorry if I'm misunderstanding.
> > >
> > > Same question, driver data, you make it 32 bits.
> > >
> > > > Anyway, for the size of the tag field: I don't have a strong opinion.
> > > > But FWIW, they're coming from this project:
> > > >
> > > > https://review.coreboot.org/plugins/gitiles/coreboot/+/269b23280f928510bcadd23182294e5b9dad11ec/payloads/libpayload/include/coreboot_tables.h#36
> > > >
> > > > As you can see there, we're extremely far from exhausting 16 bits, let alone 32.
> > >
> > > We've run into running out of bits in other subsystems before, it's
> > > "free" now, just be safe and make it 64 like I think Andy is suggesting.
> >
> > Either you and Andy are suggesting different things, or I still don't quite get
> > what you mean.
> >
> > Andy was suggesting we added a driver_data field, that is:
> >
> > struct coreboot_device_id {
> > __u32 tag;
> > kernel_ulong_t driver_data;
> > };
> >
> > You're suggesting we make the tag 64 bits long:
> >
> > struct coreboot_device_id {
> > __u64 tag;
> > };
>
> Yeah, I'm confused, sorry.
>
> Yes, add some driver_data, and if you are SURE your tag will NEVER be
> larger than 32 bits, stick with that, but really, you are using the
> space in empty padding anyway, so just make it 64bits please.

Ok, after giving it a closer look, I've decided we really should just stick with
32 bits.

More fundamental than the previous argument that we aren't close to exhausting
32 bits for the tag in coreboot, is the fact that tags are literally defined as
32 bits long for the table entries [1]. Meaning, a tag being 32 bits long is
part of the coreboot ABI. We have to parse it as 32bits from memory.
Representing it as 64 bits internally and exposing it as 64 bits to userspace
would not only be unecessarily complicating things, but also misrepresenting the
data that we're getting from the firmware.

I can add driver_data for v4 no problem, as we can simply not use it while we
don't need it, but having tags be 64 bits actively complicates things for no
real gain, so it's a no-go.

Thanks,
Nícolas

[1] https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/main/src/commonlib/include/commonlib/coreboot_tables.h#128