Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ampere(R) Altra(R) Processor - CPU Detection Error #236

Closed
ozanMSFT opened this issue Apr 11, 2024 · 0 comments · Fixed by #237
Closed

Ampere(R) Altra(R) Processor - CPU Detection Error #236

ozanMSFT opened this issue Apr 11, 2024 · 0 comments · Fixed by #237

Comments

@ozanMSFT
Copy link
Contributor

ozanMSFT commented Apr 11, 2024

Summary:

PR 220 has introduced an index problem that is preventing the retrieval of correct CPU information for Windows ARM64 systems using Ampere(R) Altra(R) Processor.

Found by: @iremyux


Details:

The main reason is the incompatibility between woa_chip_name (windows-arm-init.h) and woa_chips[] (init.c).

Since woa_chip_name_microsoft_sq_3 is duplicated, this for loop is not reaching the Ampere(R) Altra(R) Processor element in the array due to wrong size.


Error:

"Unknown chip model name 'Ampere(R) Altra(R) Processor'.
Please add new Windows on Arm SoC/chip support to arm/windows/init.c!"

cc: @iremyux, @malfet

malfet pushed a commit that referenced this issue Apr 17, 2024
**Summary:**

Resolves #236

Also related to [PR 220](#220) change.

```
"Unknown chip model name 'Ampere(R) Altra(R) Processor'.
Please add new Windows on Arm SoC/chip support to arm/windows/init.c!"
```

---

**Previous error details:**

The error's reason was:

`woa_chip_name` (`windows-arm-init.h`)  enum had only 4 elements (stored in `woa_chip_name_last`)

```c
enum woa_chip_name {
	woa_chip_name_microsoft_sq_1 = 0,
	woa_chip_name_microsoft_sq_2 = 1,
	woa_chip_name_microsoft_sq_3 = 2,
	woa_chip_name_ampere_altra = 3,
	woa_chip_name_unknown = 4,
	woa_chip_name_last = woa_chip_name_unknown
};
```

However, `woa_chips[]`  (`init.c`) has a duplicated value for `woa_chip_name_microsoft_sq_3` due to different strings for same target after the [PR 220](#220)

> Strings are `Snapdragon (TM) 8cx Gen 3` and `Snapdragon Compute Platform`

And this was causing following `for loop` (`init.c`) is not checking for all elements in `woa_chips[]`.

```c
for (uint32_t i = 0; i < (uint32_t)woa_chip_name_last; i++) {
	size_t compare_length = wcsnlen(woa_chips[i].chip_name_string, CPUINFO_PACKAGE_NAME_MAX);
	int compare_result = wcsncmp(text_buffer, woa_chips[i].chip_name_string, compare_length);
	if (compare_result == 0) {
		chip_info = woa_chips + i;
		break;
	}
}
```

---

**Fix Details:**

We added `woa_chip_name_microsoft_sq_3_devkit` to maintain **one to one** relationship between `woa_chip_name` (`windows-arm-init.h`) and `woa_chips[]` (`init.c`).

Also, we especially specified indexes with `enums` to prevent future duplications and increase readability of the code and relationship.
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 a pull request may close this issue.

1 participant