Skip to content

Add OP-TEE GetSystemTime and revise LVBS platform Instant#987

Open
sangho2 wants to merge 1 commit into
mainfrom
sanghle/lvbs/time_and_instant
Open

Add OP-TEE GetSystemTime and revise LVBS platform Instant#987
sangho2 wants to merge 1 commit into
mainfrom
sanghle/lvbs/time_and_instant

Conversation

@sangho2

@sangho2 sangho2 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This PR adds OP-TEE GetSystemTime and revises the LVBS platform's Instant. The OP-TEE system time is per-instance monotonic time. Also, it now uses Hyper-V's partition reference-counter tick that is a monotonic, frequency-invariant counter.

@sangho2 sangho2 changed the title Add OP-TEE GetTime and revise LVBS platform Instant Add OP-TEE GetSystemTime and revise LVBS platform Instant Jun 30, 2026
@sangho2 sangho2 changed the title Add OP-TEE GetSystemTime and revise LVBS platform Instant Add OP-TEE GetSystemTime and revise LVBS platform Instant Jun 30, 2026
@sangho2 sangho2 marked this pull request as ready for review June 30, 2026 18:20
@github-actions

Copy link
Copy Markdown

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---

Description:
The enum's variant had its discriminant value change. This breaks downstream code that used its value via a numeric cast like `as isize`.
        ref: https://doc.rust-lang.org/reference/items/enumerations.html#assigning-discriminant-values
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/enum_no_repr_variant_discriminant_changed.ron

Failed in:
  variant SyscallRequest::CrypStateAlloc 9 -> 10 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:95
  variant SyscallRequest::CrypStateFree 10 -> 11 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:102
  variant SyscallRequest::CipherInit 11 -> 12 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:105
  variant SyscallRequest::CipherUpdate 12 -> 13 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:110
  variant SyscallRequest::CipherFinal 13 -> 14 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:117
  variant SyscallRequest::CrypObjGetInfo 14 -> 15 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:124
  variant SyscallRequest::CrypObjAlloc 15 -> 16 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:128
  variant SyscallRequest::CrypObjClose 16 -> 17 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:133
  variant SyscallRequest::CrypObjReset 17 -> 18 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:136
  variant SyscallRequest::CrypObjPopulate 18 -> 19 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:139
  variant SyscallRequest::CrypObjCopy 19 -> 20 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:144
  variant SyscallRequest::CrypRandomNumberGenerate 20 -> 21 in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:148

--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/inherent_method_missing.ron

Failed in:
  LinuxKernel::init, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/af4fa22f366509f1d01d59788151ff6126b67fac/litebox_platform_lvbs/src/lib.rs:618

}
}
// Persistent time was never set by this TA; report it per the spec.
TeeTimeCategory::TaPersistent => return Err(TeeResult::TimeNotSet),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What syscall is for a TA to set its persistent time?

@sangho2 sangho2 Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is set_ta_time that our OP-TEE shim doesn't support. Basically, this function stores an offset value in persistent storage. TeeTimeCategory::TaPersistent is expected to use this stored value.

Err(err) => {
// TODO: this seems like the wrong kind of error for OPTEE.
ctx.rax = (err.as_neg() as isize).reinterpret_as_unsigned();
ctx.rax = TeeResult::from(err) as usize;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix in this line is not specific to this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True. we can separate this if necessary.

@wdcui wdcui left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I left some comments for your reference. Thanks.

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.

2 participants