Skip to content

Commit

Permalink
Upstream tdx-tdcall to crates.io
Browse files Browse the repository at this point in the history
Signed-off-by: Ouyang, Hang <[email protected]>
Signed-off-by: OuyangHang33 <[email protected]>
  • Loading branch information
OuyangHang33 committed Jun 17, 2024
1 parent 92f5989 commit 9398089
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions tdx-tdcall/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ homepage = "https://github.com/confidential-containers"
license = "BSD-2-Clause-Patent"
edition = "2018"

readme = "README.md"
keywords = ["TDCALL", "TDX", "intel"]

[dependencies]
lazy_static = { version = "1.0", features = ["spin_no_std"] }
log = "0.4.13"
Expand Down
16 changes: 16 additions & 0 deletions tdx-tdcall/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim?ref=badge_shield)
# TDX-tdcall - Trust Domain Extensions tdcall

## Documents

* [Intel TDX](https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html)

## Introduction

Intel’s Trust Domain Extensions (TDX) protect confidential guest VMs from the host and physical attacks by isolating the guest register state and by encrypting the guest memory. In TDX, a special module running in a special mode sits between the host and the guest and manages the guest/host separation.

This tdx-tdcall crate provides constants, stuctures and wrappers to support user access TDCALL services.


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim?ref=badge_large)
8 changes: 4 additions & 4 deletions tdx-tdcall/src/tdx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub fn tdvmcall_io_write_32(port: u16, byte: u32) {
pub fn tdvmcall_mmio_write<T: Sized>(address: *const T, value: T) {
let address = address as u64 | *SHARED_MASK;
fence(Ordering::SeqCst);
let val = unsafe { *(&value as *const T as *const u64) };
let val = unsafe { *(core::ptr::addr_of!(value) as *const u64) };

let mut args = TdVmcallArgs {
r11: TDVMCALL_MMIO,
Expand Down Expand Up @@ -273,7 +273,7 @@ pub fn tdvmcall_mmio_read<T: Clone + Copy + Sized>(address: usize) -> T {
tdvmcall_halt();
}

unsafe { *(&args.r11 as *const u64 as *const T) }
unsafe { *(core::ptr::addr_of!(args.r11) as *const T) }
}

/// Used to request the host VMM to map a GPA range as a private or shared memory mappings.
Expand Down Expand Up @@ -514,8 +514,8 @@ pub fn tdcall_get_td_info() -> Result<TdInfo, TdCallError> {
///
/// Details can be found in TDX Module ABI spec section 'TDG.VP.INFO Leaf'
pub fn tdcall_extend_rtmr(digest: &TdxDigest, mr_index: u32) -> Result<(), TdCallError> {
let buffer: u64 = &digest.data as *const u8 as u64;

let buffer: u64 = core::ptr::addr_of!(digest.data) as u64;
let mut args = TdcallArgs {
rax: TDCALL_TDEXTENDRTMR,
rcx: buffer,
Expand Down

0 comments on commit 9398089

Please sign in to comment.