-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the KVM_TDX_INIT_VCPU ioctl. Signed-off-by: Jake Correnti <[email protected]>
- Loading branch information
1 parent
6221c28
commit 2f0863c
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub mod ioctl; |
This file contains 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 |
---|---|---|
@@ -1 +1,27 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod linux; | ||
|
||
use crate::linux::{Cmd, TdxError}; | ||
use kvm_bindings::*; | ||
use vmm_sys_util::*; | ||
|
||
vmm_sys_util::ioctl_iowr_nr!(KVM_MEMORY_ENCRYPT_OP, KVMIO, 0xba, std::os::raw::c_ulong); | ||
|
||
impl crate::vm::TdxVm { | ||
/// TDX specific VCPU initialization using a TDVF HOB address | ||
pub fn init_vcpu(vcpu: &kvm_ioctls::VcpuFd, hob_addr: u64) -> Result<(), TdxError> { | ||
let mut cmd = Cmd { | ||
id: 2, | ||
flags: 0, | ||
data: hob_addr as *const u64 as _, | ||
error: 0, | ||
_unused: 0, | ||
}; | ||
let ret = unsafe { ioctl::ioctl_with_mut_ptr(vcpu, KVM_MEMORY_ENCRYPT_OP(), &mut cmd) }; | ||
if ret < 0 { | ||
return Err(TdxError::from(ret)); | ||
} | ||
Ok(()) | ||
} | ||
} |