git-intr-msg-stack
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sun, 3 Dec 2023 13:23:52 +0000 (14:23 +0100)
committerAurelien Jarno <aurel32@debian.org>
Sun, 3 Dec 2023 13:23:52 +0000 (14:23 +0100)
commitc30888df91f15c1b142f8eedcf8b7a7478d911d2
treee9fb2670835c03ecc6c6e2b00d41fda3fe089c41
parent9d49fc803fe7090e8d0c7e57a30b5d536726ea0a
git-intr-msg-stack

commit 69054cb2f08ee4ce061f503b20c1e1b343656595
Author: Sergey Bugaev <bugaevc@gmail.com>
Date:   Wed Mar 1 19:23:54 2023 +0300

    hurd: Remove the ecx kludge

    "We don't need it any more"

    The INTR_MSG_TRAP macro in intr-msg.h used to play little trick with
    the stack pointer: it would temporarily save the "real" stack pointer
    into ecx, while setting esp to point to just before the message buffer,
    and then invoke the mach_msg trap. This way, INTR_MSG_TRAP reused the
    on-stack arguments laid out for the containing call of
    _hurd_intr_rpc_mach_msg (), passing them to the mach_msg trap directly.

    This, however, required special support in hurdsig.c and trampoline.c,
    since they now had to recognize when a thread is inside the piece of
    code where esp doesn't point to the real tip of the stack, and handle
    this situation specially.

    Commit 1d20f33ff4fb634310f27493b7b87d0b20f4a0b0 has removed the actual
    temporary change of esp by actually re-pushing mach_msg arguments onto
    the stack, and popping them back at end. It did not, however, deal with
    the rest of "the ecx kludge" code in other files, resulting in potential
    crashes if a signal arrives in the middle of pushing arguments onto the
    stack.

    Fix that by removing "the ecx kludge". Instead, when we want a thread
    to skip the RPC, but cannot make just make it jump to after the trap
    since it's not done adjusting the stack yet, set the SYSRETURN register
    to MACH_SEND_INTERRUPTED (as we do anyway), and rely on the thread
    itself for detecting this case and skipping the RPC.

    This simplifies things somewhat and paves the way for a future x86_64
    port of this code.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
    Message-Id: <20230301162355.426887-1-bugaevc@gmail.com>

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-intr-msg-stack.diff
hurd/hurdsig.c
sysdeps/mach/hurd/i386/intr-msg.h
sysdeps/mach/hurd/i386/trampoline.c