Skip to content

Conversation

@Lencerf
Copy link
Contributor

@Lencerf Lencerf commented Nov 17, 2025

Commit 5ec47d4 was intended to patch ebx bits 23-16 in cpuid leaf 0x1, but it was not working as expected, as in rust, operator << has a stronger precedence than & [1]. Later commit b6667f9 fixed the operator precedence clippy warning, but did not fix the actual issue. As a result, the current code is not changing ebx,

cpu_ebx |= ((dies_per_package as u32) * (cores_per_die as u32) * (threads_per_core as u32))
    & (0xff << 16);

Since the total number of logical processors is generally less than 65536, the right hand side of the expression is 0 in most cases.

[1] https://doc.rust-lang.org/reference/expressions.html#expression-precedence

Fixes: 5ec47d4 ("arch: x86_64: enable HTT flag")

@Lencerf Lencerf requested a review from a team as a code owner November 17, 2025 19:47
Commit 5ec47d4 was intended to patch ebx bits 23-16 in cpuid leaf
0x1, but it was not working as expected, as in rust, operator << has a
stronger precedence than & [1]. Later commit b6667f9 fixed the
operator precedence clippy warning, but did not fix the actual issue. As
a result, the current code is not changing ebx,

```
cpu_ebx |= ((dies_per_package as u32) * (cores_per_die as u32) * (threads_per_core as u32))
    & (0xff << 16);
```

Since the total number of logical processors is generally less than
65536, the right hand side of the expression is 0 in most cases.

[1] https://doc.rust-lang.org/reference/expressions.html#expression-precedence

Fixes: 5ec47d4 ("arch: x86_64: enable HTT flag")
Signed-off-by: Changyuan Lyu <[email protected]>
@phip1611
Copy link
Member

phip1611 commented Nov 17, 2025

Ping @olivereanderson as he is currently working on cpu profiles for #7068 and is currently an expert for all the cpu leaves. Perhaps one of the bugs you are seeing is caused by this, Oliver?

@olivereanderson
Copy link
Contributor

Ping @olivereanderson as he is currently working on cpu profiles for #7068 and is currently an expert for all the cpu leaves. Perhaps one of the bugs you are seeing is caused by this, Oliver?

Hmm, could be, but we should be seeing problems with this even outside of my branch.

@rbradford rbradford added this pull request to the merge queue Nov 18, 2025
Merged via the queue into cloud-hypervisor:main with commit be495ec Nov 18, 2025
46 of 47 checks passed
@likebreath likebreath added the bug-fix Bug fix to include in release notes label Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Bug fix to include in release notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants