Commit graph

302 commits

Author SHA1 Message Date
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
Jason White
10b3d0df9f Disable some perf tests on aarch64
Summary: See comment for an explanation of why this is needed. These tests should eventually be updated to work on aarch64.

Reviewed By: VladimirMakaev

Differential Revision: D40867431

fbshipit-source-id: 089e8bd61bec21556bdebc8b1f89dd4d18aa0910
2022-11-01 10:11:35 -07:00
Jason White
aef4d4d2e6 Fix do_branches
Summary: Change the `sub` instruction to `subs` as the latter is needed to update the condition code that `be.n` relies on.

Reviewed By: VladimirMakaev

Differential Revision: D40867430

fbshipit-source-id: b45987b5ccd4af784988f14fe0d6b3ac97b5ad80
2022-11-01 10:11:35 -07:00
Jason White
f467cfa03c Add vdso patches for aarch64
Summary: This adds VDSO stubs for aarch64 so that we can intercept VDSO calls. See the comments in the code for more details.

Reviewed By: VladimirMakaev

Differential Revision: D40867428

fbshipit-source-id: 136818d9dbf52f4297dd4dae041e3e6dfe0764ae
2022-11-01 10:11:35 -07:00
David Tolnay
a3ed18f93a Update libc to 0.2.137
Summary: Update from 0.2.135 to 0.2.137, the latest version on crates.io, in preparation for backporting a PR in the diff after this one.

Reviewed By: zertosh

Differential Revision: D40874274

fbshipit-source-id: debf9dae82ecc20201470e634f10904a2b308e51
2022-11-01 02:16:19 -07:00
Jason White
ada1e3c542 Get tests building under aarch64
Reviewed By: VladimirMakaev

Differential Revision: D40701839

fbshipit-source-id: e60053c7d21696e7f7dd120420b896dee3d65ba7
2022-10-27 10:56:09 -07:00
Jason White
21f7f9a8a6 Fix rustc warnings
Reviewed By: VladimirMakaev

Differential Revision: D40701835

fbshipit-source-id: d74560c4c6b360f89ff6b8d37bc33890bf633947
2022-10-27 10:56:09 -07:00
Jason White
a16d576831 Fix perf timer related things on aarch64
Summary: To do proper feature detection on the CPU to know if we can get perf events, there is more work to do here. See the comment on `get_rcb_perf_config` for more info.

Reviewed By: VladimirMakaev

Differential Revision: D40701837

fbshipit-source-id: 4c7a7c00be0ab14e4fe9f4be09c8094567d5d031
2022-10-27 10:56:09 -07:00
Jason White
caf0f12131 Add generalized stack pointer access
Reviewed By: VladimirMakaev

Differential Revision: D40701834

fbshipit-source-id: 6cad4cedc0d22488117d3d991ae9a80b643ee037
2022-10-27 10:56:09 -07:00
Jason White
4f9ce11c70 Add aarch64 registers to gdbstub
Reviewed By: VladimirMakaev

Differential Revision: D40701836

fbshipit-source-id: 42c47be166d892bc208b68938d4c41746857b38c
2022-10-27 10:56:09 -07:00
Jason White
f200e9a8cf Rename Amd64CoreRegs -> CoreRegs
Summary: This is a more architecture-independent name.

Reviewed By: VladimirMakaev

Differential Revision: D40701833

fbshipit-source-id: 66b77c6f62886ecd776a3efbc0b71248f875914e
2022-10-27 10:56:09 -07:00
Jason White
4b8517a067 Move gdbstub regs definitions to arch-specific file
Summary: These definitions are x86_64-specific, so they should be defined in their own file. Later, we'll add definitions for aarch64.

Reviewed By: VladimirMakaev

Differential Revision: D40701840

fbshipit-source-id: 0c52334dc7eb9bb60020c45c3f2ef58077c20322
2022-10-27 10:56:09 -07:00
Jason White
e5fa5f367c Clean up gdbstub regs definitions
Reviewed By: VladimirMakaev

Differential Revision: D40701832

fbshipit-source-id: 8d5c95c624ae28313cecad3522078ccde4b4d75d
2022-10-27 10:56:09 -07:00
Jason White
5949b4023f Fix more things for aarch64
Summary: fixallthethings

Reviewed By: VladimirMakaev

Differential Revision: D40577286

fbshipit-source-id: 0fb2d83843886be12c46ec199ab0303d2087597d
2022-10-27 10:56:09 -07:00
Vladimir Makaev
03cbd6044d update hermetic_infra/** files with correct license header - 1/x
Summary:
Followed guide here https://www.internalfb.com/intern/wiki/Linting/License_Lint/ to add fbcode/hermetic_infra/** code to license linter. As we have parts of our code shipped as Open Source it's important to get this automated

This diff is updating existing file's licenses to not get conflict after lint rule enablement

Reviewed By: jasonwhite

Differential Revision: D40674080

fbshipit-source-id: da6ecac036f8964619cf7912058f3a911558e7b1
2022-10-26 12:18:14 -07:00
Jason White
8862833da4 Replace direct register accesses with abstraction
Reviewed By: wangbj

Differential Revision: D40577287

fbshipit-source-id: 8fe94d172ffb0f1d7c2e177ec6314b1b77f4e5c1
2022-10-21 12:09:36 -07:00
Jason White
6ad5309bb1 Add abstraction over register access
Summary:
This abstracts the set of general purpose registers so that we can more easily access special registers in an architecture-independent way.

The rest of the code will be refactored to use this new interface in a later change.

Reviewed By: wangbj

Differential Revision: D40577289

fbshipit-source-id: 313a3ab3863f09a506b6e61fb67093fc49eeae3e
2022-10-21 12:09:36 -07:00
Jason White
6e36d021a3 Add aarch64 support to safeptrace
Summary: Adds aarch64 support to the safeptrace crate.

Reviewed By: wangbj

Differential Revision: D40577290

fbshipit-source-id: e7748e00a3d37d13a576e33865a4b97917cb661d
2022-10-21 12:09:36 -07:00
Jason White
5049415db6 Get main reverie crate compiling on aarch64
Reviewed By: wangbj

Differential Revision: D40577288

fbshipit-source-id: 0cf76ef1fdae1a5bcd0aaf046ec59ed7b7478d91
2022-10-21 12:09:36 -07:00
David Tolnay
eb92a00594 Update to async-trait 0.1.58
Summary: This release makes async trait methods work better with rust-analyzer's "go to definition" and other IDE functionality.

Reviewed By: zertosh

Differential Revision: D40532047

fbshipit-source-id: 1871d1819ebe1aab0846b0135f051c45e6e8821b
2022-10-19 17:35:20 -07:00
Jason White
adc75712a7 Add FICLONE and FICLONERANGE ioctls
Reviewed By: igorsugak

Differential Revision: D40521846

fbshipit-source-id: 25ec8d85ee0fc3c4df07637c9623505460a6670b
2022-10-19 13:37:38 -07:00
Ryan Newton
4b910a9e2b bump the SKID_MARGIN from 50 to 60
Summary:
On devvm5443.atn0.facebook.com (Intel Xeon Processor (Skylake)), I observed a slippage a bit past the skid of 50:

    ✉ Timeout: hermetic_infra/hermit/tests:hermit_run_strict__sh_par_work - main (300.011)
    Test output:
    > from_execution_error::timeout::LocalExecutor::Timeout
    :: Run1...
    thread 'main' panicked at 'Clock perf counter exceeds target value at start of attempted single-step: 23417931 > 23417927. Consider increasing SKID_MARGIN_RCBS.', hermetic_infra/reverie/reverie-ptrace/src/timer.rs:562:9

Therefore I'm bumping it to 60.

This is unfortunate, because it directly slows down our chaos mode preemptions (until we eventually get an emulator), but I'm therefore bumping the skid margin.
We could also potentially set it differently for devvm and for bare metal.

Reviewed By: jasonwhite

Differential Revision: D40383171

fbshipit-source-id: 34bb8217a61fc2c77f1d45d23b8c28f91cae5efc
2022-10-18 12:27:28 -07:00
Nofel Yaseen
79de15c108 Enable aarch64 build
Summary: Get reverie-syscalls building on aarch64

Reviewed By: jasonwhite

Differential Revision: D40323777

fbshipit-source-id: bc7a326dc06deb2247a4b2a8f784b05745e961b7
2022-10-17 12:28:12 -07:00
Andrey Buchinskiy
a24e92eea4 bump tokio version to 1.21.2
Reviewed By: zertosh

Differential Revision: D40199323

fbshipit-source-id: 32355e73ea669a180ac759ddb02760db10c8b02b
2022-10-14 15:24:20 -07:00
Jeremy Fitzhardinge
f1336c3b2e third-party/rust: bump tracing-subscriber and tracing-glog
Summary:
tracing-glog -> 0.2.1 with minor formatting bugfix
tracing-subscriber -> 0.3.16 mostly to keep it fresh and share dependencies

Reviewed By: davidbarsky

Differential Revision: D40350661

fbshipit-source-id: e62ec53747a194da0a9b0ca2b63bb16df2479a6f
2022-10-14 13:32:47 -07:00
Sargun Dhillon
fa682caf9b Update Rust libc crate to 0.2.135
Summary: This updates the libc crate to 0.2.135, which includes the FICLONE constant needed to the given ioctl.

Reviewed By: justintrudell

Differential Revision: D40286796

fbshipit-source-id: acfa115479cd289f478d8d73937be34ced5c4bbb
2022-10-13 18:51:18 -07:00
Jason White
c4bd924994 Propagate typed_syscall!{} attributes
Differential Revision: D40329620

fbshipit-source-id: 5088249785601329aee6609c4873d991bdaf38f3
2022-10-13 10:15:47 -07:00
Igor Makaruks
f43ccb1c5c Cleaned up duplicate help messages
Summary: Ran regex `#\[clap.*?help` to locate single line clap options with help messages and manually went through several multiline ones.

Reviewed By: jasonwhite

Differential Revision: D40297841

fbshipit-source-id: 108d9da70f9a3bd096167e41c287a4a959b10c17
2022-10-13 05:25:03 -07:00
Jason White
b973b4ad42 Propagate syscall_list!{} attributes
Differential Revision: D40323825

fbshipit-source-id: 78deea76931058ed8eeb44250a0168ef400fee8a
2022-10-12 16:34:18 -07:00