patina_boot: add partition module (lock_partition_write, write_partition_raw, bp_write)#14
Draft
kat-perez wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ion_raw, bp_write) * lock_partition_write — NVMe Set Features FID 11h (BPWPC). Recovered from closed PR #1488. CDW11 BPWPS bit layout not yet validated against NVMe 1.4 §5.21.1.13 Figure 312 on hardware. * write_partition_raw — BlockIo WriteBlocks + FlushBlocks at LBA 0, block-aligned with zero-padded tail. Recovered from closed PR #1489. * bp_write — Identify Controller (CNS=01h) → chunked Firmware Image Download at FWUG granularity → Firmware Commit (action 110b DownloadBP, BPID at CDW10 bit 31). Caller sizes `data` to BPSIZE; helper does not read BPINFO. 85 existing unit tests pass.
0f8cc9c to
65a76de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
patina_boot::partitionmodule with three helpers for platforms building System Recovery Environment (SRE) flows that own boot-partition lifecycle:lock_partition_write(device_path)— NVMe Set Features FID11h(Boot Partition Write Protection Configuration) to place BP0 + BP1 in Write Protect Until Power Cycle.write_partition_raw(device_path, data)— BlockIoWriteBlocks+FlushBlocksat LBA 0 of any BlockIo-exposed partition.bp_write(device_path, bank_id, data)— chunked NVMeFirmware Image Download+Firmware Commit(action 110b DownloadBP, BPID at CDW10 bit 31) targeting BP0 or BP1.This recovers the work from closed PRs #1488 and #1489 (closed 2026-05-12 when the SRE orchestrator moved out of patina_boot) plus adds the BP-write side that those PRs didn't cover.
All 85 existing unit tests pass.
Hardware verification
End-to-end Pass-Thru command bytes exercised on a Surface Maa bench (Kioxia KBG8HZNS512G, NVMe 2.0,
CAP.BPS=1,BPSZ= 8192 × 128 KiB = 1 GiB) via a one-off shell-app harness:EFI_NVM_EXPRESS_PASS_THRU_PROTOCOLreachable viaBootServices.locate_device_pathbp_writeis correct; the harness's first version had this wrong and tripped "Boot Partition Write Prohibited" against the active BP0)Known controller quirk (documented inline in
bp_write)The Kioxia KBG8 firmware rejects cumulative
Firmware Image Downloadpast 16 MiB with command-specific status14h"Overlapping Range" — even though NVMe 1.4 spec requires acceptance of up to BPSIZE worth of bytes before Commit. This helper trusts the spec; consumers needing full-BP writes on Kioxia BG8 will hit this and may need vendor workarounds (intermediate Commits or alternate sequence). Other NVMe controllers should work as-is.Caveats for reviewers
lock_partition_write's CDW11 layout (BP0WPS bits 2:0, BP1WPS bits 5:3) is inherited unchanged from the closed PR #1488. I have not yet validated it against the actual NVMe 1.4 §5.21.1.13 Figure 312 layout on hardware. Worth a careful spec read before depending on it.dataslice. A separate read of theBPINFOMMIO register is needed to learn BPSIZE; that requires PCI BAR access and is out of scope here.FW_COMMIT_ACTION_ACTIVATE_BP(commit action111b) is defined but unused; reserved for a futurebp_activate()helper.Refs