Skip to content

Conversation

@sangho2
Copy link
Contributor

@sangho2 sangho2 commented Dec 12, 2025

This PR adds OP-TEE message protocol and SMC handlers (a handler for TA request is
covered in another PR).

Also, this PR adds traits for physical memory access to (copy from/to) the memory of
a remote environment (e.g., VTL0, normal world, ...), PhysMutPtr and PhysConstPtr.
These traits expect platforms will implement Linux kernel's vmap-like functions to
enable virtually contiguous mapping of non-contiguous physical pages on demand.

@sangho2 sangho2 changed the title Add OP-TEE message protocol and SMC handlers Add handlers for OP-TEE message protocol and SMC Dec 12, 2025
@sangho2 sangho2 force-pushed the sanghle/lvbs/optee_msg_handler_1 branch 2 times, most recently from 2902dd9 to 102cfa9 Compare December 12, 2025 22:59
@sangho2 sangho2 marked this pull request as ready for review December 12, 2025 23:06
Copy link
Member

@wdcui wdcui left a comment

Choose a reason for hiding this comment

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

Thank you for adding the support for OP-TEE step-by-step. I left some comments below. I suggest @jaybosamiya-ms to take a look at ptr.rs.

@sangho2 sangho2 force-pushed the sanghle/lvbs/optee_msg_handler_1 branch 2 times, most recently from f2691a8 to 16850b8 Compare December 14, 2025 15:37
Copy link
Member

@jaybosamiya-ms jaybosamiya-ms left a comment

Choose a reason for hiding this comment

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

I've only looked at litebox_shim_optee/src/ptr.rs, a few comments from my pass over it:

@sangho2 sangho2 force-pushed the sanghle/lvbs/optee_msg_handler_1 branch 4 times, most recently from 58476ce to 27152aa Compare December 24, 2025 00:12
Copy link
Member

@jaybosamiya-ms jaybosamiya-ms left a comment

Choose a reason for hiding this comment

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

The new ptr.rs‎ is a significant rewrite over the prior version. I have a few minor comments/clarifications, but no major concerns with it as it currently stands (the more major changes are things that #505 already has in mind, so I'll just make a quick comment there to re-look at this PR when cleaning things up with that).

Minor readability note: it appears all the methods in this are right up against each other with no blank lines separating them; usually an additional newline between functions (before the doc string for the function) helps with readability. Not major and not a blocker. Funnily, rustfmt has an (unstable) pair of options blank_lines_*_bound that are the closest to what would guarantee this but they are hilariously broken and would be a bad idea for us to enable lol

@sangho2 sangho2 force-pushed the sanghle/lvbs/optee_msg_handler_1 branch 2 times, most recently from aa93994 to b4ab389 Compare December 26, 2025 19:23
@sangho2
Copy link
Contributor Author

sangho2 commented Jan 7, 2026

If we merge #572 first, we can get rid of PhysConstPtr and PhysMutPtr's usage of litebox_platform_multiplex::platform().

Copy link
Member

@wdcui wdcui left a comment

Choose a reason for hiding this comment

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

I left some comments below.

@sangho2 sangho2 requested a review from CvvT January 20, 2026 22:04
Copy link
Member

@jaybosamiya-ms jaybosamiya-ms left a comment

Choose a reason for hiding this comment

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

I've focused my review on the VMapProvider. Comments inline, but I'll just bubble the high-level comment to the top here too: if it helps unblock this PR, please feel free to move VmapProvider into litebox_common_optee. Since the current usage of it is only to provide litebox_shim_optee::ptr::Phys*Ptr, there is no reason to block this otherwise fairly-large PR on making sure the design is general enough to sit inside the main litebox crate.

@sangho2 sangho2 force-pushed the sanghle/lvbs/optee_msg_handler_1 branch from 20a424a to 42500bb Compare January 23, 2026 00:36
@sangho2 sangho2 force-pushed the sanghle/lvbs/optee_msg_handler_1 branch from 4cecf50 to 4d0df5e Compare January 24, 2026 00:29
@github-actions
Copy link

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

Click for details
--- failure copy_impl_added: type now implements Copy ---

Description:
A public type now implements Copy, causing non-move closures to capture it by reference instead of moving it.
        ref: https://github.com/rust-lang/rust/issues/100905
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/copy_impl_added.ron

Failed in:
  litebox::mm::linux::NonZeroAddress in /home/runner/work/litebox/litebox/litebox/src/mm/linux.rs:220

--- failure derive_trait_impl_removed: built-in derived trait no longer implemented ---

Description:
A public type has stopped deriving one or more traits. This can break downstream code that depends on those types implementing those traits.
        ref: https://doc.rust-lang.org/reference/attributes/derive.html#derive
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/derive_trait_impl_removed.ron

Failed in:
  type OpteeSmcResult no longer derives Clone, in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:1479
  type OpteeSmcResult no longer derives Copy, in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:1479

--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself 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.46.0/src/lints/enum_missing.ron

Failed in:
  enum litebox_common_optee::OpteeSmcReturn, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1428

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that 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.46.0/src/lints/enum_variant_missing.ron

Failed in:
  variant OpteeMessageCommand::Unknown, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1117

--- 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.46.0/src/lints/inherent_method_missing.ron

Failed in:
  OpteeSmcResult::return_status, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1352
  OpteeSmcResult::exchange_capabilities, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1356
  OpteeSmcResult::uuid, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1371
  OpteeSmcResult::revision, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1379
  OpteeSmcResult::os_revision, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1384
  OpteeSmcResult::disable_shm_cache, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1390
  OpteeSmcArgs::arg_index, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1283

--- failure repr_align_removed: repr(align) removed ---

Description:
A type no longer declares a minimum alignment via repr(align). This can break code that depends on the type's alignment or layout.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#repr-align-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/repr_align_removed.ron

Failed in:
  struct OpteeSmcArgs in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:1417

--- failure repr_c_removed: repr(C) removed ---

Description:
repr(C) was removed from a type. This can cause its memory layout to change, breaking FFI use cases.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#repr-c-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/repr_c_removed.ron

Failed in:
  struct OpteeSmcArgs in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:1417

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself 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.46.0/src/lints/struct_missing.ron

Failed in:
  struct litebox_common_optee::OpteeMsgArg, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/31065d59d9c2ff9c83695490e11d51971e0ead9e/litebox_common_optee/src/lib.rs:1240

--- failure struct_with_no_pub_fields_changed_type: public API struct with no public fields is no longer a struct ---

Description:
A struct without pub fields became an enum or union, breaking pattern matching.
        ref: https://internals.rust-lang.org/t/rest-patterns-foo-should-match-non-struct-types/21607
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/struct_with_no_pub_fields_changed_type.ron

Failed in:
  struct litebox_common_optee::OpteeSmcResult became enum in file /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:1479

@sangho2 sangho2 added this pull request to the merge queue Jan 24, 2026
Merged via the queue into main with commit 15dc300 Jan 24, 2026
14 checks passed
@sangho2 sangho2 deleted the sanghle/lvbs/optee_msg_handler_1 branch January 24, 2026 00:53
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.

5 participants