Skip to content

Commit

Permalink
XXX: fix the small stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmooney committed Sep 26, 2023
1 parent 62f3adb commit fdb74ba
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
11 changes: 9 additions & 2 deletions bin/propolis-standalone/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,18 @@ pub fn parse_cpuid(config: &Config) -> anyhow::Result<Option<cpuid::Set>> {
let mut set = cpuid::Set::new(vendor);
let entries: Vec<CpuidEntry> = profile.try_into()?;
for entry in entries {
// TODO: balk at conflicts?
set.insert(
let conflict = set.insert(
cpuid::Ident(entry.func, entry.idx),
cpuid::Entry::from(entry.values),
);

if conflict.is_some() {
anyhow::bail!(
"conflicing entry at func:{:#?} idx:{:#?}",
entry.func,
entry.idx
)
}
}
Ok(Some(set))
} else {
Expand Down
4 changes: 2 additions & 2 deletions crates/bhyve-api/sys/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ impl vcpu_cpuid_entry {
///
/// Bhyve expects that cpuid entries are sorted by function, and then index,
/// from least to greatest. Entries which must match on index should come
/// before (less-than) those do not, so the former can take precedence in
/// matching.
/// before (less-than) those that do not, so the former can take precedence
/// in matching.
///
/// This function is provided so that a list of entries can be easily sorted
/// prior to loading them into the kernel VMM.
Expand Down
2 changes: 1 addition & 1 deletion crates/cpuid-profile-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct CpuidEntry {
pub enum CpuidParseError {
#[error("Unable to parse leaf {0}: {1}")]
Leaf(String, std::num::ParseIntError),
#[error("Unable to values: {0}")]
#[error("Unable to parse values: {0}")]
Values(&'static str),
}

Expand Down
10 changes: 7 additions & 3 deletions lib/propolis/src/cpuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,16 @@ impl Specializer {
}
TopoKind::Ext1E => {
let id = self.vcpuid.unwrap_or(0) as u32;
let compute_id = if self.has_smt { id / 2 } else { id };
let mut ebx = id;
if self.has_smt {
// bits 15:8 hold the zero-based threads-per-compute-unit
ebx |= 0x100;
}
set.insert(
Ident(leaf, None),
Entry {
eax: id,
ebx: 0x100 | id,
ebx,
// TODO: populate ecx info?
ecx: 0,
edx: 0,
Expand Down Expand Up @@ -409,5 +413,5 @@ pub fn host_query(ident: Ident) -> Entry {
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
pub fn host_query(_ident: Ident) -> Entry {
panic("this is not going to work on non-x86")
panic!("this is not going to work on non-x86")
}

0 comments on commit fdb74ba

Please sign in to comment.