Skip to content

Initialize vendor/uarch out-parameters for unhandled implementers#395

Merged
GregoryComer merged 1 commit into
pytorch:mainfrom
maxim-davgalev:main
Jun 17, 2026
Merged

Initialize vendor/uarch out-parameters for unhandled implementers#395
GregoryComer merged 1 commit into
pytorch:mainfrom
maxim-davgalev:main

Conversation

@maxim-davgalev

@maxim-davgalev maxim-davgalev commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Initialize the vendor/uarch out-parameters at function entry in
cpuinfo_arm_decode_vendor_uarch (src/arm/uarch.c), so an unhandled
implementer yields unknown values rather than uninitialized stack values.

Fixes #394

…arch

The default case of the implementer switch only logs a warning and
returns without writing *vendor or *uarch. Callers such as
get_core_info_from_midr() in src/arm/windows/init.c pass uninitialized
stack variables, so for any unhandled implementer the reported vendor
and uarch are whatever happened to be on the stack.

Initialize both out-parameters to cpuinfo_vendor_unknown /
cpuinfo_uarch_unknown at function entry so the decode result is
deterministic for every implementer, present or future.
@meta-cla

meta-cla Bot commented Jun 16, 2026

Copy link
Copy Markdown

Hi @maxim-davgalev!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@maxim-davgalev maxim-davgalev marked this pull request as draft June 16, 2026 10:22
@meta-cla

meta-cla Bot commented Jun 16, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the cla signed label Jun 16, 2026
@maxim-davgalev maxim-davgalev marked this pull request as ready for review June 16, 2026 10:23
@fbarchard

Copy link
Copy Markdown
Contributor

Does #385 cover this?

@maxim-davgalev

Copy link
Copy Markdown
Contributor Author

Does #385 cover this?

Yes, #385 covers part of this.

#395 addresses two defects in cpuinfo_arm_decode_vendor_uarch:

  1. Missing Apple implementer ('a' / 0x61) case. Add Apple M1/M2/M3/M4 Linux MIDR detection #385 fully covers this.

  2. The 'default' branch only logs a warning and never writes the *vendor / *uarch out-parameters, while the caller passes uninitialized stack variables. Add Apple M1/M2/M3/M4 Linux MIDR detection #385 does not cover this.

So, as #385 fixes logic for Apple's implementer 'a' (0x61), I can drop the Apple-case patch and update the PR and issue #394.

@maxim-davgalev maxim-davgalev changed the title Correctly identify Apple CPUs in the generic ARM MIDR decoder Initialize vendor/uarch out-parameters for unhandled implementers Jun 17, 2026
@maxim-davgalev

Copy link
Copy Markdown
Contributor Author

I've updated the PR and issue #394.

@GregoryComer GregoryComer merged commit f9176bd into pytorch:main Jun 17, 2026
11 of 12 checks passed
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.

cpuinfo_arm_decode_vendor_uarch returns uninitialized vendor/uarch for unhandled implementers

3 participants