Skip to content

mkcosi: recognize arm64 CIH images, not just amd64 - #758

Draft
bfjelds (bfjelds) wants to merge 1 commit into
mainfrom
user/bfjelds/mkcosi-cih-arm64-guids
Draft

mkcosi: recognize arm64 CIH images, not just amd64#758
bfjelds (bfjelds) wants to merge 1 commit into
mainfrom
user/bfjelds/mkcosi-cih-arm64-guids

Conversation

@bfjelds

Copy link
Copy Markdown
Member

Summary

mkcosi's CIH detector (isCIHImage()) only ever accepted the amd64 discoverable-partition-spec GUIDs for ROOT and HASH-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).
  • ROOT and HASH-A/HASH-B now accept either the amd64 or arm64 GUID, reusing the arch-specific constants already defined in this package's metadata.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.
  • No behavior change for amd64 images or any other partition.

Why not runtime.GOARCH?

Deliberately not keying this off runtime.GOARCH: that reflects the architecture of whatever host is running mkcosi, not the architecture of the image being inspected. mkcosi runs natively — unlike, e.g., Image Customizer, which can run under container/binfmt emulation matching the target arch, making runtime.GOARCH incidentally 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 ./... and go vet ./... clean for tools/cmd/mkcosi.
  • No existing unit tests for this package to run.

Status

Draft — mkcosi is 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.

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

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants