Skip to content

Commit

Permalink
fix: coding style for sev and kvm backend
Browse files Browse the repository at this point in the history
Signed-off-by: Harald Hoyer <harald@profian.com>
  • Loading branch information
haraldh authored and npmccallum committed Oct 18, 2021
1 parent 91886c5 commit e9e3331
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
10 changes: 6 additions & 4 deletions src/backend/kvm/builder.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// SPDX-License-Identifier: Apache-2.0

use super::mem::Region;
use crate::backend::kvm::KvmKeepPersonality;
use super::KvmKeepPersonality;

use std::convert::TryFrom;
use std::mem::size_of;
use std::sync::{Arc, RwLock};

use anyhow::{Error, Result};
use kvm_bindings::bindings::kvm_userspace_memory_region;
use kvm_bindings::fam_wrappers::KVM_MAX_CPUID_ENTRIES;
use kvm_ioctls::{Kvm, VcpuFd, VmFd};
use mmarinus::{perms, Map};
use sallyport::elf::pf::kvm::SALLYPORT;
use sallyport::Block;
use std::convert::TryFrom;
use std::mem::size_of;
use std::sync::{Arc, RwLock};
use x86_64::VirtAddr;

pub struct Builder {
Expand Down
1 change: 1 addition & 0 deletions src/backend/kvm/data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::backend::Datum;

use kvm_ioctls::Kvm;

pub fn dev_kvm() -> Datum {
Expand Down
11 changes: 7 additions & 4 deletions src/backend/kvm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// SPDX-License-Identifier: Apache-2.0

pub use kvm_bindings::kvm_userspace_memory_region as KvmUserspaceMemoryRegion;

use super::Loader;
use crate::backend::kvm::data::{dev_kvm, kvm_version};
use crate::backend::kvm::mem::Region;
use data::{dev_kvm, kvm_version};
use mem::Region;

use std::sync::Arc;

use anyhow::Result;
use kvm_bindings::bindings::kvm_userspace_memory_region;
pub use kvm_bindings::kvm_userspace_memory_region as KvmUserspaceMemoryRegion;
use kvm_ioctls::Kvm;
use kvm_ioctls::{VcpuFd, VmFd};
use mmarinus::{perms, Map};
use std::sync::Arc;
use x86_64::VirtAddr;

pub mod builder;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/kvm/thread.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0

use super::super::Command;
use super::KeepPersonality;

use std::sync::{Arc, RwLock};

use crate::backend::kvm::KeepPersonality;
use anyhow::{anyhow, Result};
use kvm_ioctls::{VcpuExit, VcpuFd};
use mmarinus::{perms, Kind, Map};
Expand Down
9 changes: 5 additions & 4 deletions src/backend/sev/builder.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// SPDX-License-Identifier: Apache-2.0

use super::cpuid_page::CpuidPage;
use super::SnpKeepPersonality;
use crate::backend::kvm::builder::kvm_try_from_builder;
use crate::backend::kvm::mem::Region;

use std::convert::TryFrom;
use std::sync::{Arc, RwLock};

use super::cpuid_page::CpuidPage;
use super::mem::Region;
use crate::backend::kvm::builder::kvm_try_from_builder;
use crate::backend::sev::SnpKeepPersonality;
use anyhow::Context;
use anyhow::{Error, Result};
use kvm_ioctls::{Kvm, VmFd};
Expand Down
5 changes: 3 additions & 2 deletions src/backend/sev/cpuid_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
//! FIXME

use const_default::ConstDefault;
use core::mem::size_of;

use core::fmt::{Debug, Formatter};
use core::mem::size_of;
use std::fmt::Display;

use kvm_bindings::bindings::KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
use kvm_bindings::fam_wrappers::KVM_MAX_CPUID_ENTRIES;
use kvm_ioctls::Kvm;
use std::fmt::Display;

const COUNT_MAX: usize = 64;

Expand Down
5 changes: 3 additions & 2 deletions src/backend/sev/data.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-License-Identifier: Apache-2.0

pub use crate::backend::kvm::data::{dev_kvm, kvm_version};

use crate::backend::probe::x86_64::{CpuId, Vendor};
use crate::backend::Datum;

use std::arch::x86_64::__cpuid_count;
use std::fs::OpenOptions;
use std::mem::{transmute, MaybeUninit};
use std::str::from_utf8;

pub use super::super::kvm::data::{dev_kvm, kvm_version};

pub fn has_reasonable_memlock_rlimit() -> Datum {
let mut rlimits = MaybeUninit::uninit();
let res = unsafe { libc::getrlimit(libc::RLIMIT_MEMLOCK, rlimits.as_mut_ptr()) };
Expand Down
8 changes: 5 additions & 3 deletions src/backend/sev/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// SPDX-License-Identifier: Apache-2.0

use super::kvm::{mem, Keep, KeepPersonality};
use super::sev::mem::Region;
use super::kvm::mem::Region;
use super::kvm::{Keep, KeepPersonality};
use super::Loader;

use std::sync::Arc;

use anyhow::Result;
use data::{
dev_kvm, dev_sev, dev_sev_readable, dev_sev_writable, has_reasonable_memlock_rlimit,
Expand All @@ -11,7 +14,6 @@ use data::{
use kvm_ioctls::VmFd;
use sev::firmware::Firmware;
use sev::launch::linux::ioctl::KvmEncRegion;
use std::sync::Arc;

mod builder;
mod cpuid_page;
Expand Down

0 comments on commit e9e3331

Please sign in to comment.