From: Godmar Back <godmar@gmail.com>
To: William Tambe via Libc-help <libc-help@sourceware.org>
Subject: curiosity question about swapcontext libc implementation on x86_64
Date: Thu, 1 Feb 2024 10:23:37 -0500 [thread overview]
Message-ID: <CAB4+JYKx0+6r=pVzymV24O3LHSdVBCZUXJKM9LAmVkwEEgAJeA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 887 bytes --]
The implementation of the obsolescent makecontext/getcontext/swapcontext
family of functions on x86_64 [1] appears to save a selection of registers.
These include callee-saved regs like rbx, rbp, r12-r15, but also
caller-saved regs like rdi, rsi, rdx, rcx. On the floating point side, it
saves mxcsr, the x87 FPU state via fnstenv, but not the xmm SSE register.
All of these floating point registers are callee-saved based on the AMD64
ABI [2].
It also saves/restores the current signal mask.
Does anyone know why it saves this set of registers/signal mask? Why does
it save callee-saved registers, but not all of them?
- Godmar
[1]
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86_64/swapcontext.S;h=b2e0f19a9d57e5007b094037b4cf59868029fc36;hb=HEAD
[2]
https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build
next reply other threads:[~2024-02-01 15:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 15:23 Godmar Back [this message]
2024-02-25 11:27 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAB4+JYKx0+6r=pVzymV24O3LHSdVBCZUXJKM9LAmVkwEEgAJeA@mail.gmail.com' \
--to=godmar@gmail.com \
--cc=libc-help@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).