Re: [PATCH v2] hurd: Add expected abilist files for x86_64

2023-03-19 Thread Florian Weimer
* Sergey Bugaev: > On Sun, Mar 19, 2023 at 9:05 PM Florian Weimer wrote: >> You should consider creating a shlib-versions file with a baseline of >> 2.38, so that the obsolete Sun RPC symbols (and many others) are not >> compiled in. > > So *that's* how it's done! Thank you. > > Does the below lo

Re: [RFC PATCH 00/34] The rest of the x86_64-gnu port

2023-03-19 Thread Flávio Cruz
Nice work indeed Sergey! On Sun, Mar 19, 2023 at 12:44 PM Luca wrote: > Hi Sergey, > > this looks like a great work! > > Il 19/03/23 16:09, Sergey Bugaev ha scritto: > > I was unable to actually get it running on GNU Mach. It either never gets > > started, or crashes soon enough. The latter is a

[PATCH gnumach] Align the user stack correctly for 64 bit programs.

2023-03-19 Thread Flavio Cruz
* i386/i386/thread.h: Define STACK_ALIGN which is 16-byte for 64 bit programs as recommended by the System V AMD64 guidelines. * i386/i386/pcb.c: Use STACK_ALIGN to align the bootstrap arguments and ultimately the stack where the program starts on. * kern/bootstrap.c: Do not align arg_len here

[PATCH v2] hurd: Add expected abilist files for x86_64

2023-03-19 Thread Sergey Bugaev
On Sun, Mar 19, 2023 at 9:05 PM Florian Weimer wrote: > You should consider creating a shlib-versions file with a baseline of > 2.38, so that the obsolete Sun RPC symbols (and many others) are not > compiled in. So *that's* how it's done! Thank you. Does the below look reasonable? I've dropped l

Re: [RFC PATCH 00/34] The rest of the x86_64-gnu port

2023-03-19 Thread Luca
Il 19/03/23 18:39, Sergey Bugaev ha scritto: Once this works, you should be able to build ext2fs.static, exec.static and run a "hello-dynamic-glibc" test by replacing /hurd/startup, which is the first dynamically-linked executable started. Actually no, exec is the first dynamic executable alrea

Re: [RFC PATCH glibc 34/34] hurd: Add expected abilist files for x86_64

2023-03-19 Thread Florian Weimer
* Sergey Bugaev via Libc-alpha: > +GLIBC_2.2.6 __rpc_thread_createerr F > +GLIBC_2.2.6 __rpc_thread_svc_fdset F > +GLIBC_2.2.6 __rpc_thread_svc_max_pollfd F > +GLIBC_2.2.6 __rpc_thread_svc_pollfd F You should consider creating a shlib-versions file with a baseline of 2.38, so that the obsolete Su

Re: [RFC PATCH 00/34] The rest of the x86_64-gnu port

2023-03-19 Thread Sergey Bugaev
(un-cc-ing libc-alpha) > One reason for troubles in testing with gnumach is that rpc don't work > very well yet... Simple syscalls should work if you take my patch with > syscall64 v3, and also some simple rpcs, but in general I still see some > issues with the 64-bit message format and the mig-ge

Re: [RFC PATCH 00/34] The rest of the x86_64-gnu port

2023-03-19 Thread Luca
Hi Sergey, this looks like a great work! Il 19/03/23 16:09, Sergey Bugaev ha scritto: I was unable to actually get it running on GNU Mach. It either never gets started, or crashes soon enough. The latter is actually to be expected, since the kernel does not actually support i386_fsgs_base_state

Re: [RFC PATCH glibc 33/34] hurd: Create abilist files for lib{mach,hurd}user

2023-03-19 Thread Samuel Thibault
Sergey Bugaev, le dim. 19 mars 2023 18:39:20 +0300, a ecrit: > Yay! Can you believe just how glad I am to finally have completed it :D I think I do :) > > I don't have the time now to review the whole series, just a comment > > here: we don't really want to introduce abilist for lib{mach,hurd}use

Re: [RFC PATCH glibc 33/34] hurd: Create abilist files for lib{mach, hurd}user

2023-03-19 Thread Sergey Bugaev
On Sun, Mar 19, 2023 at 6:19 PM Samuel Thibault wrote: > > Hello, > > Thanks for this work! :D Yay! Can you believe just how glad I am to finally have completed it :D > I don't have the time now to review the whole series, just a comment > here: we don't really want to introduce abilist for lib{

Re: [RFC PATCH glibc 33/34] hurd: Create abilist files for lib{mach,hurd}user

2023-03-19 Thread Samuel Thibault
Hello, Thanks for this work! :D I don't have the time now to review the whole series, just a comment here: we don't really want to introduce abilist for lib{mach,hurd}user since their content will depend on the mach/hurd version glibc gets built against. Samuel Sergey Bugaev, le dim. 19 mars 20

[RFC PATCH glibc 21/34] x86_64: Add rtld-stpncpy & rtld-strncpy

2023-03-19 Thread Sergey Bugaev
Just like the other existing rtld-str* files, this provides rtld with usable versions of stpncpy and strncpy. Signed-off-by: Sergey Bugaev --- sysdeps/x86_64/multiarch/rtld-stpncpy.S | 18 ++ sysdeps/x86_64/multiarch/rtld-strncpy.S | 18 ++ 2 files changed, 36 ins

[RFC PATCH glibc 16/34] hurd: Add sys/ucontext.h and sigcontext.h for x86_64

2023-03-19 Thread Sergey Bugaev
This is based on the Linux port's version, but laid out to match Mach's struct i386_thread_state, much like the i386 version does. Signed-off-by: Sergey Bugaev --- I'm not very sure about the FP stuff, nor about any of this, really. Please do review. sysdeps/mach/hurd/x86_64/bits/sigcontext.h

[RFC PATCH glibc 17/34] hurd: Implement x86_64/intr-msg.h

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- This is a prelimenary version of intr-msg.h. I can't know whether or not it works until we can test it. The code relies on syscall preserving values of the registers used to pass syscall arguments. The code in SYSCALL_EXAMINE that just compares two bytes to the en

[RFC PATCH glibc 23/34] elf: Stop including tls.h in ldsodefs.h

2023-03-19 Thread Sergey Bugaev
Nothing in there needs tls.h Signed-off-by: Sergey Bugaev --- sysdeps/generic/ldsodefs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index c99dad77..5f21bc63 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@

[RFC PATCH glibc 06/34] hurd: Swap around two function calls

2023-03-19 Thread Sergey Bugaev
...to keep `sigexc' port initialization in one place, and match what the comments say. No functional change. Signed-off-by: Sergey Bugaev --- hurd/hurdfault.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c index a81e7280..4340897d

[RFC PATCH glibc 12/34] hurd: More 64-bit integer casting fixes

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/ioctl.c | 4 ++-- sysdeps/mach/hurd/x86/init-first.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c index 0f5de5d3..ab913a59 100644 --- a/sysdeps/mach/hurd/i

[RFC PATCH glibc 22/34] htl: Implement thread_set_pcsptp for x86_64

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/htl/pt-machdep.c | 73 +++ 1 file changed, 73 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/htl/pt-machdep.c diff --git a/sysdeps/mach/hurd/x86_64/htl/pt-machdep.c b/sysdeps/mach/hurd/x86_64/htl/pt-machde

[RFC PATCH glibc 04/34] hurd: Make exception subcode a long

2023-03-19 Thread Sergey Bugaev
On EXC_BAD_ACCESS, exception subcode is used to pass the faulting memory address, so it needs to be (at least) pointer-sized. Thus, make it into a long. This matches the corresponding change in GNU Mach. --- hurd/catch-exc.c | 2 +- hurd/hurd/signal.h | 5 +++-- hurd/hurdfault.c | 2 +- 3 file

[RFC PATCH glibc 33/34] hurd: Create abilist files for lib{mach, hurd}user

2023-03-19 Thread Sergey Bugaev
It looks like each specific port is supposed to provide abilist files for all the built shared objects in its most nested sysdeps directory. Do just that for libmachuser and libhurduser. This was done by running 'make update-abi' and then moving the generated files from sysdeps/mach/ and sysdeps/m

[RFC PATCH glibc 14/34] hurd: Move rtld-strncpy-c.c out of mach/hurd/

2023-03-19 Thread Sergey Bugaev
There's nothing Mach- or Hurd-specific about it; any port that ends up with rtld pulling in strncpy will need this. Signed-off-by: Sergey Bugaev --- sysdeps/{mach/hurd => }/i386/i686/multiarch/rtld-strncpy-c.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sysdeps/{mach/hurd => }/i

[RFC PATCH glibc 10/34] stdio-common: Fix building when !IS_IN (libc)

2023-03-19 Thread Sergey Bugaev
In this case, _itoa_word () is already defined inline in the header (see sysdeps/generic/_itoa.h), and the second definition causes an error. Signed-off-by: Sergey Bugaev --- stdio-common/_itoa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdio-common/_itoa.c b/stdio-common/_itoa.c in

[RFC PATCH glibc 27/34] hurd: Don't leak __hurd_reply_port0

2023-03-19 Thread Sergey Bugaev
Previously, once we set up TLS, we would implicitly switch from using __hurd_reply_port0 to reply_port inside the TCB, leaving the former unused. But we never deallocated it, so it got leaked. Instead, migrate the port into the new TCB's reply_port slot. This avoids both the port leak and an extra

[RFC PATCH glibc 24/34] hurd: Only check for TLS initialization inside rtld or in static builds

2023-03-19 Thread Sergey Bugaev
When glibc is built as a shared library, TLS is always initialized by the call of TLS_INIT_TP () macro made inside the dynamic loader, prior to running the main program (see dl-call_tls_init_tp.h). We can take advantage of this: we know for sure that __LIBC_NO_TLS () will evaluate to 0 in all other

[RFC PATCH glibc 30/34] hurd: Implement longjmp for x86_64

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/longjmp_chk.S | 134 + sysdeps/mach/hurd/x86_64/__longjmp.S | 102 2 files changed, 236 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/longjmp_chk.S create mode 100644 sysdeps

[RFC PATCH glibc 19/34] hurd: Move a couple of singal-related files to x86

2023-03-19 Thread Sergey Bugaev
These do not need any changes to be used on x86_64. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/{i386 => x86}/exc2signal.c | 0 sysdeps/mach/hurd/{i386 => x86}/signal-defines.sym | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sysdeps/mach/hurd/{i386 => x86}/exc2signal

[RFC PATCH glibc 13/34] x86-64: Disable prefer_map_32bit_exec tunable on non-Linux

2023-03-19 Thread Sergey Bugaev
While we could/should implement MAP_32BIT for the Hurd port by setting all the high bits of mask in a vm_map () call, neither MAP_32BIT nor glibc.cpu.prefer_map_32bit_exec exist on the Hurd as of now. Compile this code out to fix build failures. Signed-off-by: Sergey Bugaev --- sysdeps/x86/cpu-f

[RFC PATCH glibc 20/34] htl: Add tcb-offsets.sym for x86_64

2023-03-19 Thread Sergey Bugaev
The source code is the same as sysdeps/i386/htl/tcb-offsets.sym, but of course the produced tcb-offsets.h will be different. Signed-off-by: Sergey Bugaev --- sysdeps/x86_64/htl/Makefile| 20 sysdeps/x86_64/htl/tcb-offsets.sym | 8 2 files changed, 28 insert

[RFC PATCH glibc 08/34] hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rtld

2023-03-19 Thread Sergey Bugaev
hurd/lookup-retry.c is compiled into rtld, the dynamic linker/loader. To avoid pulling in file_set_size, file_utimens, tty/ctty stuff, more string/memory code (memmove, strncpy, strcpy), and more strtoul/itoa code, compile out support for O_TRUNC and FS_RETRY_MAGICAL when building hurd/lookup-retry

[RFC PATCH glibc 15/34] hurd: Use uintptr_t for register values in trampoline.c

2023-03-19 Thread Sergey Bugaev
This is more correct, if only because these fields are defined as having the type unsigned int in the Mach headers, so casting them to a signed int and then back is suboptimal. Also, remove an extra reassignment of uesp -- this is another remnant of the ecx kludge. Signed-off-by: Sergey Bugaev -

[RFC PATCH glibc 18/34] hurd: Port trampoline.c to x86_64

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- Same as for intr-msg.h, can't know whether this works until we try it. sysdeps/mach/hurd/{i386 => x86}/trampoline.c | 139 ++- 1 file changed, 132 insertions(+), 7 deletions(-) rename sysdeps/mach/hurd/{i386 => x86}/trampoline.c (71%) diff --gi

[RFC PATCH glibc 26/34] hurd: Remove __hurd_local_reply_port

2023-03-19 Thread Sergey Bugaev
Now that the signal code no longer accesses it, the only real user of it was mig-reply.c, so move the logic for managing the port there. If we're in SHARED and outside of rtld, we know that __LIBC_NO_TLS () always evaluates to 0, and a TLS reply port will always be used, not __hurd_reply_port0. St

[RFC PATCH glibc 07/34] hurd: Fix file name in #error

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- hurd/longjmp-ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hurd/longjmp-ts.c b/hurd/longjmp-ts.c index bc4add32..0032d747 100644 --- a/hurd/longjmp-ts.c +++ b/hurd/longjmp-ts.c @@ -27,5 +27,5 @@ _hurd_longjmp_thread_state (void *state, j

[RFC PATCH glibc 25/34] hurd: Improve reply port handling when exiting signal handlers

2023-03-19 Thread Sergey Bugaev
If we're doing signals, that means we've already got the signal thread running, and that implies TLS having been set up. So we know that __hurd_local_reply_port will resolve to THREAD_SELF->reply_port, and can access that directly using the THREAD_GETMEM and THREAD_SETMEM macros. This avoids potent

[RFC PATCH glibc 32/34] hurd: Implement sigreturn for x86_64

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/sigreturn.c | 155 +++ 1 file changed, 155 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/sigreturn.c diff --git a/sysdeps/mach/hurd/x86_64/sigreturn.c b/sysdeps/mach/hurd/x86_64/sigreturn.c new file m

[RFC PATCH 00/34] The rest of the x86_64-gnu port

2023-03-19 Thread Sergey Bugaev
Hello! (Naturally, the subject line is a reference to the "How to draw an owl" meme.) It's been more than a month since I've tried to run ./configure --host=x86_64-gnu and see what would come out of it, and here we are now: with these patches, glibc fully builds, and even somewhat "works"! On te

[RFC PATCH glibc 31/34] hurd: Microoptimize _hurd_self_sigstate ()

2023-03-19 Thread Sergey Bugaev
When THREAD_GETMEM is defined with inline assembly, the compiler may not optimize away the two reads of _hurd_sigstate. Help it out a little bit by only reading it once. This also makes for a slightly cleaner code. Signed-off-by: Sergey Bugaev --- hurd/hurd/signal.h | 8 +--- 1 file changed,

[RFC PATCH glibc 28/34] hurd: Implement _hurd_longjmp_thread_state for x86_64

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/longjmp-ts.c | 41 +++ 1 file changed, 41 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/longjmp-ts.c diff --git a/sysdeps/mach/hurd/x86_64/longjmp-ts.c b/sysdeps/mach/hurd/x86_64/longjmp-ts.c new file

[RFC PATCH glibc 29/34] hurd: Add vm_param.h for x86_64

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/vm_param.h | 24 1 file changed, 24 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/vm_param.h diff --git a/sysdeps/mach/hurd/x86_64/vm_param.h b/sysdeps/mach/hurd/x86_64/vm_param.h new file mode 10064

[RFC PATCH glibc 11/34] mach, hurd: Drop __libc_lock_self0

2023-03-19 Thread Sergey Bugaev
This was used for the value of libc-lock's owner when TLS is not yet set up, so THREAD_SELF can not be used. Since the value need not be anything specific -- it just has to be non-NULL -- we can just use a plain constant, such as (void *) 1, for this. This avoids accessing the symbol through GOT, a

[RFC PATCH gnumach 03/34] Make exception subcode a long

2023-03-19 Thread Sergey Bugaev
On EXC_BAD_ACCESS, exception subcode is used to pass the faulting memory address, so it needs to be (at least) pointer-sized. Thus, make it into a long. This requires matching changes in glibc and the Hurd. --- NOTE: Most of this was a pretty mechanical change, but I'm not very sure I got the exc

[RFC PATCH glibc 05/34] hurd: Remove __hurd_threadvar_stack_{offset, mask}

2023-03-19 Thread Sergey Bugaev
Noone is or should be using __hurd_threadvar_stack_{offset,mask}, we have proper TLS now. These two remaining variables are never set to anything other than zero, so any code that would try to use them as described would just dereference a zero pointer and crash. So remove them entirely. Signed-of

[RFC PATCH gnumach 02/34] Remove bootstrap.defs

2023-03-19 Thread Sergey Bugaev
As far as I can see, this file was imported in the very beginning of GNU Mach history, and unused since then. Nobody implements or uses this interface. GNU Mach uses a different way to pass the privileged ports to the bootstrap tasks: instead of the task(s) actively asking for the ports in an RPC,

[RFC PATCH glibc 09/34] hurd: Fix _hurd_setup_sighandler () signature

2023-03-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- hurd/trampoline.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hurd/trampoline.c b/hurd/trampoline.c index a0639a20..5bd8dec9 100644 --- a/hurd/trampoline.c +++ b/hurd/trampoline.c @@ -26,11 +26,11 @@ that structure. */ st

[RFC PATCH gnumach 01/34] Add i386_fsgs_base_state

2023-03-19 Thread Sergey Bugaev
--- i386/include/mach/i386/thread_status.h | 8 1 file changed, 8 insertions(+) diff --git a/i386/include/mach/i386/thread_status.h b/i386/include/mach/i386/thread_status.h index 3de22ff3..32e40686 100644 --- a/i386/include/mach/i386/thread_status.h +++ b/i386/include/mach/i386/thread_s