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

Add Vmmap to src/rawposix #46

Open
rennergade opened this issue Sep 30, 2024 · 5 comments
Open

Add Vmmap to src/rawposix #46

rennergade opened this issue Sep 30, 2024 · 5 comments
Assignees

Comments

@rennergade
Copy link
Contributor

This is where were going to add the vmmap for now so once the tests are up you two can PR to here.

@Yaxuan-w
Copy link
Member

That would be great if @pranav-bhatt @ruchjoshi-nyu can post current VMMAP progress (including difficulties) and implementation details here

@Yaxuan-w
Copy link
Member

Yaxuan-w commented Nov 6, 2024

Task tracker for implementing VMMAP in RawPOSIX

Add current code into RawPOSIX

  • Add current VMMAP implementation into RawPOSIX (each cage structure has vmmap) - @Yaxuan-w
  • Add comments - @ruchjoshi-nyu

Integration

Address picked by host calling vmmap, then use this addr to call kernel mmap, a function before mmap in dispatcher to check and pick addr for vmmap

All translation about address should be done in dispatcher stage. Including all functions related to pointers
— handle situations depends on flags

Test

  • Add tests for vmmap

@ChinmayShringi
Copy link
Contributor

ChinmayShringi commented Nov 7, 2024

Below is the syscall list that uses pointer and doesn't use.

// Uses pointers
getcwd_syscall       // getcwd_syscall(&self, buf: *mut u8, bufsize: u32) -> i32
read_syscall         // read_syscall(&self, virtual_fd: i32, readbuf: *mut u8, count: usize) -> i32
write_syscall        // write_syscall(&self, virtual_fd: i32, buf: *const u8, count: usize) -> i32
ioctl_syscall        // ioctl_syscall(&self, virtual_fd: i32, request: u64, ptrunion: *mut u8) -> i32
mmap_syscall         // mmap_syscall(&self, addr: *mut u8, len: usize, prot: i32, flags: i32, virtual_fd: i32, off: i64) -> i32
munmap_syscall       // munmap_syscall(&self, addr: *mut u8, len: usize) -> i32
getdents_syscall     // getdents_syscall(&self, virtual_fd: i32, buf: *mut u8, nbytes: u32) -> i32
send_syscall         // send_syscall(&self, virtual_fd: i32, buf: *const u8, buflen: usize, flags: i32) -> i32
sendto_syscall       // sendto_syscall(&self, virtual_fd: i32, buf: *const u8, buflen: usize, flags: i32, dest_addr: &GenSockaddr) -> i32
shmat_syscall        // shmat_syscall(&self, shmid: i32, shmaddr: *mut u8, shmflg: i32) -> i32
shmdt_syscall        // shmdt_syscall(&self, shmaddr: *mut u8) -> i32
pread_syscall        // pread_syscall(&self, virtual_fd: i32, buf: *mut u8, count: usize, offset: i64) -> i32
pwrite_syscall       // pwrite_syscall(&self, virtual_fd: i32, buf: *const u8, count: usize, offset: i64) -> i32
getifaddrs_syscall   // getifaddrs_syscall(&self, buf: *mut u8, count: usize) -> i32
writev_syscall       // writev_syscall(&self,virtual_fd: i32,iovec: *const interface::IovecStruct,iovcnt: i32,) -> i32
recv_syscall         // recv_syscall(&self, virtual_fd: i32, buf: *mut u8, buflen: usize, flags: i32) -> i32
recvfrom_syscall     // recvfrom_syscall(&self, virtual_fd: i32, buf: *mut u8, buflen: usize, flags: i32, addr: &mut Option<&mut GenSockaddr>) -> i32
getsockopt_syscall   // getsockopt_syscall(&self, virtual_fd: i32, level: i32, optname: i32, optval: *mut u8, optlen: *mut u32) -> i32
setsockopt_syscall   // setsockopt_syscall(&self, virtual_fd: i32, level: i32, optname: i32, optval: *const u8, optlen: u32) -> i32
gethostname_syscall  // gethostname_syscall(&self, name: *mut u8, len: isize) -> i32

@rennergade
Copy link
Contributor Author

Below is the syscall list that uses pointer and doesn't use.

// Uses pointers
getcwd_syscall       // getcwd_syscall(&self, buf: *mut u8, bufsize: u32) -> i32
read_syscall         // read_syscall(&self, virtual_fd: i32, readbuf: *mut u8, count: usize) -> i32
write_syscall        // write_syscall(&self, virtual_fd: i32, buf: *const u8, count: usize) -> i32
ioctl_syscall        // ioctl_syscall(&self, virtual_fd: i32, request: u64, ptrunion: *mut u8) -> i32
mmap_syscall         // mmap_syscall(&self, addr: *mut u8, len: usize, prot: i32, flags: i32, virtual_fd: i32, off: i64) -> i32
munmap_syscall       // munmap_syscall(&self, addr: *mut u8, len: usize) -> i32
getdents_syscall     // getdents_syscall(&self, virtual_fd: i32, buf: *mut u8, nbytes: u32) -> i32
send_syscall         // send_syscall(&self, virtual_fd: i32, buf: *const u8, buflen: usize, flags: i32) -> i32
sendto_syscall       // sendto_syscall(&self, virtual_fd: i32, buf: *const u8, buflen: usize, flags: i32, dest_addr: &GenSockaddr) -> i32
shmat_syscall        // shmat_syscall(&self, shmid: i32, shmaddr: *mut u8, shmflg: i32) -> i32
shmdt_syscall        // shmdt_syscall(&self, shmaddr: *mut u8) -> i32
pread_syscall        // pread_syscall(&self, virtual_fd: i32, buf: *mut u8, count: usize, offset: i64) -> i32
pwrite_syscall       // pwrite_syscall(&self, virtual_fd: i32, buf: *const u8, count: usize, offset: i64) -> i32
getifaddrs_syscall   // getifaddrs_syscall(&self, buf: *mut u8, count: usize) -> i32
writev_syscall       // writev_syscall(&self,virtual_fd: i32,iovec: *const interface::IovecStruct,iovcnt: i32,) -> i32
recv_syscall         // recv_syscall(&self, virtual_fd: i32, buf: *mut u8, buflen: usize, flags: i32) -> i32
recvfrom_syscall     // recvfrom_syscall(&self, virtual_fd: i32, buf: *mut u8, buflen: usize, flags: i32, addr: &mut Option<&mut GenSockaddr>) -> i32
getsockopt_syscall   // getsockopt_syscall(&self, virtual_fd: i32, level: i32, optname: i32, optval: *mut u8, optlen: *mut u32) -> i32
setsockopt_syscall   // setsockopt_syscall(&self, virtual_fd: i32, level: i32, optname: i32, optval: *const u8, optlen: u32) -> i32
gethostname_syscall  // gethostname_syscall(&self, name: *mut u8, len: isize) -> i32

I think theres a few of these that should use pointers but may not be as evident? Like I believe things like select and poll should use pointers but not sure what the interface is now. Maybe @Yaxuan-w can chime in.

@Yaxuan-w
Copy link
Member

I think theres a few of these that should use pointers but may not be as evident? Like I believe things like select and poll should use pointers but not sure what the interface is now. Maybe @Yaxuan-w can chime in.

The dispatcher.rs being compared by Chinmay is the one after merging the WASM API PR. In that PR, some syscalls (e.g., select, epoll_ctl, epoll_wait) were not added to the dispatcher. I have already opened an issue for this and assigned Robin to address the missing syscalls.

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

No branches or pull requests

5 participants