Skip to content

Commit 01c535b

Browse files
committed
Update docs
Signed-off-by: Simon Davies <[email protected]>
1 parent ce989de commit 01c535b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Signal Handling in Hyperlight
22

3-
Hyperlight registers custom signal handlers to intercept and manage specific signals, primarily `SIGSYS` and `SIGRTMIN`. Here's an overview of the registration process:
4-
- **Preserving Old Handlers**: When registering a new signal handler, Hyperlight first retrieves and stores the existing handler using `OnceCell`. This allows Hyperlight to delegate signals to the original handler if necessary.
3+
Hyperlight registers custom signal handlers to intercept and manage specific signals, primarily `SIGSYS` , `SIGRTMIN` and `SIGSEGV` Here's an overview of the registration process:
4+
- **Preserving Old Handlers**: When registering a new signal handler, Hyperlight first retrieves and stores the existing handler using either `OnceCell` or a `static AtomicPtr` This allows Hyperlight to delegate signals to the original handler if necessary.
55
- **Custom Handlers**:
66
- **`SIGSYS` Handler**: Captures disallowed syscalls enforced by seccomp. If the signal originates from a hyperlight thread, Hyperlight logs the syscall details. Otherwise, it delegates the signal to the previously registered handler.
77
- **`SIGRTMIN` Handler**: Utilized for inter-thread signaling, such as execution cancellation. Similar to SIGSYS, it distinguishes between application and non-hyperlight threads to determine how to handle the signal.
8-
- **Thread Differentiation**: Hyperlight uses thread-local storage (IS_HYPERLIGHT_THREAD) to identify whether the current thread is a hyperlight thread. This distinction ensures that signals are handled appropriately based on the thread's role.
8+
- **`SIGSEGV` Handler**: Handles segmentation faults for dirty page tracking of host memory mapped into a VM. If the signal applies to an address that is mapped to a VM, it is processed by Hyperlight; otherwise, it is passed to the original handler.
99

1010
## Potential Issues and Considerations
1111

@@ -15,3 +15,14 @@ Hyperlight registers custom signal handlers to intercept and manage specific sig
1515
- **Invalidation of `old_handler`**: The stored old_handler reference may no longer point to a valid handler, causing undefined behavior when Hyperlight attempts to delegate signals.
1616
- **Loss of Custom Handling**: Hyperlight's custom handler might not be invoked as expected, disrupting its ability to enforce syscall restrictions or manage inter-thread signals.
1717

18+
### Debugging and Signal Handling
19+
20+
By default when debugging a host application/test/example with GDB or LLDB the debugger will handle the `SIGSEGV` signal, by breaking when it is rised to prevent this and let hyperlight hadnle the signal enter the following in the debug console:
21+
22+
#### LLDB
23+
24+
```process handle SIGSEGV -n true -p true -s false```
25+
26+
#### GDB
27+
28+
```handle SIGSEGV nostop noprint pass```

0 commit comments

Comments
 (0)