x86: remove deprecated KVM based s2idle notification related code
This commit reverts 344e2432d1 "x86:
handle KVM_SYSTEM_EVENT_S2IDLE request" but also some other parts which
grow around this concept. The s2idle notification linux counterpart
based on KVM hypercall was rejected in the linux kernel mailing list and
new approach was suggested which is based on virtual PMC. Additionally
the privileged guest term was introduced only for ManaTEE, which is not
evaluated anymore.
The new Virtual PMC related approach is used instead for getting guest
s2idle notifications, see CL:3780642.
BUG=None
TEST=Build + tools/presubmit crosvm_tests_x86_64
Change-Id: I3cf4b77ab192198fe9e8b990b994a41105c2e72f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4507305
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
fed899f79e
commit
a8985f0ba8
11 changed files with 1 additions and 76 deletions
|
|
@ -130,7 +130,6 @@ pub const GZVM_SYSTEM_EVENT_CRASH: u32 = 3;
|
|||
pub const GZVM_SYSTEM_EVENT_WAKEUP: u32 = 4;
|
||||
pub const GZVM_SYSTEM_EVENT_SUSPEND: u32 = 5;
|
||||
pub const GZVM_SYSTEM_EVENT_SEV_TERM: u32 = 6;
|
||||
pub const GZVM_SYSTEM_EVENT_S2IDLE: u32 = 7;
|
||||
pub const GIC_V3_NR_LRS: u32 = 16;
|
||||
pub const GZVM_IOC_MAGIC: u32 = 146;
|
||||
pub const GZVM_CAP_ARM_VM_IPA_SIZE: u32 = 165;
|
||||
|
|
|
|||
|
|
@ -1232,7 +1232,6 @@ impl Vcpu for GeniezoneVcpu {
|
|||
GZVM_SYSTEM_EVENT_SHUTDOWN => Ok(VcpuExit::SystemEventShutdown),
|
||||
GZVM_SYSTEM_EVENT_RESET => Ok(VcpuExit::SystemEventReset),
|
||||
GZVM_SYSTEM_EVENT_CRASH => Ok(VcpuExit::SystemEventCrash),
|
||||
GZVM_SYSTEM_EVENT_S2IDLE => Ok(VcpuExit::SystemEventS2Idle),
|
||||
_ => {
|
||||
error!("Unknown GZVM system event {}", event_type);
|
||||
Err(Error::new(EINVAL))
|
||||
|
|
|
|||
|
|
@ -1024,7 +1024,6 @@ impl Vcpu for KvmVcpu {
|
|||
KVM_SYSTEM_EVENT_SHUTDOWN => Ok(VcpuExit::SystemEventShutdown),
|
||||
KVM_SYSTEM_EVENT_RESET => self.system_event_reset(event_flags),
|
||||
KVM_SYSTEM_EVENT_CRASH => Ok(VcpuExit::SystemEventCrash),
|
||||
KVM_SYSTEM_EVENT_S2IDLE => Ok(VcpuExit::SystemEventS2Idle),
|
||||
_ => {
|
||||
error!(
|
||||
"Unknown KVM system event {} with flags {}",
|
||||
|
|
|
|||
|
|
@ -448,7 +448,6 @@ pub enum VcpuExit {
|
|||
SystemEventShutdown,
|
||||
SystemEventReset,
|
||||
SystemEventCrash,
|
||||
SystemEventS2Idle,
|
||||
RdMsr {
|
||||
index: u32,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Added by kvm_sys/bindgen.sh
|
||||
pub const KVM_SYSTEM_EVENT_S2IDLE: u32 = 4;
|
||||
// TODO(tjeznach): Remove this when reporting KVM_IOAPIC_NUM_PINS is no longer required.
|
||||
pub const KVM_CAP_IOAPIC_NUM_PINS: u32 = 8191;
|
||||
// TODO(qwandor): Update this once the pKVM patches are merged upstream with a stable capability ID.
|
||||
|
|
|
|||
|
|
@ -22,9 +22,6 @@
|
|||
* copy in the ARM_PROTECTED stuff that isn't quite upstream yet.
|
||||
*/
|
||||
|
||||
// Added by kvm_sys/bindgen.sh
|
||||
pub const KVM_SYSTEM_EVENT_S2IDLE: u32 = 4;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Added by kvm_sys/bindgen.sh
|
||||
pub const KVM_SYSTEM_EVENT_S2IDLE: u32 = 4;
|
||||
// TODO(tjeznach): Remove this when reporting KVM_IOAPIC_NUM_PINS is no longer required.
|
||||
pub const KVM_CAP_IOAPIC_NUM_PINS: u32 = 8191;
|
||||
// TODO(qwandor): Update this once the pKVM patches are merged upstream with a stable capability ID.
|
||||
|
|
|
|||
|
|
@ -1677,12 +1677,6 @@ pub struct RunCommand {
|
|||
/// path to a disk image
|
||||
pub pmem_device: Vec<DiskOption>,
|
||||
|
||||
#[argh(switch)]
|
||||
#[serde(skip)] // TODO(b/255223604)
|
||||
#[merge(strategy = overwrite_option)]
|
||||
/// grant this Guest VM certain privileges to manage Host resources, such as power management
|
||||
pub privileged_vm: Option<bool>,
|
||||
|
||||
#[cfg(feature = "process-invariants")]
|
||||
#[argh(option, arg_name = "PATH")]
|
||||
#[serde(skip)] // TODO(b/255223604)
|
||||
|
|
@ -3087,8 +3081,6 @@ impl TryFrom<RunCommand> for super::config::Config {
|
|||
cfg.force_calibrated_tsc_leaf = cmd.force_calibrated_tsc_leaf.unwrap_or_default();
|
||||
}
|
||||
|
||||
cfg.privileged_vm = cmd.privileged_vm.unwrap_or_default();
|
||||
|
||||
cfg.stub_pci_devices = cmd.stub_pci_device;
|
||||
|
||||
cfg.vvu_proxy = cmd.vvu_proxy;
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,6 @@ pub struct Config {
|
|||
pub plugin_mounts: Vec<BindMount>,
|
||||
pub plugin_root: Option<PathBuf>,
|
||||
pub pmem_devices: Vec<DiskOption>,
|
||||
pub privileged_vm: bool,
|
||||
#[cfg(feature = "process-invariants")]
|
||||
pub process_invariants_data_handle: Option<u64>,
|
||||
#[cfg(feature = "process-invariants")]
|
||||
|
|
@ -1375,7 +1374,6 @@ impl Default for Config {
|
|||
plugin_mounts: Vec::new(),
|
||||
plugin_root: None,
|
||||
pmem_devices: Vec::new(),
|
||||
privileged_vm: false,
|
||||
#[cfg(feature = "process-invariants")]
|
||||
process_invariants_data_handle: None,
|
||||
#[cfg(feature = "process-invariants")]
|
||||
|
|
|
|||
|
|
@ -2790,7 +2790,6 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
to_gdb_channel.clone(),
|
||||
cfg.per_vm_core_scheduling,
|
||||
cpu_config,
|
||||
cfg.privileged_vm,
|
||||
match vcpu_cgroup_tasks_file {
|
||||
None => None,
|
||||
Some(ref f) => Some(
|
||||
|
|
@ -2800,7 +2799,6 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
},
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
cfg.userspace_msr.clone(),
|
||||
guest_suspended_cvar.clone(),
|
||||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), unix))]
|
||||
bus_lock_ratelimit_ctrl,
|
||||
run_mode,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
use std::fs::File;
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::prelude::*;
|
||||
use std::sync::mpsc;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -37,7 +35,7 @@ use hypervisor::VcpuRunHandle;
|
|||
use libc::c_int;
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
use riscv64::Riscv64 as Arch;
|
||||
use sync::Condvar;
|
||||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), unix))]
|
||||
use sync::Mutex;
|
||||
use vm_control::*;
|
||||
#[cfg(feature = "gdb")]
|
||||
|
|
@ -203,47 +201,6 @@ where
|
|||
Ok((vcpu, vcpu_run_handle))
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
|
||||
fn handle_s2idle_request(
|
||||
_privileged_vm: bool,
|
||||
_guest_suspended_cvar: &Arc<(Mutex<bool>, Condvar)>,
|
||||
) {
|
||||
}
|
||||
|
||||
// Allow error! and early return anywhere in function
|
||||
#[allow(clippy::needless_return)]
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
fn handle_s2idle_request(privileged_vm: bool, guest_suspended_cvar: &Arc<(Mutex<bool>, Condvar)>) {
|
||||
const POWER_STATE_FREEZE: &[u8] = b"freeze";
|
||||
|
||||
// For non privileged guests, wake up blocked thread on condvar, which is awaiting
|
||||
// non-privileged guest suspension to finish.
|
||||
if !privileged_vm {
|
||||
let (lock, cvar) = &**guest_suspended_cvar;
|
||||
let mut guest_suspended = lock.lock();
|
||||
*guest_suspended = true;
|
||||
|
||||
cvar.notify_one();
|
||||
info!("dbg: s2idle notified");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// For privileged guests, proceed with the suspend request
|
||||
let mut power_state = match OpenOptions::new().write(true).open("/sys/power/state") {
|
||||
Ok(s) => s,
|
||||
Err(err) => {
|
||||
error!("Failed on open /sys/power/state: {}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(err) = power_state.write(POWER_STATE_FREEZE) {
|
||||
error!("Failed on writing to /sys/power/state: {}", err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fn vcpu_loop<V>(
|
||||
mut run_mode: VmRunMode,
|
||||
cpu_id: usize,
|
||||
|
|
@ -257,11 +214,9 @@ fn vcpu_loop<V>(
|
|||
requires_pvclock_ctrl: bool,
|
||||
from_main_tube: mpsc::Receiver<VcpuControl>,
|
||||
use_hypervisor_signals: bool,
|
||||
privileged_vm: bool,
|
||||
#[cfg(feature = "gdb")] to_gdb_tube: Option<mpsc::Sender<VcpuDebugStatusMessage>>,
|
||||
#[cfg(feature = "gdb")] guest_mem: GuestMemory,
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] msr_handlers: MsrHandlers,
|
||||
guest_suspended_cvar: Arc<(Mutex<bool>, Condvar)>,
|
||||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), unix))]
|
||||
bus_lock_ratelimit_ctrl: Arc<Mutex<Ratelimit>>,
|
||||
) -> ExitState
|
||||
|
|
@ -451,9 +406,6 @@ where
|
|||
info!("system crash event on vcpu {}", cpu_id);
|
||||
return ExitState::Stop;
|
||||
}
|
||||
Ok(VcpuExit::SystemEventS2Idle) => {
|
||||
handle_s2idle_request(privileged_vm, &guest_suspended_cvar);
|
||||
}
|
||||
Ok(VcpuExit::Debug) => {
|
||||
#[cfg(feature = "gdb")]
|
||||
if let Err(e) =
|
||||
|
|
@ -544,11 +496,9 @@ pub fn run_vcpu<V>(
|
|||
#[cfg(feature = "gdb")] to_gdb_tube: Option<mpsc::Sender<VcpuDebugStatusMessage>>,
|
||||
enable_per_vm_core_scheduling: bool,
|
||||
cpu_config: Option<CpuConfigArch>,
|
||||
privileged_vm: bool,
|
||||
vcpu_cgroup_tasks_file: Option<File>,
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
userspace_msr: std::collections::BTreeMap<u32, arch::MsrConfig>,
|
||||
guest_suspended_cvar: Arc<(Mutex<bool>, Condvar)>,
|
||||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), unix))]
|
||||
bus_lock_ratelimit_ctrl: Arc<Mutex<Ratelimit>>,
|
||||
run_mode: VmRunMode,
|
||||
|
|
@ -629,14 +579,12 @@ where
|
|||
requires_pvclock_ctrl,
|
||||
from_main_tube,
|
||||
use_hypervisor_signals,
|
||||
privileged_vm,
|
||||
#[cfg(feature = "gdb")]
|
||||
to_gdb_tube,
|
||||
#[cfg(feature = "gdb")]
|
||||
guest_mem,
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
msr_handlers,
|
||||
guest_suspended_cvar,
|
||||
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), unix))]
|
||||
bus_lock_ratelimit_ctrl,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue