arch: x86_64: fix cpuid leaf 0x1 EBX bits 23-16
Commit5ec47d4883was 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 commitb6667f948efixed 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:5ec47d4883("arch: x86_64: enable HTT flag") Signed-off-by: Changyuan Lyu <changyuanl@google.com>
This commit is contained in:
parent
8ee26286ac
commit
be495ec64a
1 changed files with 3 additions and 2 deletions
|
|
@ -1303,9 +1303,10 @@ fn update_cpuid_topology(
|
|||
let die_width = u16::BITS - (dies_per_package - 1).leading_zeros() + core_width;
|
||||
|
||||
// The very old way: a flat number of logical CPUs per package: CPUID.1H:EBX[23:16] bits.
|
||||
let core_count = dies_per_package as u32 * cores_per_die as u32 * threads_per_core as u32;
|
||||
let mut cpu_ebx = CpuidPatch::get_cpuid_reg(cpuid, 0x1, None, CpuidReg::EBX).unwrap_or(0);
|
||||
cpu_ebx |= ((dies_per_package as u32) * (cores_per_die as u32) * (threads_per_core as u32))
|
||||
& (0xff << 16);
|
||||
cpu_ebx &= !(0xff << 16);
|
||||
cpu_ebx |= (core_count & 0xff) << 16;
|
||||
CpuidPatch::set_cpuid_reg(cpuid, 0x1, None, CpuidReg::EBX, cpu_ebx);
|
||||
|
||||
let mut cpu_edx = CpuidPatch::get_cpuid_reg(cpuid, 0x1, None, CpuidReg::EDX).unwrap_or(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue