Skip to content

Platform for Kernel#10

Merged
CvvT merged 13 commits intomainfrom
linux_kernel
Feb 18, 2025
Merged

Platform for Kernel#10
CvvT merged 13 commits intomainfrom
linux_kernel

Conversation

@CvvT
Copy link
Copy Markdown
Contributor

@CvvT CvvT commented Feb 12, 2025

Per our discussion, LinuxKernel is the provider/platform which depends on HostInterface (host specific interface) and Task (for per task storage).

@CvvT CvvT requested a review from wdcui February 12, 2025 19:59
@CvvT
Copy link
Copy Markdown
Contributor Author

CvvT commented Feb 12, 2025

As we discussed #9, removed blocking punchthrough futex (which will be reimplemented in Litebox)

Copy link
Copy Markdown
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 focused on the high-level interfaces and structures in this round of review.

Comment thread Cargo.toml Outdated
Comment thread litebox_platform_linux_kernel/snp-sandbox.h
uint64_t ret;
} __attribute__((__packed__));

#define SNP_SANDBOX_IOCTL_DEBUG 0x6300 // _IO('c', 0)
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.

TODO: maybe split this header file to two parts and only copy the part related to litebox here? For instance, litebox platform doesn't need to know the driver's IOCTL code.

Comment thread litebox_platform_linux_kernel/src/error.rs
Comment thread litebox_platform_linux_kernel/src/host/mod.rs
Comment thread litebox_platform_linux_kernel/src/lib.rs
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Copy link
Copy Markdown
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.

Added a bunch of comments.

Comment thread litebox_platform_linux_kernel/src/lib.rs
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Comment thread litebox_platform_linux_kernel/src/host/snp/snp_impl.rs Outdated
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Comment thread litebox_platform_linux_kernel/snp-sandbox.h
Comment thread litebox_platform_linux_kernel/snp-sandbox.h
Comment thread litebox_platform_linux_kernel/src/lib.rs Outdated
Copy link
Copy Markdown
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.

Modulo the two remaining comments that I have (one regarding a comment that needs to be updated, and the other regarding cpu-mhz), I think this is reasonable enough to merge; we can postpone other improvements (e.g., linux-common etc) to future PRs.

@CvvT
Copy link
Copy Markdown
Contributor Author

CvvT commented Feb 14, 2025

Removed Task trait from this PR. My initial thought was that we need it to help convert a kernel pointer to a pointer accessible to the host. However, I can also change the sandbox driver to do it.

Comment thread litebox_platform_linux_kernel/Cargo.toml Outdated
@CvvT
Copy link
Copy Markdown
Contributor Author

CvvT commented Feb 15, 2025

Rebase on the main branch and add implementation for RawPointerProvider (See https://github.com/MSRSSP/litebox/blob/8ad1533d8031851fa42f5438701c0c458dea3d6c/litebox_platform_linux_kernel/src/ptr.rs). To avoid complicate this PR, left todos in the function body.

Another change I did due to RawPointerProvider is the following:

     fn rt_sigprocmask(
         how: i32,
-        set: Option<*const crate::host::linux::sigset_t>,
-        oldset: Option<*mut crate::host::linux::sigset_t>,
+        set: UserConstPtr<sigset_t>,
+        oldset: UserMutPtr<sigset_t>,
         sigsetsize: usize,
     ) -> Result<usize, error::Errno> {

Also, instead of passing user space pointer to host, I believe it is preferable to do some extra copy and pass kernel memory instead. See more comments here: https://github.com/MSRSSP/litebox/blob/8ad1533d8031851fa42f5438701c0c458dea3d6c/litebox_platform_linux_kernel/src/host/snp/snp_impl.rs#L185-L195

@CvvT CvvT merged commit ff05350 into main Feb 18, 2025
@CvvT CvvT deleted the linux_kernel branch February 18, 2025 21:25
jaybosamiya-ms pushed a commit that referenced this pull request Feb 18, 2025
Implement a platform running in kernel mode that supports different hosts

* implement kernel platform LinuxKernel
* define platform-host interface HostInterface
* implement HostInterface for snp
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.

3 participants