cmdline: add --no-pmu option

Add option to not use the advertised PMU for the VM.

BUG=b:360388014
TEST=boot VM on Android with --no-pmu

Change-Id: I4e614915371bb55337471023a2cc062f58e6c4ee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5937867
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Elie Kheirallah <khei@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Elie Kheirallah 2024-10-16 17:52:27 +00:00 committed by crosvm LUCI
parent 93272c20b6
commit 4cdd0d99da
8 changed files with 17 additions and 0 deletions

View file

@ -439,6 +439,7 @@ impl arch::LinuxArch for AArch64 {
_guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
device_tree_overlays: Vec<DtbOverlay>,
fdt_position: Option<FdtPosition>,
no_pmu: bool,
) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
where
V: VmAArch64,
@ -524,6 +525,7 @@ impl arch::LinuxArch for AArch64 {
let mut use_pmu = vm
.get_hypervisor()
.check_capability(HypervisorCap::ArmPmuV3);
use_pmu &= !no_pmu;
let vcpu_count = components.vcpu_count;
let mut has_pvtime = true;
let mut vcpus = Vec::with_capacity(vcpu_count);

View file

@ -496,6 +496,7 @@ pub trait LinuxArch {
guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
device_tree_overlays: Vec<DtbOverlay>,
fdt_position: Option<FdtPosition>,
no_pmu: bool,
) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
where
V: VmArch,

View file

@ -198,6 +198,7 @@ impl arch::LinuxArch for Riscv64 {
_guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
device_tree_overlays: Vec<DtbOverlay>,
fdt_position: Option<FdtPosition>,
_no_pmu: bool,
) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
where
V: VmRiscv64,

View file

@ -1711,6 +1711,13 @@ pub struct RunCommand {
/// don't use legacy KBD devices emulation
pub no_i8042: Option<bool>,
#[cfg(target_arch = "aarch64")]
#[argh(switch)]
#[serde(skip)] // TODO(b/255223604)
#[merge(strategy = overwrite_option)]
/// disable Performance Monitor Unit (PMU)
pub no_pmu: Option<bool>,
#[argh(switch)]
#[serde(skip)] // TODO(b/255223604)
#[merge(strategy = overwrite_option)]
@ -2799,6 +2806,7 @@ impl TryFrom<RunCommand> for super::config::Config {
);
}
cfg.mte = cmd.mte.unwrap_or_default();
cfg.no_pmu = cmd.no_pmu.unwrap_or_default();
cfg.swiotlb = cmd.swiotlb;
}

View file

@ -827,6 +827,7 @@ pub struct Config {
#[cfg(windows)]
pub net_vhost_user_tube: Option<Tube>,
pub no_i8042: bool,
pub no_pmu: bool,
pub no_rtc: bool,
pub no_smt: bool,
pub params: Vec<String>,
@ -1054,6 +1055,7 @@ impl Default for Config {
#[cfg(windows)]
net_vhost_user_tube: None,
no_i8042: false,
no_pmu: false,
no_rtc: false,
no_smt: false,
params: Vec::new(),

View file

@ -2125,6 +2125,7 @@ where
guest_suspended_cvar.clone(),
dt_overlays,
cfg.fdt_position,
cfg.no_pmu,
)
.context("the architecture failed to build the vm")?;

View file

@ -2658,6 +2658,7 @@ where
/* guest_suspended_cvar= */ None,
dt_overlays,
cfg.fdt_position,
cfg.no_pmu,
)
.exit_context(Exit::BuildVm, "the architecture failed to build the vm")?;

View file

@ -819,6 +819,7 @@ impl arch::LinuxArch for X8664arch {
guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
device_tree_overlays: Vec<DtbOverlay>,
_fdt_position: Option<FdtPosition>,
_no_pmu: bool,
) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
where
V: VmX86_64,