x86: Expost HT flag to Guest in host-cpu-topology
At present, host-cpu-topology won't set HT flag for vCPU.
It's reasonable to allow Guest have the same HT flag setting as Host
when set host-cpu-topology.
BUG=None
TEST=cargo build
TEST=set host-cpu-topology and check ht flag in /proc/cpuinfo
Change-Id: I116e49975ab32d37c733690bc0f0f96148fbd4f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314869
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
diff --git a/src/main.rs b/src/main.rs
index 87de9cf..c7580c3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2211,6 +2211,15 @@
));
}
if cfg.host_cpu_topology {
+ if cfg.no_smt {
+ return Err(argument::Error::ExpectedArgument(
+ "`host-cpu-topology` cannot be set at the same time as `no_smt`, since \
+ the smt of the Guest is the same as that of the Host when \
+ `host-cpu-topology` is set."
+ .to_owned(),
+ ));
+ }
+
// Safe because we pass a flag for this call and the host supports this system call
let pcpu_count = unsafe { libc::sysconf(libc::_SC_NPROCESSORS_CONF) } as usize;
if cfg.vcpu_count.is_some() {