]> xenbits.xensource.com Git - unikraft/libs/musl.git/commit
Remove clone patches and use our own defined clone assembly wrappers
authorSergiu Moga <sergiu@unikraft.io>
Mon, 24 Mar 2025 17:26:12 +0000 (19:26 +0200)
committerMichalis Pappas <michalis@unikraft.io>
Tue, 22 Apr 2025 08:18:53 +0000 (10:18 +0200)
commit12e7d61e322a707252531b7704a5ea288b788ebd
tree53e458cdbac51f21c894d7d57f2562a5719a0f93
parentfb1a30557992773beade4e37413df1355edf0c4b
Remove clone patches and use our own defined clone assembly wrappers

We are now using our own `__clone` assembly wrappers in the unikernel
so drop current `__clone` assembly functions that translate libc wrapper
arguments to syscall arguments and instead copy/reuse those defined by
us in the core repository.

Do this copy-paste so that in case if int the future there will appear
differences between what we do in the core in those wrappers and what
we need for musl, the musl wrappers stay the same.

WARNING: There is, however, a very notable difference.

There is a bug in our current native/musl glue code where there is
a mismatch between what we do with TLS size/alignment and what musl
does.

To avoid it (and possibly unknowingly break other things) we have to
keep the forced alignment of the child stack.

This bug has always existed, including in the clone wrapper we are
replacing which also did this alignment. The wrapper claimed something
about `movaps` that is not entirely true. Essentially, because of an
old clone patch (part of the same series that ported musl clone
to Unikraft) that also patches `pthread_create` claiming Unikraft needs
an aligned TLS (for some reason we do not yet know), the clone child
stack ends up misaligned by 8, which causes a `movaps` that somewhere
along the line tries to store something at `some_aligned_offset(%rbp)`
to generate a #GP because rbp itself is not aligned.
To workaround this, back then this was the solution: a forced child
stack alignment. So keep this workaround for now, and debug this ASAP.

As for why we have this alignment for ARM64 as well, I can not be
sure, but I guess it simply aligned itself with the implementation of
x86 since it was introduced afterwards. Besides, it also makes use
of the same pthread_create code. Thus, keep aligning stuff for ARM64
as well.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #86
22 files changed:
Makefile.uk
Makefile.uk.musl.thread
arch/arm64/__clone.S [new file with mode: 0644]
arch/x86_64/__clone.S [new file with mode: 0644]
patches/0013-Comment-macros-to-stop-using-VDSO.patch [new file with mode: 0644]
patches/0013-This-is-the-clone-wrapper-that-musl-uses-for-x86_64.patch [deleted file]
patches/0014-Comment-macros-to-stop-using-VDSO.patch [deleted file]
patches/0014-include-Use-function-declaration-for-getdents64.patch [new file with mode: 0644]
patches/0015-Modify-clone-wrapper.patch [deleted file]
patches/0015-Use-uk_syscall_r_for_alt_socketcall-patch.patch [new file with mode: 0644]
patches/0016-Use-ulong-in-ioctl.patch [new file with mode: 0644]
patches/0017-include-Use-function-declaration-for-getdents64.patch [deleted file]
patches/0017-locale-iconv-Add-character-map-option.patch [new file with mode: 0644]
patches/0018-Use-uk_syscall_r_for_alt_socketcall-patch.patch [deleted file]
patches/0018-prlimit64_conflict.patch [new file with mode: 0644]
patches/0019-Use-ulong-in-ioctl-definition.patch [new file with mode: 0644]
patches/0019-Use-ulong-in-ioctl.patch [deleted file]
patches/0020-Add-syscall-function-prototype.patch [new file with mode: 0644]
patches/0020-Use-ulong-in-ioctl-definition.patch [deleted file]
patches/0020-locale-iconv-Add-character-map-option.patch [deleted file]
patches/0020-prlimit64_conflict.patch [deleted file]
patches/0021-Add-syscall-function-prototype.patch [deleted file]