Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use addr_of! macro instead of & #711

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tdx-tdcall/src/tdx.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Hank! Can addr_of! be used here as well? Otherwise LGTM.
let buffer: u64 = &digest.data as *const u8 as u64;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it also need to change. I will update it

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,7 +514,7 @@ 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,
Expand Down
Loading