* [PATCH v2] powerpc: wii: Add the fixed OTP layout
@ 2026-07-29 22:50 Link Mauve
2026-07-29 23:20 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Link Mauve @ 2026-07-29 22:50 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Link Mauve, Michael Garofalo, Ash Logan, Jonathan Neuschäfer,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), devicetree, linuxppc-dev,
linux-kernel
These 128 bytes have a known fixed layout, so we can expose those as
cells for either kernel or userspace consumption.
Signed-off-by: Link Mauve <linkmauve@linkmauve.fr>
---
arch/powerpc/boot/dts/wii.dts | 42 +++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
Changes since v1:
- Link to v1:
https://lore.kernel.org/lkml/20260726181921.16269-1-linkmauve@linkmauve.fr/T/
- Switch to using hyphens instead of underscores as it is preferred in
device-trees.
- Extend device-private-key@28 to 0x1e bytes instead of 0x1c, which is
its correct size.
- Document that this cell and the next one overlap for two bytes, and
it’s expected.
diff --git a/arch/powerpc/boot/dts/wii.dts b/arch/powerpc/boot/dts/wii.dts
index 473d9feb9cdb..d3a94d94e9e1 100644
--- a/arch/powerpc/boot/dts/wii.dts
+++ b/arch/powerpc/boot/dts/wii.dts
@@ -233,6 +233,48 @@ control@d800100 {
otp@d8001ec {
compatible = "nintendo,hollywood-otp";
reg = <0x0d8001ec 0x8>;
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ boot1-sha1@0 {
+ reg = <0x00 0x14>;
+ };
+
+ common-key@14 {
+ reg = <0x14 0x10>;
+ };
+
+ device-id@24 {
+ reg = <0x24 0x4>;
+ };
+
+ /*
+ * device-private-key@28 and nand-hmac-key@44
+ * overlap on two bytes, that’s expected.
+ */
+ device-private-key@28 {
+ reg = <0x28 0x1e>;
+ };
+
+ nand-hmac-key@44 {
+ reg = <0x44 0x14>;
+ };
+
+ nand-key@58 {
+ reg = <0x58 0x10>;
+ };
+
+ backup-key@68 {
+ reg = <0x68 0x10>;
+ };
+
+ unknown@78 {
+ reg = <0x78 0x8>;
+ };
+ };
};
disk@d806000 {
base-commit: 78bc8af4affb9a732504eb22eeac7d1e50883853
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] powerpc: wii: Add the fixed OTP layout
2026-07-29 22:50 [PATCH v2] powerpc: wii: Add the fixed OTP layout Link Mauve
@ 2026-07-29 23:20 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-07-29 23:20 UTC (permalink / raw)
To: Link Mauve; +Cc: conor+dt, devicetree, robh
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] The `device-private-key@28` NVMEM cell has a length of 30 bytes, which is unaligned to the provider's 4-byte `word_size`, causing an unconditional `dev_err` to be logged during boot.
Pre-existing issues:
- [High] Concurrent reads to the Nintendo OTP NVMEM device cause data corruption due to missing locking in `nintendo_otp_reg_read`.
--
--- Patch [1]: [PATCH v2] powerpc: wii: Add the fixed OTP layout ---
commit 790200474049a449f0c4b09d4900a200ca3ca581
Author: Link Mauve <linkmauve@linkmauve.fr>
powerpc: wii: Add the fixed OTP layout
This commit adds a fixed nvmem-layout to the hollywood-otp device tree
node for the Nintendo Wii. It defines the locations and sizes of various
keys and IDs within the 128-byte OTP memory, exposing them as NVMEM cells.
Link: https://lore.kernel.org/lkml/20260726181921.16269-1-linkmauve@linkmauve.fr/T/
> diff --git a/arch/powerpc/boot/dts/wii.dts b/arch/powerpc/boot/dts/wii.dts
> index 473d9feb9cdb8..d3a94d94e9e19 100644
> --- a/arch/powerpc/boot/dts/wii.dts
> +++ b/arch/powerpc/boot/dts/wii.dts
> @@ -233,6 +233,48 @@ control@d800100 {
> otp@d8001ec {
> compatible = "nintendo,hollywood-otp";
> reg = <0x0d8001ec 0x8>;
> +
> + nvmem-layout {
> + compatible = "fixed-layout";
> + #address-cells = <1>;
> + #size-cells = <1>;
[ ... ]
> + /*
> + * device-private-key@28 and nand-hmac-key@44
> + * overlap on two bytes, that’s expected.
> + */
> + device-private-key@28 {
> + reg = <0x28 0x1e>;
> + };
[Severity: Medium]
Does this 30-byte length trigger a spurious error log on boot?
The nintendo-otp driver specifies a word_size of 4. When the NVMEM core
parses this cell via nvmem_add_cells_from_dt(), it sets the raw length
to 30. Later, nvmem_cell_info_to_nvmem_cell_entry_nodup() checks if the
raw length is aligned to the word size.
Since 30 is not a multiple of 4, will the NVMEM core unconditionally log
a dev_err before rounding it up?
Would adding the bits property (e.g., bits = <0 240>) allow the NVMEM core
to gracefully pre-align the raw read length without emitting the spurious
error?
[ ... ]
> + unknown@78 {
> + reg = <0x78 0x8>;
> + };
> + };
[Severity: High]
This is a pre-existing issue, but does concurrent reading of these newly
exposed OTP cells cause data corruption?
Looking at the driver in drivers/nvmem/nintendo-otp.c:
nintendo_otp_reg_read() {
...
iowrite32be(OTP_READ | bank | addr, priv->regs + HW_OTPCMD);
*val++ = ioread32be(priv->regs + HW_OTPDATA);
...
}
Because this uses a stateful two-step I/O sequence (writing the target
address to HW_OTPCMD, then reading the data from HW_OTPDATA) without any
synchronization primitives, what happens if multiple drivers or userspace
processes read from these cells concurrently?
Will the executions interleave, causing one thread to read the data requested
by another thread?
> };
>
> disk@d806000 {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729225010.838760-1-linkmauve@linkmauve.fr?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-29 23:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 22:50 [PATCH v2] powerpc: wii: Add the fixed OTP layout Link Mauve
2026-07-29 23:20 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox