mkcosi: recognize arm64 CIH images, not just amd64 - #758
Draft
bfjelds (bfjelds) wants to merge 1 commit into
Draft
mkcosi: recognize arm64 CIH images, not just amd64#758bfjelds (bfjelds) wants to merge 1 commit into
bfjelds (bfjelds) wants to merge 1 commit into
Conversation
isCIHImage() only accepted the amd64 discoverable-partition-spec GUIDs for ROOT and HASH-A/HASH-B, so any arm64 CIH image was silently misclassified as non-CIH and fell back to generic (non-CIH) metadata population -- not a hard failure, but a loss of CIH-specific metadata (e.g. usrhash extraction) for arm64 images. Change cihPartitionDef.TypeGUID (single value) to TypeGUIDs (a list), and accept either the amd64 or arm64 GUID for ROOT and HASH-A/HASH-B, reusing the arch-specific constants already defined in this package's metadata.go (PartitionTypeRootAmd64/Arm64, PartitionTypeUsrAmd64Verity/ Arm64Verity). Deliberately does not key this off runtime.GOARCH: that reflects the architecture of whatever host is running mkcosi, not the architecture of the image being inspected, and mkcosi runs natively (unlike e.g. Image Customizer, which can run under container/binfmt emulation matching the target arch). Matching against both known GUID sets directly is correct regardless of host/target arch relationship. isCIHImage() itself is refactored to key partMap by partition name only (GPT partition names are already unique within a CIH image) and check the actual type GUID against the acceptable set for that name, rather than keying by name+typeGUID as before. No behavior change for amd64 images or for any other partition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
fintelia
approved these changes
Aug 28, 2026
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
mkcosi's CIH detector (isCIHImage()) only ever accepted the amd64 discoverable-partition-spec GUIDs forROOTandHASH-A/HASH-B. An arm64 CIH image is silently misclassified as non-CIH and falls back to generic (non-CIH) metadata population — not a hard failure, but a loss of CIH-specific metadata (e.g.usrhash=extraction) for arm64 images.Change
cihPartitionDef.TypeGUID(single value) →TypeGUIDs(a list).ROOTandHASH-A/HASH-Bnow accept either the amd64 or arm64 GUID, reusing the arch-specific constants already defined in this package'smetadata.go(PartitionTypeRootAmd64/Arm64,PartitionTypeUsrAmd64Verity/Arm64Verity).isCIHImage()is refactored to key its internal partition map by name only (GPT partition names are already unique within a CIH image) and check the actual type GUID against the acceptable set for that name.Why not
runtime.GOARCH?Deliberately not keying this off
runtime.GOARCH: that reflects the architecture of whatever host is runningmkcosi, not the architecture of the image being inspected.mkcosiruns natively — unlike, e.g., Image Customizer, which can run under container/binfmt emulation matching the target arch, makingruntime.GOARCHincidentally correct there. Matching against both known GUID sets directly is correct regardless of the host/target architecture relationship (native, cross-built, or emulated).Validation
go build ./...andgo vet ./...clean fortools/cmd/mkcosi.Status
Draft —
mkcosiis not currently invoked by any known consumer (ACL's COSI generation uses Image Customizer instead), so this is a proactive fix for a latent bug rather than an active regression. Opening for visibility/review; not urgent.