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

Added code to get the tsc time on HW-isolated VMs (TDX) - Issue 345. #346

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ckotamra
Copy link

In the current implementation, boot times are reported in the device tree only for non-hw-isolated vms by calling tsc refcount.

On TDX-based VMs, tsc ref time is calculated by:

  1. Reading tsc
  2. Getting the tsc frequency using TDCALL to read HV_X64_MSR_TSC_FREQUENCY

@ckotamra ckotamra requested a review from a team as a code owner November 15, 2024 23:05
@ckotamra ckotamra changed the title Added code to get the tsc time on HW-isolated VMs (TDX). (#345) Added code to get the tsc time on HW-isolated VMs (TDX) - Issue 345. Nov 15, 2024
openhcl/openhcl_boot/src/main.rs Outdated Show resolved Hide resolved
@@ -508,6 +511,18 @@ const fn zeroed<T: FromZeroes>() -> T {
unsafe { core::mem::MaybeUninit::<T>::zeroed().assume_init() }
}

/// Get the tsc ref time for hw isolated vms in 100ns
#[allow(unused_variables)]
fn get_hw_tsc_time(isolation: IsolationType) -> u64 {
Copy link
Member

Choose a reason for hiding this comment

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

@smalis-msft do you know what it would take to do the same on SNP?

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a better question for @sluck-msft? I haven't dug into the SNP docs nearly deep enough to know off the top of my head

Copy link
Contributor

Choose a reason for hiding this comment

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

openhcl/openhcl_boot/src/main.rs Outdated Show resolved Hide resolved
openhcl/openhcl_boot/src/main.rs Outdated Show resolved Hide resolved
openhcl/openhcl_boot/src/arch/x86_64/tdx.rs Outdated Show resolved Hide resolved
openhcl/openhcl_boot/src/arch/x86_64/tdx.rs Outdated Show resolved Hide resolved
@ckotamra ckotamra requested a review from a team as a code owner November 18, 2024 22:56
openhcl/minimal_rt/src/isolation.rs Outdated Show resolved Hide resolved
openhcl/minimal_rt/src/arch/x86_64/reftime.rs Outdated Show resolved Hide resolved
openhcl/minimal_rt/src/arch/x86_64/reftime.rs Outdated Show resolved Hide resolved
openhcl/minimal_rt/src/single_threaded.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants