aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2021-10-18 00:43:23 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2021-10-18 00:50:41 +0200
commit1d20f33ff4fb634310f27493b7b87d0b20f4a0b0 (patch)
tree9155e9f1f1417168e8783c4fa97120ac181fe501 /sysdeps/mach
parent9d3c9a046a2d7cfc9cad18675612e5916c65d7d7 (diff)
downloadglibc-1d20f33ff4fb634310f27493b7b87d0b20f4a0b0.zip
glibc-1d20f33ff4fb634310f27493b7b87d0b20f4a0b0.tar.gz
glibc-1d20f33ff4fb634310f27493b7b87d0b20f4a0b0.tar.bz2
hurd: Fix intr-msg parameter/stack kludge
INTR_MSG_TRAP was tinkering with esp to make it point to _hurd_intr_rpc_mach_msg's parameters, and notably use (&msg)[-1] which is meaningless in C. Instead, just push the parameters on the stack, which also avoids leaving local variables of _hurd_intr_rpc_mach_msg below esp. We now also properly express that OPTION and TIMEOUT may be updated during the trap call.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/i386/intr-msg.h49
1 files changed, 39 insertions, 10 deletions
diff --git a/sysdeps/mach/hurd/i386/intr-msg.h b/sysdeps/mach/hurd/i386/intr-msg.h
index bd94aaf..ac3e5c0 100644
--- a/sysdeps/mach/hurd/i386/intr-msg.h
+++ b/sysdeps/mach/hurd/i386/intr-msg.h
@@ -21,8 +21,6 @@
to indicate that the signal thread might mutate them as part
of sending us to a signal handler. */
-/* After _hurd_intr_rpc_msg_about_to we need to make a last check of cancel, in
- case we got interrupted right before _hurd_intr_rpc_msg_about_to. */
#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify, cancel_p, intr_port_p) \
({ \
error_t err; \
@@ -31,21 +29,52 @@
".globl _hurd_intr_rpc_msg_do_trap\n" \
".globl _hurd_intr_rpc_msg_in_trap\n" \
".globl _hurd_intr_rpc_msg_sp_restored\n" \
- "_hurd_intr_rpc_msg_about_to: cmpl $0, %5\n" \
+ "_hurd_intr_rpc_msg_about_to:" \
+ /* We need to make a last check of cancel, in case we got interrupted
+ right before _hurd_intr_rpc_msg_about_to. */ \
+ " cmpl $0, %5\n" \
" jz _hurd_intr_rpc_msg_do\n" \
+ /* We got interrupted, note so and return EINTR. */ \
" movl $0, %3\n" \
" movl %6, %%eax\n" \
" jmp _hurd_intr_rpc_msg_sp_restored\n" \
- "_hurd_intr_rpc_msg_do: movl %%esp, %%ecx\n" \
- " .cfi_def_cfa_register %%ecx\n" \
- " leal %4, %%esp\n" \
+ "_hurd_intr_rpc_msg_do:" \
+ /* Ok, push the mach_msg_trap arguments. */ \
+ " pushl 24(%4)\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ " pushl %2\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ " pushl 16(%4)\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ " pushl 12(%4)\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ " pushl 8(%4)\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ " pushl %1\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ " pushl (%4)\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ " pushl $0\n" \
+ " .cfi_adjust_cfa_offset 4\n" \
+ /* TODO: remove this ecx kludge, we don't need it any more */ \
+ " movl %%esp, %%ecx\n" \
"_hurd_intr_rpc_msg_cx_sp: movl $-25, %%eax\n" \
"_hurd_intr_rpc_msg_do_trap: lcall $7, $0 # status in %0\n" \
- "_hurd_intr_rpc_msg_in_trap: movl %%ecx, %%esp\n" \
- " .cfi_def_cfa_register %%esp\n" \
+ "_hurd_intr_rpc_msg_in_trap:" \
+ /* Ok, clean the arguments and update OPTION and TIMEOUT. */ \
+ " addl $8, %%esp\n" \
+ " .cfi_adjust_cfa_offset -8\n" \
+ " popl %1\n" \
+ " .cfi_adjust_cfa_offset -4\n" \
+ " addl $12, %%esp\n" \
+ " .cfi_adjust_cfa_offset -12\n" \
+ " popl %2\n" \
+ " .cfi_adjust_cfa_offset -4\n" \
+ " addl $4, %%esp\n" \
+ " .cfi_adjust_cfa_offset -4\n" \
"_hurd_intr_rpc_msg_sp_restored:" \
- : "=a" (err), "+m" (option), "+m" (timeout), "=m" (*intr_port_p) \
- : "m" ((&msg)[-1]), "m" (*cancel_p), "i" (EINTR) \
+ : "=a" (err), "+r" (option), "+r" (timeout), "=m" (*intr_port_p) \
+ : "r" (&msg), "m" (*cancel_p), "i" (EINTR) \
: "ecx"); \
err; \
})