[PATCH] Make __mach_msg_destroy portable for x86_64

2023-04-29 Thread Flavio Cruz
We need to align on uintptr_t to make this work for x86_64, otherwise things will go wrong when RPCs return errors. --- mach/msg-destroy.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mach/msg-destroy.c b/mach/msg-destroy.c index 7429ecbc2d..0a8b46c895 100644 --- a

[PATCH] Define mig_strlen and __mig_strlen to support dynamically sized strings in hurd RPCs

2023-04-29 Thread Flavio Cruz
We make lib{mach,hurd}user.so call __mig_strlen which can be relocated before libc.so is relocated, similar to what is done with __mig_memcpy. --- mach/Makefile | 2 +- mach/Versions | 4 mach/mach/mig_support.h | 2 ++ mach/mig_strle

[DO NOT PUSH PATCH v3 6/6] TMP hurd: Lower BRK_START

2023-04-29 Thread Sergey Bugaev
...until gnumach learns to support higher addresses --- This is not meant to be pushed, but you're going to need this patch to run glibc on the current builds of gnumach. sysdeps/mach/hurd/x86_64/vm_param.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/x8

[PATCH v3 0/6] The remaining x86_64-gnu patches

2023-04-29 Thread Sergey Bugaev
These are the patches that I have locally that have not (yet) been pushed. Most of them I have already sent previously, but have made changes to since then. Please see the notes on individual patches. I'm putting "v3" on the whole series because some of the patches here have already been through v

[RFC PATCH v3 5/6] hurd: Make it possible to call memcpy very early

2023-04-29 Thread Sergey Bugaev
Normally, in static builds, the first code that runs is _start, in e.g. sysdeps/x86_64/start.S, which quickly calls __libc_start_main, passing it the argv etc. Among the first things __libc_start_main does is initializing the tunables (based on env), then CPU features, and then calls _dl_relocate_s

[RFC PATCH v3 3/6] hurd: Replace reply port with a dead name on failed interruption

2023-04-29 Thread Sergey Bugaev
If we're trying to interrupt an interruptible RPC, but the server fails to respond to our __interrupt_operation () call, we instead destroy the reply port we were expecting the reply to the RPC on. Instead of deallocating the name completely, replace it with a dead name, so the name won't get reus

[PATCH v3 4/6] hurd: Add expected abilist files for x86_64

2023-04-29 Thread Sergey Bugaev
These were created by creating stub files, running 'make update-abi', and reviewing the results. Also, set baseline ABI to GLIBC_2.38, the (upcoming) first glibc release to first have x86_64-gnu support. Signed-off-by: Sergey Bugaev --- Changes compared to v2: - __pthread_self is now in libc.so

[PATCH v3 2/6] hurd: Implement longjmp for x86_64

2023-04-29 Thread Sergey Bugaev
Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev --- I have checked that setjmp/longjmp actually works sucessfully, with both __longjmp and longjmp_chk. I have not been able to check w/ sigaltstack because we don't yet have the proc server and signals. Changes since v1: - drop the separat

[PATCH v3 1/6] hurd: Implement sigreturn for x86_64

2023-04-29 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- This incorporates back the fix made to the i386 version: we do need to call _hurd_self_sigstate () once after all. sysdeps/mach/hurd/x86_64/sigreturn.c | 162 +++ 1 file changed, 162 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_

Re: [PATCH gnumach] Use c_string for dev_name_t in the device subsystem.

2023-04-29 Thread Samuel Thibault
Applied, thanks! Flavio Cruz, le mer. 26 avril 2023 01:22:53 -0400, a ecrit: > Added device_open_new and device_open_new_request and reused the old MiG > ID for xxx_device_set_status which has not been in used in the past > decade. > > Note that device_open_new is gated on defining > DEVICE_ENABL

Re: [PATCH 3/3] Mark various cold functions as __COLD

2023-04-29 Thread Samuel Thibault
It looks sensible to me indeed, any opinion from somebody else? Sergey Bugaev, le sam. 29 avril 2023 16:12:23 +0300, a ecrit: > GCC docs explicitly list perror () as a good candidate for using > __attribute__ ((cold)). So apply __COLD to perror () and similar > functions. > > Signed-off-by: Se

Re: [PATCH 2/3] hurd: Mark error functions as __COLD

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:12:22 +0300, a ecrit: > This should hopefully hint the compiler that they are unlikely > to be called. > > Signed-off-by: Sergey Bugaev > --- > hurd/hurd.h| 2 +- > hurd/hurd/fd.h | 8 > 2 files changed, 5 insertions(+), 5 de

Re: [PATCH] cdefs.h: Define __COLD

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:20:53 +0300, a ecrit: > And of course right after I have sent it, I notice that I forgot the > "Not GCC or clang." case. > > Sergey > > -- >8 -- > > From 1b8c6563828399de563846525d0f525001f2d80d Mon Sep 17 00:00:00 2001 > From: Sergey Bug

Re: [PATCH 7/7] hurd: Fix FS_RETRY_MAGICAL "machtype" handling

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:13:54 +0300, a ecrit: > We need to set file_name, not update retryname. This is what the other > branches do. > > Before this change, any attempt to access such a file would segfault due > to file_name being unset: > > $ settrans -ac /tmp/

Re: [PATCH 6/7] hurd: Respect existing FD_CLOEXEC in S_msg_set_fd

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:13:53 +0300, a ecrit: > If the process has set the close-on-exec flag for the file descriptor, > it expects the file descriptor to get closed on exec, even if we replace > what the file descriptor refers to. > > Signed-off-by: Sergey Bugaev

Re: [PATCH 5/7] hurd: Don't leak the auth port in msg* RPCs

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:13:52 +0300, a ecrit: > The leak can be easily reproduced (and observed) using the portinfo > tool: > > $ portinfo -v $$ | grep task > 36: send task(1577)(self) (refs: 127) > $ portinfo -v $$ | grep task > 36: send task(1577)(self)

Re: [PATCH 4/7] hurd: Make _exit work during early boot-up

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:13:51 +0300, a ecrit: > If any of the early boot-up tasks calls exit () or returns from main (), > terminate it properly instead of crashing on trying to dereference > _hurd_ports and getting forcibly terminated by the kernel. > > We sadly

Re: [PATCH 3/7] hurd: Mark various conditions as unlikely

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:13:50 +0300, a ecrit: > Signed-off-by: Sergey Bugaev > --- > hurd/hurd/fd.h | 10 +- > hurd/hurd/signal.h | 4 ++-- > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h > index 2

Re: [PATCH 2/7] hurd: Move libc_hidden_def's around

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev via Libc-alpha, le sam. 29 avril 2023 16:13:49 +0300, a ecrit: > Each libc_hidden_def should be placed immediately next to its function, > not in some random unrelated place. > > No functional change. > > Fixes: 653d74f12abea144219af00400ed1f1ac5dfa79f > "hurd: Glo

Re: [PATCH 1/7] hurd: Simplify _hurd_critical_section_lock a bit

2023-04-29 Thread Samuel Thibault
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:13:48 +0300, a ecrit: > This block of code was doing exactly what _hurd_self_sigstate does; so > just call that and let it do its job. > > Signed-off-by: Sergey Bugaev > --- > hurd/hurd/signal.h | 14 +- > 1 file changed, 1 in

Re: Mach time device, or: I know why the network deadlocks!

2023-04-29 Thread Sergey Bugaev
On Sat, Apr 29, 2023 at 7:39 AM Flávio Cruz wrote: > This never happened to me. Probably because I don't have NTP installed > in my Hurd box? That might explain it :) But I can't be the only one who wants their Hurd VM to have a sane notion of the current time across suspend-wake cycles of the h

Re: [PATCH] cdefs.h: Define __COLD

2023-04-29 Thread Sergey Bugaev
And of course right after I have sent it, I notice that I forgot the "Not GCC or clang." case. Sergey -- >8 -- >From 1b8c6563828399de563846525d0f525001f2d80d Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Thu, 27 Apr 2023 17:42:11 +0300 Subject: [PATCH] cdefs.h: Define __COLD This expands

[PATCH 3/7] hurd: Mark various conditions as unlikely

2023-04-29 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- hurd/hurd/fd.h | 10 +- hurd/hurd/signal.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h index 241797bf..824b7dbb 100644 --- a/hurd/hurd/fd.h +++ b/hurd/hurd/fd.h @@ -73,18 +73,18 @@ _hurd_fd_

[PATCH 4/7] hurd: Make _exit work during early boot-up

2023-04-29 Thread Sergey Bugaev
If any of the early boot-up tasks calls exit () or returns from main (), terminate it properly instead of crashing on trying to dereference _hurd_ports and getting forcibly terminated by the kernel. We sadly cannot make the __USEPORT macro do the check for _hurd_ports being unset, because it evalu

[PATCH 7/7] hurd: Fix FS_RETRY_MAGICAL "machtype" handling

2023-04-29 Thread Sergey Bugaev
We need to set file_name, not update retryname. This is what the other branches do. Before this change, any attempt to access such a file would segfault due to file_name being unset: $ settrans -ac /tmp/my-machtype /hurd/magic machtype $ cat /tmp/my-machtype Segmentation fault Checked on i686-gn

[PATCH 6/7] hurd: Respect existing FD_CLOEXEC in S_msg_set_fd

2023-04-29 Thread Sergey Bugaev
If the process has set the close-on-exec flag for the file descriptor, it expects the file descriptor to get closed on exec, even if we replace what the file descriptor refers to. Signed-off-by: Sergey Bugaev --- hurd/hurdmsg.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff -

[PATCH 5/7] hurd: Don't leak the auth port in msg* RPCs

2023-04-29 Thread Sergey Bugaev
The leak can be easily reproduced (and observed) using the portinfo tool: $ portinfo -v $$ | grep task 36: send task(1577)(self) (refs: 127) $ portinfo -v $$ | grep task 36: send task(1577)(self) (refs: 253) $ portinfo -v $$ | grep task 36: send task(1577)(self) (refs: 379) $ portinfo

[PATCH 2/7] hurd: Move libc_hidden_def's around

2023-04-29 Thread Sergey Bugaev
Each libc_hidden_def should be placed immediately next to its function, not in some random unrelated place. No functional change. Fixes: 653d74f12abea144219af00400ed1f1ac5dfa79f "hurd: Global signal disposition" Signed-off-by: Sergey Bugaev --- hurd/hurdsig.c | 9 + 1 file changed, 5 i

[PATCH 1/7] hurd: Simplify _hurd_critical_section_lock a bit

2023-04-29 Thread Sergey Bugaev
This block of code was doing exactly what _hurd_self_sigstate does; so just call that and let it do its job. Signed-off-by: Sergey Bugaev --- hurd/hurd/signal.h | 14 +- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index 662e95

[PATCH 1/3] cdefs.h: Define __COLD

2023-04-29 Thread Sergey Bugaev
This expands to __attribute__ ((cold)) when supported. It should be used to mark up functions that are invoked rarely. Signed-off-by: Sergey Bugaev --- I can change __COLD to __attribute_cold__ if that is preferred. misc/sys/cdefs.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/mis

[PATCH 2/3] hurd: Mark error functions as __COLD

2023-04-29 Thread Sergey Bugaev
This should hopefully hint the compiler that they are unlikely to be called. Signed-off-by: Sergey Bugaev --- hurd/hurd.h| 2 +- hurd/hurd/fd.h | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hurd/hurd.h b/hurd/hurd.h index eca4abb7..06f00e93 100644 --- a/hurd/hu

[PATCH 3/3] Mark various cold functions as __COLD

2023-04-29 Thread Sergey Bugaev
GCC docs explicitly list perror () as a good candidate for using __attribute__ ((cold)). So apply __COLD to perror () and similar functions. Signed-off-by: Sergey Bugaev --- include/error.h | 4 ++-- libio/stdio.h | 2 +- misc/err.h | 12 ++-- misc/error.h| 4 ++-- 4 files