Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting VMMAP to RawPOSIX #56

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open

Porting VMMAP to RawPOSIX #56

wants to merge 58 commits into from

Conversation

ChinmayShringi
Copy link

@ChinmayShringi ChinmayShringi commented Nov 25, 2024

Please note this is taken from RawPosix: (Lind-Project/RawPOSIX#87)

Description

Issue # 45

Type of change

Porting pranav-bhatt and ruchjoshi-nyu implementation of VMMAP to RawPOSIX. Request review for porting location and if more comments are needed.

I also added few comments to make things more clear. That would be great if ruchjoshi-nyu could review their correctness.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been added to a pull request and/or merged in other modules (native-client, lind-glibc, lind-project)

Copy link
Member

@Yaxuan-w Yaxuan-w left a comment

Choose a reason for hiding this comment

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

Awesome! Minor changes requested.

Would it make more sense to move LIND_ROOT in fs_calls.rs and net_calls.rs to corresponding constant files as well?

src/RawPOSIX/src/safeposix/mod.rs Outdated Show resolved Hide resolved
src/RawPOSIX/src/safeposix/syscalls/fs_calls.rs Outdated Show resolved Hide resolved
src/RawPOSIX/src/tests/sys_tests.rs Outdated Show resolved Hide resolved
@Yaxuan-w Yaxuan-w changed the title Porting VMMAP to RawPOSIX [REVIEW for comments] Porting VMMAP to RawPOSIX Nov 26, 2024
@rennergade
Copy link
Contributor

@ChinmayShringi add address checking and conversion:

  1. create function in mem.rs called check_and_convert_addr(user_addr: u64)
    That function calls check_addr_mapping() in vmmap.rs and checks if address is valid, if not return Error type of result
    If valid return Result(vmmap.base_addr + user_addr)
  2. in dispatcher, if returns error, return EFAULT error
  3. if succesful, unwrap Result and send that value to syscall like usual

@rennergade rennergade closed this Dec 4, 2024
@rennergade
Copy link
Contributor

rennergade commented Dec 4, 2024

@ChinmayShringi additional tasks

  • read through all of this, add additional comments on understanding
  • add additional tests as needed

@rennergade rennergade reopened this Dec 4, 2024
…ent-squash

Enhance RawPOSIX Dispatcher with Memory Validation and Improved Syscall Handling in Nacl
@Yaxuan-w
Copy link
Member

Yaxuan-w commented Jan 6, 2025

I met this error while compiling the newest vmmap:

error[E0308]: `match` arms have incompatible types
    --> src/safeposix/dispatcher.rs:312:13
     |
204  |       let ret = match call_number {
     |  _______________-
205  | |         WRITE_SYSCALL => {
206  | |             // Handles writing data from user buffer to file descriptor
...    |
233  | |             cage.write_syscall(fd, buf, count)
     | |             ---------------------------------- this is found to be of type `i32`
...    |
269  | |             cage.writev_syscall(fd, iov_base, iovcnt)
     | |             ----------------------------------------- this is found to be of type `i32`
...    |
286  | |             interface::munmap_handler(cageid, addr, length)
     | |             ----------------------------------------------- this is found to be of type `i32`
...    |
312  | |             interface::mmap_handler(cageid, addr, len, prot, flags, fd, off)
     | |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
...    |
1624 | |         _ => -1, // Return -1 for unknown syscalls
1625 | |     };
     | |_____- `match` arms have incompatible types
     |
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit

src/safeposix/shm.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@rennergade rennergade 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 few notes.

Also Im not sure but think the vmmap branch needs to be updated against main because I think there's stuff showing up thats already been merged?

@rennergade
Copy link
Contributor

I think this is ready to merge once the tests are straightened out.

@ChinmayShringi
Copy link
Author

The test cases are fixed and it builds and runs, test cases do fail but now they run without errors.

@qianxichen233
Copy link
Contributor

The test cases are fixed and it builds and runs, test cases do fail but now they run without errors.

Which test cases are you refering to? RawPOSIX testsuite or lind-wasm unit test?

@ChinmayShringi
Copy link
Author

The test cases are fixed and it builds and runs, test cases do fail but now they run without errors.

Which test cases are you refering to? RawPOSIX testsuite or lind-wasm unit test?

Rawposix test suite

@qianxichen233
Copy link
Contributor

The test cases are fixed and it builds and runs, test cases do fail but now they run without errors.

Which test cases are you refering to? RawPOSIX testsuite or lind-wasm unit test?

Rawposix test suite

Can you also test the lind-wasm test cases? Especially those mmap tests. They are under lind-wasm/tests/unit-test/memory-test/

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.

6 participants