Skip to content

kernel: carry the YMTC PC41Q dmapool_align_512 row in nvme_id_table, refuse a kernel without it (engine#3088) - #3307

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-kernel/3088-nvme-table-quirk
Nov 22, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-kernel/3088-nvme-table-quirk

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

engine#3088 item 1: the 1bit kernel's nvme_id_table gets the YMTC PC41Q row, so that drive gets the engine#2478 fix with no nvme.quirks= on the command line. The image also refuses a kernel that lacks the row.

What changes

  • third_party/patches/linux/0001-nvme-pci-add-the-YMTC-PC41Q-dmapool_align_512-quirk.patch: { PCI_DEVICE(0x1e49, 0x1081), .driver_data = NVME_QUIRK_DMAPOOL_ALIGN_512, }, placed next to the vendor's two ZHITAI rows. It is 2 lines in drivers/nvme/host/pci.c. git apply --check passes against v7.4-rc1 (6628e7d4c). README in the same directory.
  • os/v3/puppy/kernel-quirks-check.sh: reads a kernel stage's modules.builtin.modinfo (nvme built in) or modules.alias (nvme as a module). It refuses the stage (exit 2) if nvme does not list pci:v00001E49d00001081. mk-huge-kernel.sh runs it after the module checks.
  • docs/kernel.md §1: the build recipe now applies third_party/patches/linux/*.patch. §8 notes the refusal.
  • tests/kernel_quirks_test.sh (ctest kernel_quirks) runs offline against fixture stages, in 12 rows. It checks the patch text (one file, +2/−0, the right ID and flag) and runs the check script on built-in, modular, missing, wrong-driver and no-tree stages. It goes red if the flag in the patch is changed (checked).

Measured (ryzen build, not booted on hardware)

  • The shipped kernel is reproducible from ~/wt/k74-puppy/src. The box's /data/1bit/vmlinuz (sha256 efc7f085…) with its signature removed by sbattach --remove matches that tree's bzImage byte for byte (40d6dba2…).
  • New kernel: built incrementally from a copy of that tree with the patch applied (only pci.o recompiled). vmlinux's nvme_id_table now has the entry 0x1e49 0x1081 driver_data 0x400000, which is 1<<22, NVME_QUIRK_DMAPOOL_ALIGN_512. modules.builtin.modinfo differs from the shipped one by exactly one line, nvme.alias=pci:v00001E49d00001081….
  • The module-signing cert is the same as the shipped build's, so the existing module tree (including updates/ amdxdna and ec_su_axb35) stays valid.
  • The image is signed with the existing "strixhalo Secure Boot Kernel" MOK key using sign-vmlinuz.sh, and sbverify --cert passes. No new key was created. Secure Boot state on the box was not touched.
  • kernel-quirks-check.sh refuses the shipped c26 stage (exit 2) and accepts the new stage.
  • Not run on hardware: per the test-at-the-end rule, the new kernel goes into the next image build.

Item 3 (other DRAM-less SSDs), measured on ryzen's Lexar NM990 1d97:1806, fw 641225, kernel 7.0.0-43, IOMMU DMA-FQ

  • max_hw_sectors_kb is 128, so page-aligned I/O tops out at a 31-entry PRP list. A full 32-entry list only happens on a 128 KiB O_DIRECT write from a buffer at a sub-page offset. I forced that case: writes from buf+512 with 1, 32 and 256 threads, about 16 GB in total. During the writes a bpftrace probe (fexit:nvme:nvme_pci_setup_data_prp) classified every PRP list, and tracepoint:iommu:io_page_fault was armed.
  • Result: 13,980 full 32-entry write lists at pool-page offset 0xf00, across 12 pool pages, with 0 io_page_fault events and 0 IO_PAGE_FAULT lines in dmesg. On strixhalo the YMTC faulted on 2 of 2 such commands.
  • Caveat: this kernel has no IOMMU debugfs, so I could not show that the page after each pool page was unmapped at the time. The result means no over-read was seen under the exact trigger; it does not prove the drive is immune. Because of that, the Lexar gets no table row.

Refs #3088 (items 1 and 3; nothing is closed until the next image boots with this kernel)

🤖 Generated with Claude Code

…refuse a kernel without it (engine#3088)

third_party/patches/linux/0001 adds { PCI_DEVICE(0x1e49, 0x1081), .driver_data =
NVME_QUIRK_DMAPOOL_ALIGN_512 } next to the vendor's two ZHITAI rows, so the drive in the
reference box gets the engine#2478 fix without nvme.quirks= on the command line.
os/v3/puppy/kernel-quirks-check.sh reads a kernel stage's modules.builtin.modinfo /
modules.alias and refuses one whose nvme driver does not list 1e49:1081; mk-huge-kernel.sh
runs it. docs/kernel.md applies the series in the build recipe. tests/kernel_quirks_test.sh
checks the patch text and the check on fixture stages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3088 - Partially compliant

Compliant requirements:

  • Add { PCI_DEVICE(0x1e49, 0x1081), .driver_data = NVME_QUIRK_DMAPOOL_ALIGN_512, } to nvme_id_table in the 1bit kernel
  • The live stick and the installed system carry it (kernel patch)

Non-compliant requirements:

  • Check the other DRAM-less SSDs we ship on for the same 32-entry PRP-list over-read

Requires further human verification:

  • Check the other DRAM-less SSDs we ship on for the same 32-entry PRP-list over-read
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect alias matching

The script uses a regex that may match aliases with extra characters after the device ID, potentially causing false positives. For example, a device with ID 1e49:1081 might incorrectly match an alias like pci:v00001E49d00001081sv*sd*bc*sc*i* if there are additional characters in the alias string that are not part of the intended match.

{ [ -f "$mods/modules.alias" ] && grep -q "^alias $alias[^ ]* $drv$" "$mods/modules.alias"; }; then
Test relies on specific patch file naming

The test script assumes that the patch file will be named 0001-*.patch and only checks for one patch file. If the patch file naming convention changes or multiple patch files are added, the test may fail or not cover all cases.

patches=("$root"/third_party/patches/linux/0001-*.patch)

@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 22, 2026 15:15
@bong-water-water-bong
bong-water-water-bong merged commit e63e70d into main Nov 22, 2026
11 of 12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-kernel/3088-nvme-table-quirk branch November 22, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant