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 <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
This commit is contained in:
Noah Gold 2022-06-09 21:15:07 -07:00 committed by Chromeos LUCI
parent 2efb19303d
commit 4679ac4183
2 changed files with 15 additions and 0 deletions

View file

@ -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<PitState> {
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<PitState> {
Ok(self.pit.lock().get_pit_state())

View file

@ -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<PitState>;