Re: [PATCH v7] firmware: google: Implement cbmem in sysfs driver

From: Jack Rosenthal
Date: Sat Aug 06 2022 - 16:46:24 EST


On 2022-08-04 at 15:59 -0500, Stephen Boyd wrote:
> I suspect this won't work because the driver can be unbound, and thus
> the mapping can be destroyed by devm, but then the kobject and sysfs
> file like 'mem' can be held by userspace after the driver is unbound.
> Userspace access after that time will try to read/write unmapped memory.

When the driver is unbound, read()/write() will return -ENODEV, and
mmap() isn't supported.

> Why not make this in the bus driver (coreboot-table.c)? In fact, most
> things could probably be created there instead of in a 'driver' that
> really isn't doing much 'driving' at all.

In v8, I moved the coreboot_kobj to coreboot-table.c. I imagine in the
future we could move some of the other things (e.g., "vpd") under this
object for consistency. So now the structure is:

/sys/firmware/coreboot/cbmem/<id>/...