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

Merged
merged 81 commits into from
Feb 12, 2025
Merged

Porting VMMAP to RawPOSIX #56

merged 81 commits into from
Feb 12, 2025

Conversation

ChinmayShringi
Copy link
Contributor

@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?

@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
rennergade
rennergade previously approved these changes Feb 11, 2025
@rennergade
Copy link
Contributor

@Yaxuan-w and @JustinCappos I just changed this to approved on my end. I think its good to go. I'll need you both to change to approved to merge this so if you could take another look that would be great.

JustinCappos
JustinCappos previously approved these changes Feb 11, 2025
Copy link
Member

@JustinCappos JustinCappos left a comment

Choose a reason for hiding this comment

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

In the future, let's break these down into separate PRs and make it easier to review. A lot of this isn't strictly VMMAP related.

Yaxuan-w
Yaxuan-w previously approved these changes Feb 11, 2025
yzhang71
yzhang71 previously approved these changes Feb 11, 2025
@Yaxuan-w
Copy link
Member

I met error when running with latest vmmap-alice branch:

lind@d9a905abb17d:~/lind-wasm$ ./lindtool.sh run tests/unit-tests/process_tests/deterministic/hello
/home/lind/lind-wasm/src/wasmtime/target/debug/wasmtime run --allow-precompiled --wasi threads=y --wasi preview2=n tests/unit-tests/process_tests/deterministic/hello.cwasm 
warkError: failed to run main module `tests/unit-tests/process_tests/deterministic/hello.cwasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x38da6 - <unknown>!sysmalloc
           1: 0x36449 - <unknown>!_int_malloc
           2: 0x32d91 - <unknown>!tcache_init
           3: 0x321a4 - <unknown>!__libc_malloc
           4: 0x7ad41 - <unknown>!_IO_file_doallocate
           5: 0x7710e - <unknown>!_IO_doallocbuf
           6: 0x88936 - <unknown>!_IO_new_file_overflow
           7: 0x754fd - <unknown>!__overflow
           8: 0x729bc - <unknown>!_IO_puts
           9: 0x14d9 - <unknown>!__original_main
          10: 0x1361 - <unknown>!_start
          11: 0x114174 - <unknown>!_start.command_export
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: memory fault at wasm address 0xde3f00c in linear memory of size 0x30000
    3: wasm trap: out of bounds memory access

m-hemmings
m-hemmings previously approved these changes Feb 12, 2025
Copy link

@m-hemmings m-hemmings left a comment

Choose a reason for hiding this comment

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

PR appears well documented and code is clear. I see no changes to request.

@qianxichen233
Copy link
Contributor

I met error when running with latest vmmap-alice branch:

lind@d9a905abb17d:~/lind-wasm$ ./lindtool.sh run tests/unit-tests/process_tests/deterministic/hello
/home/lind/lind-wasm/src/wasmtime/target/debug/wasmtime run --allow-precompiled --wasi threads=y --wasi preview2=n tests/unit-tests/process_tests/deterministic/hello.cwasm 
warkError: failed to run main module `tests/unit-tests/process_tests/deterministic/hello.cwasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x38da6 - <unknown>!sysmalloc
           1: 0x36449 - <unknown>!_int_malloc
           2: 0x32d91 - <unknown>!tcache_init
           3: 0x321a4 - <unknown>!__libc_malloc
           4: 0x7ad41 - <unknown>!_IO_file_doallocate
           5: 0x7710e - <unknown>!_IO_doallocbuf
           6: 0x88936 - <unknown>!_IO_new_file_overflow
           7: 0x754fd - <unknown>!__overflow
           8: 0x729bc - <unknown>!_IO_puts
           9: 0x14d9 - <unknown>!__original_main
          10: 0x1361 - <unknown>!_start
          11: 0x114174 - <unknown>!_start.command_export
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: memory fault at wasm address 0xde3f00c in linear memory of size 0x30000
    3: wasm trap: out of bounds memory access

I believe current vmmap-alice branch cannot compile because there is a misresolved merge conflict with main branch previously, the getifaddrs is perserved in dispatcher.rs while it should already be removed in main branch. I guess you encountered this error probably because you didn't notice the build was failed and used the wrong build version to run the test. I just deleted the getifaddrs and I think the test should run successfully

@rennergade
Copy link
Contributor

I met error when running with latest vmmap-alice branch:

lind@d9a905abb17d:~/lind-wasm$ ./lindtool.sh run tests/unit-tests/process_tests/deterministic/hello
/home/lind/lind-wasm/src/wasmtime/target/debug/wasmtime run --allow-precompiled --wasi threads=y --wasi preview2=n tests/unit-tests/process_tests/deterministic/hello.cwasm 
warkError: failed to run main module `tests/unit-tests/process_tests/deterministic/hello.cwasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x38da6 - <unknown>!sysmalloc
           1: 0x36449 - <unknown>!_int_malloc
           2: 0x32d91 - <unknown>!tcache_init
           3: 0x321a4 - <unknown>!__libc_malloc
           4: 0x7ad41 - <unknown>!_IO_file_doallocate
           5: 0x7710e - <unknown>!_IO_doallocbuf
           6: 0x88936 - <unknown>!_IO_new_file_overflow
           7: 0x754fd - <unknown>!__overflow
           8: 0x729bc - <unknown>!_IO_puts
           9: 0x14d9 - <unknown>!__original_main
          10: 0x1361 - <unknown>!_start
          11: 0x114174 - <unknown>!_start.command_export
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: memory fault at wasm address 0xde3f00c in linear memory of size 0x30000
    3: wasm trap: out of bounds memory access

I believe current vmmap-alice branch cannot compile because there is a misresolved merge conflict with main branch previously, the getifaddrs is perserved in dispatcher.rs while it should already be removed in main branch. I guess you encountered this error probably because you didn't notice the build was failed and used the wrong build version to run the test. I just deleted the getifaddrs and I think the test should run successfully

Yeah there seems like the build CI isn't working correctly. I mentioned this to @yashaswi2000

@Yaxuan-w
Copy link
Member

Yaxuan-w commented Feb 12, 2025

I believe current vmmap-alice branch cannot compile because there is a misresolved merge conflict with main branch previously, the getifaddrs is perserved in dispatcher.rs while it should already be removed in main branch. I guess you encountered this error probably because you didn't notice the build was failed and used the wrong build version to run the test. I just deleted the getifaddrs and I think the test should run successfully

There was no error message printed on my screen previously. I still met same error with updated vmmap-alice branch

Operations I did:

git pull
./lindtool.sh make_all
./lindtool.sh cptest tests/unit-tests/process_tests/deterministic/hello
./lindtool.sh run tests/unit-tests/process_tests/deterministic/hello

Error message:

lind@d9a905abb17d:~/lind-wasm$ ./lindtool.sh run tests/unit-tests/process_tests/deterministic/hello
/home/lind/lind-wasm/src/wasmtime/target/debug/wasmtime run --allow-precompiled --wasi threads=y --wasi preview2=n tests/unit-tests/process_tests/deterministic/hello.cwasm 
warkError: failed to run main module `tests/unit-tests/process_tests/deterministic/hello.cwasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x38da6 - <unknown>!sysmalloc
           1: 0x36449 - <unknown>!_int_malloc
           2: 0x32d91 - <unknown>!tcache_init
           3: 0x321a4 - <unknown>!__libc_malloc
           4: 0x7ad41 - <unknown>!_IO_file_doallocate
           5: 0x7710e - <unknown>!_IO_doallocbuf
           6: 0x88936 - <unknown>!_IO_new_file_overflow
           7: 0x754fd - <unknown>!__overflow
           8: 0x729bc - <unknown>!_IO_puts
           9: 0x14d9 - <unknown>!__original_main
          10: 0x1361 - <unknown>!_start
          11: 0x114174 - <unknown>!_start.command_export
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: memory fault at wasm address 0x1470000c in linear memory of size 0x30000
    3: wasm trap: out of bounds memory access

The latest change seems only remove function from dispatcher.rs, which shouldn't cause any compilation error even it was still there. I also noticed that wark has been printed out, so everything related to individual syscall handling part should be correct.

Is there any other operations I need to do?

@qianxichen233
Copy link
Contributor

qianxichen233 commented Feb 12, 2025

I believe current vmmap-alice branch cannot compile because there is a misresolved merge conflict with main branch previously, the getifaddrs is perserved in dispatcher.rs while it should already be removed in main branch. I guess you encountered this error probably because you didn't notice the build was failed and used the wrong build version to run the test. I just deleted the getifaddrs and I think the test should run successfully

There was no error message printed on my screen previously. I still met same error with updated vmmap-alice branch

Operations I did:

git pull
./lindtool.sh make_all
./lindtool.sh cptest tests/unit-tests/process_tests/deterministic/hello
./lindtool.sh run tests/unit-tests/process_tests/deterministic/hello

Error message:

lind@d9a905abb17d:~/lind-wasm$ ./lindtool.sh run tests/unit-tests/process_tests/deterministic/hello
/home/lind/lind-wasm/src/wasmtime/target/debug/wasmtime run --allow-precompiled --wasi threads=y --wasi preview2=n tests/unit-tests/process_tests/deterministic/hello.cwasm 
warkError: failed to run main module `tests/unit-tests/process_tests/deterministic/hello.cwasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x38da6 - <unknown>!sysmalloc
           1: 0x36449 - <unknown>!_int_malloc
           2: 0x32d91 - <unknown>!tcache_init
           3: 0x321a4 - <unknown>!__libc_malloc
           4: 0x7ad41 - <unknown>!_IO_file_doallocate
           5: 0x7710e - <unknown>!_IO_doallocbuf
           6: 0x88936 - <unknown>!_IO_new_file_overflow
           7: 0x754fd - <unknown>!__overflow
           8: 0x729bc - <unknown>!_IO_puts
           9: 0x14d9 - <unknown>!__original_main
          10: 0x1361 - <unknown>!_start
          11: 0x114174 - <unknown>!_start.command_export
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: memory fault at wasm address 0x1470000c in linear memory of size 0x30000
    3: wasm trap: out of bounds memory access

The latest change seems only remove function from dispatcher.rs, which shouldn't cause any compilation error even it was still there. I also noticed that wark has been printed out, so everything related to individual syscall handling part should be correct.

Is there any other operations I need to do?

Have you run lindtool cpwasm? make_all command actually only compiles glibc
And regarding the previous compilation error, getifaddrs is perserved in dispatcher.rs but it is removed in network_syscall, so the getifaddrs function call made by dispatcher.rs cannot find its syscall function

@Yaxuan-w
Copy link
Member

Have you run lindtool cpwasm? make_all command actually only compiles glibc

Works, thanks!

@rennergade rennergade merged commit 003a83d into main Feb 12, 2025
1 check passed
@Yaxuan-w Yaxuan-w mentioned this pull request Feb 13, 2025
9 tasks
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.

8 participants