-
Notifications
You must be signed in to change notification settings - Fork 16
lind-perf: add rawposix benchmarks + special syscalls.
#848
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
base: lind-perf-init
Are you sure you want to change the base?
Changes from all commits
fa412ac
d1f9ecb
68fbce7
0b438d0
796b405
a906538
88ad63c
fb13c71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| use fdtables; | ||
| use sysdefs::constants::Errno; | ||
| use typemap::datatype_conversion::sc_unusedarg; | ||
| use typemap::err_const::syscall_error; | ||
|
|
||
| use libc; | ||
|
|
||
| use crate::perf; | ||
|
|
||
| /// Special benchmark syscall for measuring a syscall that calls the kernel for resolution. | ||
| /// | ||
| /// CALL_NUM: 2001 | ||
| /// | ||
| /// Simulates the behaviour of geteuid(). | ||
| /// - publically exported through lind_syscall.h as `libc_syscall()` | ||
| pub extern "C" fn libc_syscall( | ||
| cageid: u64, | ||
| arg1: u64, | ||
| arg1_cageid: u64, | ||
| arg2: u64, | ||
| arg2_cageid: u64, | ||
| arg3: u64, | ||
| arg3_cageid: u64, | ||
| arg4: u64, | ||
| arg4_cageid: u64, | ||
| arg5: u64, | ||
| arg5_cageid: u64, | ||
| arg6: u64, | ||
| arg6_cageid: u64, | ||
| ) -> i32 { | ||
| let _timer = lind_perf::get_timer!(perf::LIBC_CALL); | ||
|
|
||
| // Validate that each extra argument is unused. | ||
| if !(sc_unusedarg(arg1, arg1_cageid) | ||
| && sc_unusedarg(arg2, arg2_cageid) | ||
| && sc_unusedarg(arg3, arg3_cageid) | ||
| && sc_unusedarg(arg4, arg4_cageid) | ||
| && sc_unusedarg(arg5, arg5_cageid) | ||
| && sc_unusedarg(arg6, arg6_cageid)) | ||
| { | ||
| panic!( | ||
| "{}: unused arguments contain unexpected values -- security violation", | ||
| "libc_syscall" | ||
| ); | ||
| } | ||
|
|
||
| (unsafe { libc::geteuid() }) as i32 | ||
| } | ||
|
|
||
| /// Special benchmark syscall for measuring a syscall that does not get resolved through the | ||
| /// kernel. | ||
| /// | ||
| /// CALL_NUM: 2002 | ||
| /// | ||
| /// Simulates the behaviour of close(-1) i.e closing an invalid file descriptor. | ||
| /// - vfd_arg is hardcoded to -1 through glibc. | ||
| /// - publically exported through lind_syscall.h as `fdtables_syscall()` | ||
| pub extern "C" fn fdtables_syscall( | ||
| cageid: u64, | ||
| vfd_arg: u64, | ||
| vfd_cageid: u64, | ||
| arg2: u64, | ||
| arg2_cageid: u64, | ||
| arg3: u64, | ||
| arg3_cageid: u64, | ||
| arg4: u64, | ||
| arg4_cageid: u64, | ||
| arg5: u64, | ||
| arg5_cageid: u64, | ||
| arg6: u64, | ||
| arg6_cageid: u64, | ||
| ) -> i32 { | ||
| let _timer = lind_perf::get_timer!(perf::FDTABLES_CALL); | ||
|
|
||
| if !(sc_unusedarg(arg2, arg2_cageid) | ||
| && sc_unusedarg(arg3, arg3_cageid) | ||
| && sc_unusedarg(arg4, arg4_cageid) | ||
| && sc_unusedarg(arg5, arg5_cageid) | ||
| && sc_unusedarg(arg6, arg6_cageid)) | ||
| { | ||
| panic!( | ||
| "{}: unused arguments contain unexpected values -- security violation", | ||
| "fdtables_syscall" | ||
| ); | ||
| } | ||
|
|
||
| // Call close(-1) | ||
| match fdtables::close_virtualfd(cageid, vfd_arg) { | ||
| Ok(()) => 0, | ||
| Err(e) => { | ||
| if e == Errno::EBADFD as u64 { | ||
| syscall_error(Errno::EBADF, "close", "Bad File Descriptor") | ||
| } else if e == Errno::EINTR as u64 { | ||
| syscall_error(Errno::EINTR, "close", "Interrupted system call") | ||
| } else { | ||
| syscall_error(Errno::EIO, "close", "I/O error") | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,11 @@ | |
| // This library provides POSIX-compliant system call implementations that operate | ||
| // within the Lind-WASM sandbox environment using the 3i (Three Interposition) system. | ||
|
|
||
| pub mod bench_calls; | ||
| pub mod fs_calls; | ||
| pub mod init; | ||
| pub mod net_calls; | ||
| pub mod perf; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also redundant
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a pub mod because lind-boot will need to access rawposix counters through Same with the threei PR, although I did not need a pub use on there which I've removed now. |
||
| pub mod sys_calls; | ||
| pub mod syscall_table; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| use lind_perf::Counter; | ||
|
|
||
| pub static LIBC_CALL: Counter = Counter::new("rawposix::libc_call"); | ||
| pub static FDTABLES_CALL: Counter = Counter::new("rawposix::fdtables_call"); | ||
|
|
||
| pub static ALL_COUNTERS: &[&Counter] = &[&LIBC_CALL, &FDTABLES_CALL]; |
Uh oh!
There was an error while loading. Please reload this page.