mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 20:04:20 +00:00
This search/replace updates all copyright notices to drop the "All rights reserved", Use "ChromiumOS" instead of "Chromium OS" and drops the trailing dots. This fulfills the request from legal and unifies our notices. ./tools/health-check has been updated to only accept this style. BUG=b:246579983 TEST=./tools/health-check Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com>
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
// Copyright 2019 The ChromiumOS Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
pub use crate::generated::plugin::*;
|
|
|
|
/// Converts protobuf representation of CpuId data into KVM format.
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
pub fn cpuid_proto_to_kvm(entry: &CpuidEntry) -> kvm_sys::kvm_cpuid_entry2 {
|
|
// Safe: C structures are expected to be zero-initialized.
|
|
let mut e: kvm_sys::kvm_cpuid_entry2 = unsafe { std::mem::zeroed() };
|
|
e.function = entry.function;
|
|
if entry.has_index {
|
|
e.flags = kvm_sys::KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
|
|
}
|
|
e.index = entry.index;
|
|
e.eax = entry.eax;
|
|
e.ebx = entry.ebx;
|
|
e.ecx = entry.ecx;
|
|
e.edx = entry.edx;
|
|
|
|
e
|
|
}
|
|
|
|
/// Converts KVM representation of CpuId data into protobuf format.
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
pub fn cpuid_kvm_to_proto(entry: &kvm_sys::kvm_cpuid_entry2) -> CpuidEntry {
|
|
let mut e = CpuidEntry::new();
|
|
e.function = entry.function;
|
|
e.has_index = entry.flags & kvm_sys::KVM_CPUID_FLAG_SIGNIFCANT_INDEX != 0;
|
|
e.index = entry.index;
|
|
e.eax = entry.eax;
|
|
e.ebx = entry.ebx;
|
|
e.ecx = entry.ecx;
|
|
e.edx = entry.edx;
|
|
|
|
e
|
|
}
|