Commit graph

180 commits

Author SHA1 Message Date
Jason White
fa44c91a66 Add script to dump the VDSO
Summary: Helper script for debugging https://github.com/facebookexperimental/hermit/issues/16.

Differential Revision: D41565407

fbshipit-source-id: 01cd3121dde671a563a8d2674cc42bfa6bce1226
2022-11-28 16:28:02 -08:00
Jason White
8909065ec3 Add build/test instructions to the README
Differential Revision: D41562403

fbshipit-source-id: 4478d4cfca9d487f03fdf3b60b2805bc65d4bca4
2022-11-28 16:28:02 -08:00
Jason White
5ff7f23e25 Remove file descriptor niche optimization
Summary: This size optimization relies on a nightly feature that will likely never be stabilized. All it did was make `Option<Fd>` equal to 4 bytes instead of 8 bytes.

Reviewed By: rrnewton

Differential Revision: D41506685

fbshipit-source-id: 15aa75b01200ff7f179373b07e14f542590aa24d
2022-11-28 12:21:33 -08:00
Jason White
c448d10586 Reduce size of getcpu vdso
Summary: The `getcpu` VDSO was just returning 0 unconditionally. This was an old hack to determinize the getcpu syscall, but we don't need this anymore because we just intercept it and determinize it instead. Reducing the size of this vdso function will make it more compatible with various VDSO implementations.

Reviewed By: wkhughes

Differential Revision: D41506684

fbshipit-source-id: 3dacad93971ecc7969d725f8b7e984a189a0ebb4
2022-11-23 13:55:56 -08:00
Jason White
debce82715 Remove unnecessary padding on vdso replacements
Summary: If the VDSO replacements are too large, they will overwrite too much memory if the real VDSO functions are smaller than the replacement. This fixes https://github.com/facebookexperimental/hermit/issues/16.

Reviewed By: wkhughes

Differential Revision: D41506686

fbshipit-source-id: 7c33e68ae9cccb440b820245e4d37184e156d03b
2022-11-23 13:55:56 -08:00
Ryan Johnson
6f03658469 Remove call to trace_start_init
Summary:
`trace_start_init` relies on the deprecated/removed symbol `initForTraceStart`,
and it's not critical, so this diff removes it.

Reviewed By: jasonwhite

Differential Revision: D41447262

fbshipit-source-id: a291b822d7e6c620f15182374d8923bc18ad2ec8
2022-11-21 17:16:10 -08:00
Jason White
2a73bdeb1c Move set_output_capture behind the nightly feature flag
Summary: `std::io::set_output_capture()` is only available in nightly. In order to publish this crate, we can't use unstable features.

Reviewed By: rrnewton

Differential Revision: D41394375

fbshipit-source-id: d4b6e9310cd6d6925aa9d7b0cd5c4558d6ef7d4c
2022-11-21 11:07:23 -08:00
Jason White
3a0494e2bc Remove need for never_type unstable feature
Summary: Refactors `do_exec` a little bit so that it no longer needs the `never_type` feature. This doesn't affect correctness at all.

Reviewed By: rrnewton

Differential Revision: D41394377

fbshipit-source-id: 30e8793557d12d9aef1c5641eb782b170f86512b
2022-11-21 11:07:23 -08:00
Jason White
5ca441ea60 Make rustc_attrs unstable feature optional
Summary: The usage of `rustc_attrs` is completely optional and only serves as a size optimization for the `Fd` type.

Reviewed By: rrnewton

Differential Revision: D41394376

fbshipit-source-id: 2f4898b872dc32c517df99e0b5f4a82fad5bda77
2022-11-21 11:07:23 -08:00
Jason White
100dd3ec3a Add "nightly" crate feature
Summary:
This adds the "nightly" crate feature to `reverie-process` so that it can use nightly features if they are enabled.

This *should* let it still get uploaded to crates.io, but some fancy optional nightly features will be hidden behind this feature flag. Then, we can still use these features internally.

Reviewed By: rrnewton

Differential Revision: D41394572

fbshipit-source-id: 6f5eaccd070f85c839089d3d5e5994471948afd4
2022-11-21 11:07:23 -08:00
Jason White
230d1421a2 Fix doc-test
Summary: The OSS CI build is currently failing because of this.

Reviewed By: rrnewton

Differential Revision: D41414284

fbshipit-source-id: ba9cb5b46f552e76d7a8ebd5ff94d949105339b6
2022-11-18 16:28:31 -08:00
Jason White
b9e3f0c0e7 Remove associated_type_defaults unstable feature
Summary: Removes the `associated_type_defaults` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing the crate on https://crates.io.

Reviewed By: rrnewton

Differential Revision: D41389496

fbshipit-source-id: f80d9dd960196ce4fb61c886796836a79e12962b
2022-11-18 12:36:51 -08:00
Jason White
9a942d055f Remove dependencies on associated_type_defaults unstable feature
Summary: Removes usage of the `associated_type_defaults` unstable feature, but does not actually disable the feature yet. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.

Reviewed By: rrnewton

Differential Revision: D41388745

fbshipit-source-id: f347a577857a713fe3088a556cbf37ffe92e5553
2022-11-18 12:36:51 -08:00
Jason White
58bc1cce8b Remove unused bench_black_box unstable feature
Summary: Removes usage of the `bench_black_box` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.

Reviewed By: rrnewton

Differential Revision: D41387686

fbshipit-source-id: 98bfcf053cd320137dbf62f4ef24beb835e1f0df
2022-11-18 12:36:51 -08:00
Jason White
0f5f62c1dd Remove need for map_first_last unstable feature
Summary: Removes usage of the `map_first_last` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.

Reviewed By: rrnewton

Differential Revision: D41387687

fbshipit-source-id: 05184220a6d6cd5ec03339845741b46e9557ca83
2022-11-18 12:36:51 -08:00
Jason White
ee616643a4 Remove need for async_closure unstable feature
Summary: Removes usage of the `async_closure` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.

Reviewed By: rrnewton

Differential Revision: D41387688

fbshipit-source-id: 136c5c8d19876e732d18dca195e87e3bc2ab7661
2022-11-18 12:36:51 -08:00
Jason White
b9bd4ec901 Fix broken backtraces
Summary:
This contains a couple of big fixes for stack traces:
 1. Fixes missing symbols for executables.
 2. Fixes missing file and line numbers for libraries that use the `gnu_debuglink` feature (where the actual debug information is in a separate file).

Reviewed By: wkhughes

Differential Revision: D41366208

fbshipit-source-id: dd9bb8099ecdab4668846acc67c3b56a04cc96cf
2022-11-17 08:52:33 -08:00
Jason White
97677924e9 third-party/rust: Upgrade addr2line and object crates
Summary: Updates `addr2line` and `object` to the latest versions.

Reviewed By: wkhughes

Differential Revision: D41327264

fbshipit-source-id: 90f600257b7176ee35b243cb7ab72afbc06762b5
2022-11-17 08:52:33 -08:00
generatedunixname89002005287564
c462336e3d Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: krallin

Differential Revision: D41368646

fbshipit-source-id: 5f15114f141028c7dcd38c96cd853f29dfe91696
2022-11-17 00:26:13 -08:00
Vladimir Makaev
4820afb142 implement set_timer_precise(rbc, instr)
Summary: We want to allow precise timers with an instruction offset. While single stepping we have target and current value of the counter and once we match branches we only increment instructions

Reviewed By: jasonwhite

Differential Revision: D41269879

fbshipit-source-id: 46b3307249663de10607513dc59d8436ca907f78
2022-11-16 14:01:41 -08:00
Ryan Newton
d7e9901f53 use RunOpts more uniformly
Summary: These previous launch_* functions can be simplified by using RunOpts to contain all the relevant information about a run, plus everything needed to print a reproducer command.

Reviewed By: VladimirMakaev

Differential Revision: D41329114

fbshipit-source-id: 5bab08dfbf28e1cee7fd244178e03ba2cdc1ba34
2022-11-16 07:01:14 -08:00
generatedunixname89002005294178
81ca16a694 Update traceviz component on FBS:master
Differential Revision: D41332214

fbshipit-source-id: 3b6a7e09e124d11a9501c2aa03b0c3cbce39b89f
2022-11-15 23:30:37 -08:00
Jason White
69367b5408 Partially fix symbol resolution
Summary: `libunwind` isn't able to resolve symbols from the symbol table. There seems to be a regression preventing this from working. This partially fixes symbol lookup for stack frames by using the `object` crate for looking up symbols in the symbol table. This is a partial fix because symbol lookup does not seem to work yet for executables (only shared libraries).

Reviewed By: VladimirMakaev

Differential Revision: D41290099

fbshipit-source-id: 5d4ad1173f6ab1ca6c2995369c2dedb4a9f30e86
2022-11-15 09:58:51 -08:00
generatedunixname89002005294178
6bea3e3f73 Update traceviz component on FBS:master
Differential Revision: D41297952

fbshipit-source-id: 0deb4885917aa482cfa4a0cb790775c9a486b8cc
2022-11-14 23:25:53 -08:00
generatedunixname89002005294178
775308ee49 Update traceviz component on FBS:master
Differential Revision: D41259923

fbshipit-source-id: dbf84d6130a30547fb1579ddbd3f54cdb2bdab7f
2022-11-13 23:25:20 -08:00
Jason White
de3a571bb9 Fix dotslash paths
Summary: Fixes the paths after moving `reverie/fb-only/` to `reverie/experimental/`.

Reviewed By: VladimirMakaev

Differential Revision: D41240531

fbshipit-source-id: bba17fa598c2bb53f2765f9e6edddd59b7543048
2022-11-11 17:43:40 -08:00
Jason White
316b36650c Add ReadFamily
Summary: Adds `ReadFamily` to make it easier to handle all `read` syscall variants.

Reviewed By: igorsugak

Differential Revision: D41239542

fbshipit-source-id: 2c847e421b38281aa5243d8dfc00a8d1de0c075a
2022-11-11 16:52:21 -08:00
Jason White
df05ba9e83 Remove Addr::as_ref and AddrMut::as_ref
Summary: These operations are misleading and should never be called. Since the address could be a remote address, dereferencing it like this is wildly wrong. Not quite sure how they got there in the first place.

Reviewed By: igorsugak

Differential Revision: D41193389

fbshipit-source-id: 143c491df81125b319f7d5d88049021a81981795
2022-11-10 15:26:59 -08:00
Dimitris Iliopoulos
84da445a0d update to Rust 1.65.0
Summary:
Added `fbcode` symlinks for `platform010` & `platform010-aarch64` and addressed the following fixes:
* Account for stabilized [`#![feature(backtrace)]`](https://github.com/rust-lang/rust/pull/99573) and [`#![feature(generic_associated_types)]`](https://github.com/rust-lang/rust/pull/99573)
* Account for removal of [`#![feature(result_into_ok_or_err)]`](https://github.com/rust-lang/rust/pull/100604)
* Account for migration of [`std::io::ReadBuf` to `std::io::BorrowBuf|BorrowCursor`](https://github.com/rust-lang/rust/pull/97015)
* Account for [`Error` trait move into core](https://github.com/rust-lang/rust/pull/99917)
* Account for `#[warn(non_camel_case_types)]`
* Various function signature, lifetime requirement changes and lint fixes

Reviewed By: zertosh

Differential Revision: D40923615

fbshipit-source-id: f7ac2828d74edeae39aae517172207b0ee998a59
2022-11-09 19:37:29 -08:00
Jason White
c6532de85d Open source experimental in-guest interception
Differential Revision: D41099658

fbshipit-source-id: 52b414e27abd3c0c3a6367dea225724f4220793b
2022-11-09 01:03:49 -08:00
Vladimir Makaev
0a023a3945 oss release: update hermit licence to BSD
Summary:
We're open sourcing Hermit under BSD licence. This diff updates the linter configuration and a linter code was executed under /hermetic_infra directory

```
arc lint --apply-patches --take LICENSELINT --paths-cmd 'hg files .'
```

Reviewed By: rrnewton

Differential Revision: D41120862

fbshipit-source-id: 099ddff7d35e928178bebd50a1d1d4a44b4d792d
2022-11-08 06:45:54 -08:00
Vladimir Makaev
0c8136b22e decode & trace instructions while single-stepping
Summary:
This adds an ability to decode an instruction on top of the safeptrace::Stopped task and enables debug! tracing when single-stepping.

Note that performance overhead should not be present when higher tracing level  is requested

Reviewed By: jasonwhite

Differential Revision: D40895393

fbshipit-source-id: 867f237a0517304314f4ac43313c1f26cee3f646
2022-11-08 04:39:12 -08:00
Vladimir Makaev
f33975a3eb trace output buffers for clock_gettime
Reviewed By: jasonwhite

Differential Revision: D40946575

fbshipit-source-id: 5ca05f7d38ebd1eb7e031f017482ef8358bf1f2d
2022-11-08 04:39:12 -08:00
Vladimir Makaev
96c89f04e8 implement displayable_ptr! macro to simplify displayable implementation
Summary:
Implementing Displayable can be quite annoying (see D40877692)
This macro provides a boilerplate implementation for a custom struct wrapper for AddrMut<T>
Additional customization can be achieved by implementing Displayable for T

Reviewed By: jasonwhite

Differential Revision: D40946491

fbshipit-source-id: daff74b2c0c23c6d970f920c7d43ab2c381a1dcb
2022-11-08 04:39:12 -08:00
Vladimir Makaev
0ecbd32338 detlog "gettimeofday" output buffers
Summary: While investigating a test failure I've narrowed down a divergence to a gettimeofday syscall having different result in trace-replay use case in certain conditions. In this diff I'm enhacing the syscalls DETLOGS with "output buffers" derefed. Currently barelly any of the parameters are supported but hopefully we'll handle Displayable in a more general purpose way in a future

Reviewed By: jasonwhite

Differential Revision: D40877692

fbshipit-source-id: 47c3d310713e400fb2ab18dc736b84999e8c7b99
2022-11-08 04:39:12 -08:00
Vladimir Makaev
c93d2024e7 add common code to display libc::user_regs_struct
Summary: this adds more compact and reusable way to display libc::user_regs_struct

Reviewed By: jasonwhite

Differential Revision: D40895319

fbshipit-source-id: fde83d834cc4179bfc6a6aa8d77a4de5f6598e1b
2022-11-08 04:39:12 -08:00
Jason White
cc40e95c91 Remove unnecessary Serialize/Deserialize impls for tools
Summary: Now that `Tool` doesn't require `Serialize` and `Deserialize`, we can remove these unnecessary derives. Hopefully this will have a slight improvement to compile-times.

Reviewed By: wkhughes

Differential Revision: D40958697

fbshipit-source-id: 88aa1f4ee2b953ba287d749c88d200c2887ccd46
2022-11-03 12:53:11 -07:00
Jason White
4b87db9065 Remove requirement for Tool to implement Serialize and Deserialize
Summary: Nothing relies on this requirement nor do I think anything ever will rely on this requirement. If I recall correctly, the reason this was originally added is because a hypothetical in-guest Reverie backend might need to copy the process-level state after a fork/clone/execve. However, after getting far enough into the implementation of an in-guest backend, I don't think this is something we'll ever need to do. For fork/clone, the address space is just forked, so we already have the process-level state. If, for some reason, we need to re-copy some process-level state into a new process post-execve, we can just leave that up to the tool to implement (by doing RPC calls).

Reviewed By: wkhughes

Differential Revision: D40958698

fbshipit-source-id: a41244102ca20fdfd28ab34180d098a13273949a
2022-11-03 12:53:11 -07:00
Jason White
0a4791711c Remove old and unused llvm_asm!() assembly blocks
Summary:
This was from the *before times* when `core::arch::asm` wasn't yet stable. `llvm_asm!()` has been removed from recent versions of rustc, so this stuff won't even compile anymore.

Note that this also removes a rather large block of `llvm_asm` (`check_for_xen_pmi_bug`) that hasn't yet been migrated over to the new asm syntax. This seems like a lot of work for little benefit, so I'm just deleting it for now.

Differential Revision: D40957341

fbshipit-source-id: 2b9bf97e93eaa9462295b9060907530dd797e288
2022-11-03 12:53:11 -07:00
Jason White
ffc3020fe8 Update readme with aarch64 support
Reviewed By: wkhughes

Differential Revision: D40956267

fbshipit-source-id: 10655f6898e026506778c0a55b8daee619029908
2022-11-03 12:53:11 -07:00
Jason White
ffd9f11127 Fix reverie-syscalls tests on aarch64
Reviewed By: wkhughes

Differential Revision: D40919201

fbshipit-source-id: 76e9d470fe6632d4c42232a6c7bbc41c2ac8d0f8
2022-11-03 12:53:11 -07:00
Jason White
3d5d8c99b6 Fix strace unit tests
Reviewed By: wkhughes

Differential Revision: D40915387

fbshipit-source-id: b311a6f71c08ce2c7b490f59b2e711d78a41c7a7
2022-11-03 12:53:11 -07:00
Jason White
312049857d Fix subscription unit tests
Reviewed By: wkhughes

Differential Revision: D40915386

fbshipit-source-id: c8aed0e220ea3589e21595fdc91a67c354560cb4
2022-11-03 12:53:11 -07:00
Jason White
b7bf8c32bd Add alias for Newfstatat syscall
Summary: The syscall `fstatat` is defined a bit weirdly on x86-64 as `newfstatat`. To make the platform differences slightly easier to deal with, lets just define a type alias for it.

Reviewed By: wkhughes

Differential Revision: D40910778

fbshipit-source-id: 4bf307e574d2d2c13f1cf764e7604b32113d209e
2022-11-03 12:53:11 -07:00
Jason White
71551a592c Remove unnecessary allocations in vdso patching
Reviewed By: VladimirMakaev

Differential Revision: D40872276

fbshipit-source-id: cd4b25b437ad2f4bb7929f33477af866da80dc3c
2022-11-01 10:11:35 -07:00
Jason White
90e39abc59 Fix skip_seccomp_syscall
Summary: Fixes `skip_seccomp_syscall` on aarch64 to *actually* skip the syscall. I plan on cleaning this up a bit more in a later diff because we are calling `getregs` and `setregs` more than necessary on a per-interception basis.

Reviewed By: VladimirMakaev

Differential Revision: D40867423

fbshipit-source-id: d72b4998b5c1c44f426a9129eccb205ccfc320fa
2022-11-01 10:11:35 -07:00
Jason White
0ae449caba Fix unused dependency warning
Reviewed By: VladimirMakaev

Differential Revision: D40872004

fbshipit-source-id: 07ee4af14dcf33e9a8d1c0f2aa2333062d39c044
2022-11-01 10:11:35 -07:00
Jason White
deac8c4140 Add test to check that syscalls are suppressed successfully
Summary: This checks that intercepted syscalls are actually skipped (by setting the syscall to -1). This was found to not be working on aarch64 and is fixed in the next diff.

Reviewed By: VladimirMakaev

Differential Revision: D40867424

fbshipit-source-id: 7ac514c060a2611aac8cc4a8bb7540aa3d7302fb
2022-11-01 10:11:35 -07:00
Jason White
76adc9174f Fix initial syscall injection
Summary: This fixes the initial syscall injection on aarch64. This also does slight simplification of the instructions that get plopped down at the current instruction pointer so that we can fit the instructions into a single word. That is, instead of injecting `INT3; SYSCALL; INT3`, we inject `SYSCALL; INT3`.

Reviewed By: VladimirMakaev

Differential Revision: D40867427

fbshipit-source-id: 2afa96f2270e16284523a17b09da00529893c20e
2022-11-01 10:11:35 -07:00
Jason White
2346c73d2c Fix tests on aarch64
Summary: Gets all tests in `reverie-process` successfully working on aarch64.

Reviewed By: VladimirMakaev

Differential Revision: D40867425

fbshipit-source-id: 4aa7b0be17a40f677baf5de312a0765f8c41c2a4
2022-11-01 10:11:35 -07:00