Skip to content

LVBS: Revise VTL switch loop and add run_thread support#541

Merged
sangho2 merged 10 commits intomainfrom
sanghle/lvbs/ktls
Jan 27, 2026
Merged

LVBS: Revise VTL switch loop and add run_thread support#541
sangho2 merged 10 commits intomainfrom
sanghle/lvbs/ktls

Conversation

@sangho2
Copy link
Contributor

@sangho2 sangho2 commented Dec 6, 2025

This PR revises VTL switch loop including VTL0 state saving/restoring, and
adds run_thread support.

This PR uses assembly code to carefully switch between VTLs while
saving/restoring VTL0 general-purpose registers and extended states.

Also, it adds run_thread support for the LVBS platform and revises the syscall
handling routine based on that of the Linux userland platform.

@sangho2 sangho2 marked this pull request as ready for review December 6, 2025 00:09
@wdcui wdcui requested a review from jstarks December 6, 2025 00:52
@sangho2 sangho2 changed the title LVBS: Kernel TLS for assembly code LVBS: Revise VTL switch loop and add run_thread support Jan 22, 2026
sangho2 added a commit that referenced this pull request Jan 22, 2026
This PR fixes some bugs in the VTL switching loop and improve its
reliability and performance.
Specifically, this PR uses assembly code to carefully switch between
VTLs while saving/restoring
VTL0 registers. This PR removes some unreliable stack manipulation code
we had before.
In addition, this PR makes it clear that we no longer store the VTL1
state in per-core storage.

Note: this PR and #541 should be merged together since #541 suffers from
a crash due to
some bugs that this PR is fixing.

---------

Co-authored-by: Sangho Lee <sanghle@microsoft.com>
@sangho2 sangho2 added the must-not-merge:undergoing-restructuring Known deeper set of changes are happening on this PR before it is mergeable again label Jan 22, 2026
@sangho2 sangho2 removed the must-not-merge:undergoing-restructuring Known deeper set of changes are happening on this PR before it is mergeable again label Jan 23, 2026
@sangho2 sangho2 requested a review from wdcui January 23, 2026 18:19
Sangho Lee added 8 commits January 24, 2026 02:14
This PR adds `run_thread` support for LVBS platform and revise its
syscall handling routine based on
Linux userland platform's syscall handling. It has suppressed new page
table creation for now
because it needs to be done by the runner via an upcall (userspace
support still exists, but doesn't
create a separate one for each TA instance for now).

---------

Co-authored-by: Sangho Lee <sanghle@microsoft.com>
Copy link
Contributor Author

@sangho2 sangho2 left a comment

Choose a reason for hiding this comment

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

.

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.

Overall, the code looks good to me. I left some comments below.

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 making efforts to improve this PR!

@github-actions
Copy link

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

Click for details
--- 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:
  PerCpuVariables::kernel_stack_top, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/9734d6c8b5dbe5cc67645953a2d69b856ea9665c/litebox_platform_lvbs/src/host/per_cpu_variables.rs:55

--- 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_platform_lvbs::syscall_entry::SyscallContextRaw, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/9734d6c8b5dbe5cc67645953a2d69b856ea9665c/litebox_platform_lvbs/src/syscall_entry.rs:54

--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---

Description:
A publicly-visible struct has at least one public field 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/struct_pub_field_missing.ron

Failed in:
  field vtl1_state of struct PerCpuVariables, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/9734d6c8b5dbe5cc67645953a2d69b856ea9665c/litebox_platform_lvbs/src/host/per_cpu_variables.rs:38
  field cr2 of struct VtlState, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/9734d6c8b5dbe5cc67645953a2d69b856ea9665c/litebox_platform_lvbs/src/mshv/vtl_switch.rs:46

--- warning repr_c_plain_struct_fields_reordered: struct fields reordered in repr(C) struct ---

Description:
A public repr(C) struct had its fields reordered. This can change the struct's memory layout, possibly breaking FFI use cases that depend on field position and order.
        ref: https://doc.rust-lang.org/reference/type-layout.html#reprc-structs
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/repr_c_plain_struct_fields_reordered.ron

Failed in:
  VtlState.rax moved from position 3 to 2, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:52
  VtlState.rbx moved from position 4 to 3, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:53
  VtlState.rcx moved from position 5 to 4, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:54
  VtlState.rdx moved from position 6 to 5, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:55
  VtlState.rsi moved from position 7 to 6, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:56
  VtlState.rdi moved from position 8 to 7, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:57
  VtlState.r8 moved from position 9 to 8, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:58
  VtlState.r9 moved from position 10 to 9, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:59
  VtlState.r10 moved from position 11 to 10, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:60
  VtlState.r11 moved from position 12 to 11, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:61
  VtlState.r12 moved from position 13 to 12, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:62
  VtlState.r13 moved from position 14 to 13, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:63
  VtlState.r14 moved from position 15 to 14, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:64
  VtlState.r15 moved from position 16 to 15, in /home/runner/work/litebox/litebox/litebox_platform_lvbs/src/mshv/vtl_switch.rs:65

@sangho2 sangho2 added this pull request to the merge queue Jan 27, 2026
Merged via the queue into main with commit 69da9ec Jan 27, 2026
14 checks passed
@sangho2 sangho2 deleted the sanghle/lvbs/ktls branch January 27, 2026 06:19
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