This repository was archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Implement and export CpuId, MsrList and Msrs as FamStructWrappers #8
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
573b5c1
implement CpuId as a FamStructWrapper over kvm_cpuid2
acatangiu 596b6b8
implement Msrs as a FamStructWrapper over kvm_msrs
acatangiu ef8ecc4
implement MsrList as a FamStructWrapper over kvm_msr_list
acatangiu 6751a3c
use a 'fam-wrappers' feature to gate the FamStructWrappers
acatangiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use vmm_sys_util::fam::{FamStruct, FamStructWrapper}; | ||
|
||
#[cfg(feature = "kvm-v4_14_0")] | ||
use super::bindings_v4_14_0::*; | ||
|
||
#[cfg(feature = "kvm-v4_20_0")] | ||
use super::bindings_v4_20_0::*; | ||
|
||
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))] | ||
use super::bindings_v4_20_0::*; | ||
|
||
/// Maximum number of CPUID entries that can be returned by a call to KVM ioctls. | ||
/// | ||
/// See arch/x86/include/asm/kvm_host.h | ||
pub const KVM_MAX_CPUID_ENTRIES: usize = 80; | ||
|
||
/// Maximum number of MSRs KVM supports (See arch/x86/kvm/x86.c). | ||
pub const KVM_MAX_MSR_ENTRIES: usize = 256; | ||
|
||
// Implement the FamStruct trait for kvm_cpuid2. | ||
generate_fam_struct_impl!( | ||
kvm_cpuid2, | ||
kvm_cpuid_entry2, | ||
entries, | ||
u32, | ||
nent, | ||
KVM_MAX_CPUID_ENTRIES | ||
); | ||
|
||
/// Wrapper over the `kvm_cpuid2` structure. | ||
/// | ||
/// The `kvm_cpuid2` structure contains a flexible array member. For details check the | ||
/// [KVM API](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) | ||
/// documentation on `kvm_cpuid2`. To provide safe access to | ||
/// the array elements, this type is implemented using | ||
/// [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html). | ||
pub type CpuId = FamStructWrapper<kvm_cpuid2>; | ||
|
||
// Implement the FamStruct trait for kvm_msrs. | ||
generate_fam_struct_impl!( | ||
kvm_msrs, | ||
kvm_msr_entry, | ||
entries, | ||
u32, | ||
nmsrs, | ||
KVM_MAX_MSR_ENTRIES | ||
); | ||
|
||
/// Wrapper over the `kvm_msrs` structure. | ||
/// | ||
/// The `kvm_msrs` structure contains a flexible array member. For details check the | ||
/// [KVM API](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) | ||
/// documentation on `kvm_msrs`. To provide safe access to | ||
/// the array elements, this type is implemented using | ||
/// [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html). | ||
pub type Msrs = FamStructWrapper<kvm_msrs>; | ||
|
||
// Implement the FamStruct trait for kvm_msr_list. | ||
generate_fam_struct_impl!(kvm_msr_list, u32, indices, u32, nmsrs, KVM_MAX_MSR_ENTRIES); | ||
|
||
/// Wrapper over the `kvm_msr_list` structure. | ||
/// | ||
/// The `kvm_msr_list` structure contains a flexible array member. For details check the | ||
/// [KVM API](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) | ||
/// documentation on `kvm_msr_list`. To provide safe access to | ||
/// the array elements, this type is implemented using | ||
/// [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html). | ||
pub type MsrList = FamStructWrapper<kvm_msr_list>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.