-
Notifications
You must be signed in to change notification settings - Fork 165
Stack unwinding improvements #254
base: main
Are you sure you want to change the base?
Commits on Jun 19, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 68df400 - Browse repository at this point
Copy the full SHA 68df400View commit details -
temporarily disable panic_unwind in hostcall macro
This is for debugging purposes so that we have a test case that unwinds to `lucet_context_backstop`. This causes several of the existing test cases to fail, but if you want one that is solely focused on this behavior, run: ``` cargo test -p lucet-runtime --test host unwind ```
Configuration menu - View commit details
-
Copy full SHA for dfd8e25 - Browse repository at this point
Copy the full SHA dfd8e25View commit details -
WIP, get pieces in place for backstop CFI directives to work
... when guest code has correct .eh_frame information, anyway. this currently results in the personality function being called if you run the lucet-runtime hostcall tests under gdb with the following commands ``` set args unwind --test-threads=1 --nocapture b rust_panic r ``` then, when the breakpoint (`rust_panic`) is hit, replace the first return into guest code with a return to `lucet_context_backstop`: ``` `# v-- this is the address of lucet_context_backstop` printf '\x61\x7f\xa0\x56\x55\x55\x00\x00' \ | dd `# because gdb doesnt like "set *(long long*)0xaddr = value ` \ `# v--- just finding the pid of the test debugee ` \ of=/proc/$(ps -ef | grep lucet | grep unwind | cut -d' ' -f2)/mem \ `# v-- this is where the first guest return address is `\ `# v ..for me anyway. replaces 0x00007ffff6878685` \ `# v for "guest_func___original_main". `\ bs=1 seek=$((0x7ffff6872fa8)) \ `# dd would try to truncate guest memory by default. do not do this. `\ conv=notrunc ``` (if you can figure out how to do this standalone in gdb, i'm all ears) at this point, continuing in gdb to allow the panic mechanism to run should ... call into the provided personality function!
Configuration menu - View commit details
-
Copy full SHA for 6c0916d - Browse repository at this point
Copy the full SHA 6c0916dView commit details -
Configuration menu - View commit details
-
Copy full SHA for bf50796 - Browse repository at this point
Copy the full SHA bf50796View commit details -
Configuration menu - View commit details
-
Copy full SHA for e6d35dc - Browse repository at this point
Copy the full SHA e6d35dcView commit details -
experimental checkin of CFA calculation expression
Also includes a not-quite-working personality function for the backstop that fails because the system unwinder doesn't want us to be able to set rdi, even though that's explicitly one of the registers listed as being supported for landing pad passing purposes.
Configuration menu - View commit details
-
Copy full SHA for 2d2bb60 - Browse repository at this point
Copy the full SHA 2d2bb60View commit details -
🎉 add CFI for all saved registers in the backstop
This means backtraces and panics now work across the host/guest stack boundary
Configuration menu - View commit details
-
Copy full SHA for f5255b2 - Browse repository at this point
Copy the full SHA f5255b2View commit details -
Configuration menu - View commit details
-
Copy full SHA for d5b2306 - Browse repository at this point
Copy the full SHA d5b2306View commit details -
Configuration menu - View commit details
-
Copy full SHA for 75ab740 - Browse repository at this point
Copy the full SHA 75ab740View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1bd449d - Browse repository at this point
Copy the full SHA 1bd449dView commit details -
Configuration menu - View commit details
-
Copy full SHA for cc36826 - Browse repository at this point
Copy the full SHA cc36826View commit details -
add (currently-ignored) callee-saved registers test
This test works with the nightly-only `#[unwind(allowed)]` attribute, which we'll hopefully be able to help move along.
Configuration menu - View commit details
-
Copy full SHA for 65beada - Browse repository at this point
Copy the full SHA 65beadaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 829124a - Browse repository at this point
Copy the full SHA 829124aView commit details -
Configuration menu - View commit details
-
Copy full SHA for e7026d2 - Browse repository at this point
Copy the full SHA e7026d2View commit details -
Configuration menu - View commit details
-
Copy full SHA for e96dd2d - Browse repository at this point
Copy the full SHA e96dd2dView commit details -
wip: induce unwinding when resetting a faulted instance
The current state of the repo is such that only the `fault_unwind` test is currently relevant: ``` cargo test -p lucet-runtime --test host fault_unwind -- --nocapture ``` Currently stuck figuring out how to set up the stack properly in order to return into the function that panics. If I pad the stack with a zero word in order to keep it 16-byte aligned, the unwinding runtime interprets that zero as a return address and fails. If I don't add the padding, later instructions fault because of unaligned arguments. We probably need to add a shim that uses `.cfi` directives in order to make the unwinding runtime skip over the padding.
Configuration menu - View commit details
-
Copy full SHA for 84d9394 - Browse repository at this point
Copy the full SHA 84d9394View commit details -
Configuration menu - View commit details
-
Copy full SHA for c988266 - Browse repository at this point
Copy the full SHA c988266View commit details -
Configuration menu - View commit details
-
Copy full SHA for 91a777e - Browse repository at this point
Copy the full SHA 91a777eView commit details -
Configuration menu - View commit details
-
Copy full SHA for a6d2262 - Browse repository at this point
Copy the full SHA a6d2262View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2cbbd9f - Browse repository at this point
Copy the full SHA 2cbbd9fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 01b1ea3 - Browse repository at this point
Copy the full SHA 01b1ea3View commit details -
improve forced unwinding in cases with termination and yield
- adds a `catch_unwind` around each hostcall to make sure we decrement `hostcall_count` when unwinding - handles `State::Yielded` instances by setting a pending termination flag, and then resuming
Configuration menu - View commit details
-
Copy full SHA for 61e083c - Browse repository at this point
Copy the full SHA 61e083cView commit details -
simplify unwinding implementation by using
Faulted
stateThis state already had the context information we needed to initiate unwinding, so we didn't need to add an extra field on our `Context`, or preemptively overwrite the guest context in the signal handler
Configuration menu - View commit details
-
Copy full SHA for 8d98bc8 - Browse repository at this point
Copy the full SHA 8d98bc8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9b627e2 - Browse repository at this point
Copy the full SHA 9b627e2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7460113 - Browse repository at this point
Copy the full SHA 7460113View commit details -
Configuration menu - View commit details
-
Copy full SHA for ff3a4d7 - Browse repository at this point
Copy the full SHA ff3a4d7View commit details -
adjust cfi expressions to use the correct parent_ctx offset
the struct at rbp changed between first authorship and today, to fix a bug where lucet instances were accidentally tied to their starting thread
Configuration menu - View commit details
-
Copy full SHA for 4af7b7e - Browse repository at this point
Copy the full SHA 4af7b7eView commit details -
Configuration menu - View commit details
-
Copy full SHA for ce5b86f - Browse repository at this point
Copy the full SHA ce5b86fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0d9db26 - Browse repository at this point
Copy the full SHA 0d9db26View commit details -
forced unwinding of guests has had its assumptions challenged
when forced unwinding was first envisioned, guests did not run at all from the point they faulted. this mean that the fault address would be a simple `guest_ctx.get_ip()` away. in the mean time, the Lucet signal handler learning how to be crossplatform broke this assumption: it now works by *overwriting* the guest's instruction pointer, swapping to the guest, and letting a function run. consequently, the guest instruction pointer is replaced and when a guest unwind is instigated after a guest faults, the return address before `initiate_unwind` (or `unwind_stub`, if present) will no longer be correct. libgcc_s will then fail to locate an FDE to describe the call frame above runtime-added unwind machinery, fail to unwind, and SIGABRT. the solution is quite simple: since the rip-accessing code is already handling a guest fault, we know the original faulting guest `rip` is preserved in the fault's `details`. insted of `guest_ctx.get_ip()`, get the address from `details.rip_addr`.
Configuration menu - View commit details
-
Copy full SHA for 6ddb7a3 - Browse repository at this point
Copy the full SHA 6ddb7a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for a0aa813 - Browse repository at this point
Copy the full SHA a0aa813View commit details -
Configuration menu - View commit details
-
Copy full SHA for bb27ee7 - Browse repository at this point
Copy the full SHA bb27ee7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6510c4c - Browse repository at this point
Copy the full SHA 6510c4cView commit details
Commits on Jun 23, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 486ae6a - Browse repository at this point
Copy the full SHA 486ae6aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4d68f0b - Browse repository at this point
Copy the full SHA 4d68f0bView commit details -
Configuration menu - View commit details
-
Copy full SHA for caa1152 - Browse repository at this point
Copy the full SHA caa1152View commit details
Commits on Jun 25, 2020
-
Configuration menu - View commit details
-
Copy full SHA for d10bd0a - Browse repository at this point
Copy the full SHA d10bd0aView commit details