From 4679ac418314660a6b203cb54c4cd0b0844d7506 Mon Sep 17 00:00:00 2001 From: Noah Gold Date: Thu, 9 Jun 2022 21:15:07 -0700 Subject: [PATCH] devices: add IrqChipX86_64::lapic_frequency. This function is used to generate cpuid leaf 15H in some situations. BUG=213152505 TEST=builds Change-Id: Ia5a7c46b32f1bdba366a500caa650edb2e3ae99f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3696534 Tested-by: kokoro Reviewed-by: Daniel Verkamp Commit-Queue: Noah Gold --- devices/src/irqchip/kvm/x86_64.rs | 12 ++++++++++++ devices/src/irqchip/x86_64.rs | 3 +++ 2 files changed, 15 insertions(+) diff --git a/devices/src/irqchip/kvm/x86_64.rs b/devices/src/irqchip/kvm/x86_64.rs index e9bd145817..0de348ef96 100644 --- a/devices/src/irqchip/kvm/x86_64.rs +++ b/devices/src/irqchip/kvm/x86_64.rs @@ -130,6 +130,12 @@ impl IrqChipX86_64 for KvmKernelIrqChip { } } + /// Get the lapic frequency in Hz + fn lapic_frequency(&self) -> u32 { + // KVM emulates the lapic to have a bus frequency of 1GHz + 1_000_000_000 + } + /// Retrieves the state of the PIT. Gets the pit state via the KVM API. fn get_pit(&self) -> Result { Ok(PitState::from(&self.vm.get_pit_state()?)) @@ -746,6 +752,12 @@ impl IrqChipX86_64 for KvmSplitIrqChip { } } + /// Get the lapic frequency in Hz + fn lapic_frequency(&self) -> u32 { + // KVM emulates the lapic to have a bus frequency of 1GHz + 1_000_000_000 + } + /// Retrieves the state of the PIT. Gets the pit state via the KVM API. fn get_pit(&self) -> Result { Ok(self.pit.lock().get_pit_state()) diff --git a/devices/src/irqchip/x86_64.rs b/devices/src/irqchip/x86_64.rs index 5f2f599db0..3015d88495 100644 --- a/devices/src/irqchip/x86_64.rs +++ b/devices/src/irqchip/x86_64.rs @@ -35,6 +35,9 @@ pub trait IrqChipX86_64: IrqChip { /// Set the current state of the specified VCPU's local APIC fn set_lapic_state(&mut self, vcpu_id: usize, state: &LapicState) -> Result<()>; + /// Get the lapic frequency in Hz + fn lapic_frequency(&self) -> u32; + /// Retrieves the state of the PIT. fn get_pit(&self) -> Result;