Skip to content

Commit a8f3cab

Browse files
committed
feat(vmm): Normalize CPUID leaf 0x1F
Intel Sapphire Rapids has CPUID leaf 0x1F that is a preferred superset to leaf 0xB. Intel recommends using leaf 0x1F when available rather than leaf 0xB. We don't use any other domains than ones supported leaf 0xB, so just copy leaf 0xB to leaf 0x1F. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent b19522f commit a8f3cab

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

docs/cpu_templates/cpuid-normalization.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ See also: [boot protocol settings](boot-protocol.md)
3636
| Set FDP_EXCPTN_ONLY bit | 0x7 | 0x0 | EBX | 6 |
3737
| Set "Deprecates FPU CS and FPU DS values" bit | 0x7 | 0x0 | EBX | 13 |
3838
| Disable performance monitoring | 0xa | - | all | all |
39+
| Fill v2 extended topology enumeration leaf | 0x1f | all | all | all |
3940
| Update brand string to use a default format and real frequency | 0x80000002, 0x80000003, 0x80000004 | - | all | all |
4041

4142
## AMD-specifc CPUID normalization

src/vmm/src/cpu_config/x86_64/cpuid/intel/normalize.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl super::IntelCpuid {
7373
self.update_power_management_entry()?;
7474
self.update_extended_feature_flags_entry()?;
7575
self.update_performance_monitoring_entry()?;
76+
self.update_extended_topology_v2_entry();
7677
self.update_brand_string_entry()?;
7778

7879
Ok(())
@@ -214,6 +215,29 @@ impl super::IntelCpuid {
214215
Ok(())
215216
}
216217

218+
/// Update extended topology v2 entry
219+
///
220+
/// CPUID leaf 1FH is a preferred superset to leaf 0xB. Intel recommends using leaf 0x1F when
221+
/// available rather than leaf 0xB.
222+
///
223+
/// Since we don't use any domains than ones supported in leaf 0xB, we just copy contents of
224+
/// leaf 0xB to leaf 0x1F.
225+
fn update_extended_topology_v2_entry(&mut self) {
226+
// Skip if leaf 0x1F does not exist.
227+
if self.get(&CpuidKey::leaf(0x1F)).is_none() {
228+
return;
229+
}
230+
231+
for index in 0.. {
232+
if let Some(subleaf) = self.get(&CpuidKey::subleaf(0xB, index)) {
233+
self.0
234+
.insert(CpuidKey::subleaf(0x1F, index), subleaf.clone());
235+
} else {
236+
break;
237+
}
238+
}
239+
}
240+
217241
fn update_brand_string_entry(&mut self) -> Result<(), NormalizeCpuidError> {
218242
// Get host brand string.
219243
let host_brand_string: [u8; BRAND_STRING_LENGTH] = host_brand_string();

0 commit comments

Comments
 (0)