Skip to content

Demand paging and fallible memory copy for LVBS#654

Merged
sangho2 merged 11 commits intomainfrom
sanghle/lvbs/page_fault_fix
Feb 12, 2026
Merged

Demand paging and fallible memory copy for LVBS#654
sangho2 merged 11 commits intomainfrom
sanghle/lvbs/page_fault_fix

Conversation

@sangho2
Copy link
Contributor

@sangho2 sangho2 commented Feb 9, 2026

Adds demand paging support for user-space addresses on the LVBS platform, handling user-space page faults from both user-mode and kernel-mode contexts (e.g., syscall handler copying not-yet mapped or invalid user pages using memcpy_fallible). This PR resolves #637.

Changes

  • ISR stubs check CS RPL to route user- and kernel-mode exceptions to the shim with different CPU context savings; kernel-mode page faults at user-space addresses trigger demand paging or address fixup
  • VTL0 memory copies replaced with memcpy_fallible + RAII Vtl0MappedGuard; copy_from_vtl0_phys uses zerocopy::FromBytes for memory safety
  • Per-CPU separate stacks for double-fault (TSS.IST1) and use-mode exception (TSS.RSP0)
  • Shim interface extended with kernel_mode field on ExceptionInfo and ResumeKernelPlatform/ExceptionFixup variants on ContinueOperation

@sangho2 sangho2 marked this pull request as ready for review February 9, 2026 22:21
@sangho2 sangho2 force-pushed the sanghle/lvbs/page_fault_fix branch 2 times, most recently from d31c159 to e07d604 Compare February 10, 2026 02:20
@sangho2 sangho2 force-pushed the sanghle/lvbs/page_fault_fix branch from e07d604 to 4eecc49 Compare February 10, 2026 02:27
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.

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.

LGTM. Thank you!

@sangho2 sangho2 force-pushed the sanghle/lvbs/page_fault_fix branch from 7067977 to 10fb2ee Compare February 12, 2026 02:27
@sangho2 sangho2 force-pushed the sanghle/lvbs/page_fault_fix branch from 10fb2ee to a17e6d4 Compare February 12, 2026 02:55
@github-actions
Copy link

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

Click for details
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field ExceptionInfo.kernel_mode in /home/runner/work/litebox/litebox/litebox/src/shim.rs:129

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_variant_added.ron

Failed in:
  variant ContinueOperation:ResumeKernelPlatform in /home/runner/work/litebox/litebox/litebox/src/shim.rs:108
  variant ContinueOperation:ExceptionFixup in /home/runner/work/litebox/litebox/litebox/src/shim.rs:113

--- 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:
  PerCpuVariablesAsm::set_interrupt_stack_ptr, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/069b405897dc01ef4702843c27669c77ce2e443e/litebox_platform_lvbs/src/host/per_cpu_variables.rs:240
  PerCpuVariablesAsm::get_interrupt_stack_ptr, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/069b405897dc01ef4702843c27669c77ce2e443e/litebox_platform_lvbs/src/host/per_cpu_variables.rs:243
  PerCpuVariablesAsm::interrupt_stack_ptr_offset, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/069b405897dc01ef4702843c27669c77ce2e443e/litebox_platform_lvbs/src/host/per_cpu_variables.rs:274

--- failure pub_module_level_const_missing: pub module-level const is missing ---

Description:
A public const is missing or renamed
        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/pub_module_level_const_missing.ron

Failed in:
  INTERRUPT_STACK_SIZE in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/069b405897dc01ef4702843c27669c77ce2e443e/litebox_platform_lvbs/src/host/per_cpu_variables.rs:24

--- failure function_missing: pub fn removed or renamed ---

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

Failed in:
  function litebox_shim_optee::recycle_session_id, previously in file /home/runner/work/litebox/litebox/target/semver-checks/git-main/069b405897dc01ef4702843c27669c77ce2e443e/litebox_shim_optee/src/session.rs:273

@sangho2 sangho2 added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit d016d3d Feb 12, 2026
14 checks passed
@sangho2 sangho2 deleted the sanghle/lvbs/page_fault_fix branch February 12, 2026 03:29
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.

Page fault handler for the LVBS platform

2 participants