summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorDrew Stratford <drewstratford@outlook.com>2019-09-18 01:41:42 +1200
committerAndreas Kling <awesomekling@gmail.com>2019-09-17 16:00:37 +0200
commit6e51ebad8ca1ec991f9aca93ddbfda46b54e313a (patch)
tree390074511bcc4dace5b2ec454ac2da607181c5fb /Kernel
parent224fbb7910a67943d34710c9b020fb91a9396914 (diff)
downloadserenity-6e51ebad8ca1ec991f9aca93ddbfda46b54e313a.zip
Kernel: Stop hardcoding syscall in signal trampoline.
We now no longer hardcode the sigreturn syscall in the signal trampoline. Because of the way inline asm inputs work, I've had to enclose the trampoline in the function signal_trampoline_dummy.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index ed999e4ad5..679e092a3a 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -793,26 +793,29 @@ void Process::sys$exit(int status)
ASSERT_NOT_REACHED();
}
-// The trampoline preserves the current eax, pushes the signal code and
-// then calls the signal handler. We do this because, when interrupting a
-// blocking syscall, that syscall may return some special error code in eax;
-// This error code would likely be overwritten by the signal handler, so it's
-// neccessary to preserve it here.
-asm(
- ".intel_syntax noprefix\n"
- "asm_signal_trampoline:\n"
- "push ebp\n"
- "mov ebp, esp\n"
- "push eax\n" // we have to store eax 'cause it might be the return value from a syscall
- "sub esp, 4\n" // align the stack to 16 bytes
- "mov eax, [ebp+12]\n" // push the signal code
- "push eax\n"
- "call [ebp+8]\n" // call the signal handler
- "add esp, 8\n"
- "mov eax, 0x2d\n" // FIXME: We shouldn't be hardcoding this.
- "int 0x82\n" // sigreturn syscall
- "asm_signal_trampoline_end:\n"
- ".att_syntax");
+void signal_trampoline_dummy(void)
+{
+ // The trampoline preserves the current eax, pushes the signal code and
+ // then calls the signal handler. We do this because, when interrupting a
+ // blocking syscall, that syscall may return some special error code in eax;
+ // This error code would likely be overwritten by the signal handler, so it's
+ // neccessary to preserve it here.
+ asm(
+ ".intel_syntax noprefix\n"
+ "asm_signal_trampoline:\n"
+ "push ebp\n"
+ "mov ebp, esp\n"
+ "push eax\n" // we have to store eax 'cause it might be the return value from a syscall
+ "sub esp, 4\n" // align the stack to 16 bytes
+ "mov eax, [ebp+12]\n" // push the signal code
+ "push eax\n"
+ "call [ebp+8]\n" // call the signal handler
+ "add esp, 8\n"
+ "mov eax, %P0\n"
+ "int 0x82\n" // sigreturn syscall
+ "asm_signal_trampoline_end:\n"
+ ".att_syntax" ::"i"(Syscall::SC_sigreturn));
+}
extern "C" void asm_signal_trampoline(void);
extern "C" void asm_signal_trampoline_end(void);