linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: Selecting an NVMEM cell for Power State Change Reason (PSCR) recording
       [not found] <20250618120255.3141862-1-o.rempel@pengutronix.de>
@ 2025-10-02 12:00 ` Oleksij Rempel
  2025-10-02 16:07   ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Oleksij Rempel @ 2025-10-02 12:00 UTC (permalink / raw)
  To: Sebastian Reichel, Srinivas Kandagatla, Benson Leung,
	Tzung-Bi Shih, Daniel Lezcano, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Kees Cook, Tony Luck, Guilherme G. Piccoli,
	Greg Kroah-Hartman
  Cc: kernel, linux-kernel, Liam Girdwood, Mark Brown,
	Rafael J. Wysocki, Zhang Rui, Lukasz Luba, linux-pm,
	Søren Andersen, Guenter Roeck, Matti Vaittinen, Ahmad Fatoum,
	Andrew Morton, chrome-platform, devicetree, linux-hardening

Hi all,

I'm seeking consensus on a minimal, upstream-acceptable way to identify the
single NVMEM cell used to persist a Power State Change Reason (PSCR). Typical
targets are battery-backed RTC scratchpads or small EEPROM. The aim is to have
a tiny breadcrumb available before userspace, across full power cuts, and
shared by bootloader/kernel/userspace.

DT vs Userspace vs ACPI

* DeviceTree (preferred): Describing where the storage lives under a real
  NVMEM provider (RTC/EEPROM) is early, robust, and OS-agnostic.

* Userspace (fallback): Possible via module/cmdline/sysfs, but leaves an
  early-boot window unconfigured and reduces usefulness for embedded devices.

* ACPI: No existing shared mechanism for this use case at present (not
  proposing an ACPI path right now).

What implementations were tried

* A PSCR consumer node in DT -> NACKed as not a HW node.

* Kernel/module parameters or sysfs selection -> tried earlier, but rejected
  for new designs and cannot guarantee early availability.

* Name-based lookups in NVMEM -> considered fragile and not scalable.

Other options which came in question (seeking guidance)

* cell-level `compatible` on a fixed-cell child (analogous to `mac-base`) to
  nominate the PSCR cell under the existing NVMEM provider. DT remains purely
  descriptive (location/size); encoding is documented outside DT and shared
  across components.

* `/chosen` phandle pointing to the nominated fixed-cell (simple to discover;
  unsure about policy concerns).

* pstore integration (not tried): a backend that uses a nominated NVMEM cell if
  such a nomination is acceptable.

* nvmem-layout usage (not tried): provider-side markup of the region to
  indicate it carries PSCR, if that pattern is acceptable for this purpose.

* Open to any established precedent for nominating a specific NVMEM cell for a
  system role without introducing software/virtual DT nodes.

Ask

* Is a cell-level `compatible` on a `fixed-cell` child an acceptable way to
  nominate the PSCR cell?

* If not, is a `/chosen` phandle acceptable here, or is there a preferred
  alternative?

Thanks for guidance - once the selection mechanism is agreed, I can respin the
PSCR series accordingly.

Latest patch version: https://lore.kernel.org/all/aHTZTFxfS6Bn4yhz@pengutronix.de/

Best Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: RFC: Selecting an NVMEM cell for Power State Change Reason (PSCR) recording
  2025-10-02 12:00 ` RFC: Selecting an NVMEM cell for Power State Change Reason (PSCR) recording Oleksij Rempel
@ 2025-10-02 16:07   ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2025-10-02 16:07 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Sebastian Reichel, Srinivas Kandagatla, Benson Leung,
	Tzung-Bi Shih, Daniel Lezcano, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Tony Luck, Guilherme G. Piccoli, Greg Kroah-Hartman,
	kernel, linux-kernel, Liam Girdwood, Mark Brown,
	Rafael J. Wysocki, Zhang Rui, Lukasz Luba, linux-pm,
	Søren Andersen, Guenter Roeck, Matti Vaittinen, Ahmad Fatoum,
	Andrew Morton, chrome-platform, devicetree, linux-hardening

On Thu, Oct 02, 2025 at 02:00:09PM +0200, Oleksij Rempel wrote:
> I'm seeking consensus on a minimal, upstream-acceptable way to identify the
> single NVMEM cell used to persist a Power State Change Reason (PSCR). Typical
> targets are battery-backed RTC scratchpads or small EEPROM. The aim is to have
> a tiny breadcrumb available before userspace, across full power cuts, and
> shared by bootloader/kernel/userspace.
> [...]
> * pstore integration (not tried): a backend that uses a nominated NVMEM cell if
>   such a nomination is acceptable.

Several years ago I wanted to have tighter integration between pstore
and nvdimm code. The thread is here, for reference:
https://lore.kernel.org/lkml/CAGXu5jLtmb3qinZnX3rScUJLUFdf+pRDVPjy=CS4KUtW9tLHtw@mail.gmail.com/

I'm not sure it it'll be a useful as background, but I thought I'd
mention it. :)

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-02 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250618120255.3141862-1-o.rempel@pengutronix.de>
2025-10-02 12:00 ` RFC: Selecting an NVMEM cell for Power State Change Reason (PSCR) recording Oleksij Rempel
2025-10-02 16:07   ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).