Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Luca Dariz
Il 28/02/23 15:14, Sergey Bugaev ha scritto: On Tue, Feb 28, 2023 at 4:26 PM Luca Dariz wrote: +/* check if we need to place some arguments on the stack */ +_syscall64_args_stack: +mov EXT(mach_trap_table)(%rax),%r10 /* get number of arguments */ +subq$6,%r10

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Luca Dariz
Il 28/02/23 07:39, Sergey Bugaev ha scritto: On Mon, Feb 27, 2023 at 11:46 PM Luca Dariz wrote: +static inline void wrmsr(uint32_t regaddr, uint64_t value) +{ +uint32_t low=(uint32_t)value, high=((uint32_t)(value >> 32)); I think it'd be more idiomatic in both GNU and Mach styles to put m

Re: [PATCH 1/2] hurd: Fully remove the ecx kludge

2023-02-28 Thread Samuel Thibault
Sergey Bugaev, le mar. 28 févr. 2023 22:44:08 +0300, a ecrit: > @@ -430,23 +429,11 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int > signo, int sigthread, > receive completes immediately or aborts. */ >abort_thread (ss, state, reply); > > - if (state->basic.PC >= (uintptr_t) &_

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Sergey Bugaev
On Wed, Mar 1, 2023 at 12:04 AM Samuel Thibault wrote: > That looks like pure luck :) That looks like mach_msg was overdesigned, if you ask me :) But at least we don't have mach_msg_overwrite, which has... 9 args! Sergey

Re: intr-msg / hurdsig looks broken, is my analysis correct?

2023-02-28 Thread Samuel Thibault
Sergey Bugaev, le mar. 28 févr. 2023 18:53:05 +0300, a ecrit: > Really, why would it matter whether eip is after > _hurd_intr_rpc_msg_about_to or not? What if it's 1 instruction before > that? We skip the call, pretending it was interrupted, but does it > really matter that we do that — can't we ju

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Samuel Thibault
Sergey Bugaev, le mar. 28 févr. 2023 18:15:45 +0300, a ecrit: > On Tue, Feb 28, 2023 at 5:37 PM Samuel Thibault > wrote: > > > -- unlike on Linux? > > > > ? Linux does put only 6 args in registers, too. > > It does not look like Linux has any syscalls that take 7 args or more, Oh, indeed! That

[PATCH 1/2] hurd: Fully remove the ecx kludge

2023-02-28 Thread Sergey Bugaev
"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

[PATCH 2/2] hurd: Fix some broken indentation

2023-02-28 Thread Sergey Bugaev
Also, fix a couple of typos. No functional change. Signed-off-by: Sergey Bugaev --- hurd/hurdsig.c | 93 +- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 3e759ae5..1c85b29f 100644 --- a/hurd/h

Re: intr-msg / hurdsig looks broken, is my analysis correct?

2023-02-28 Thread Sergey Bugaev
So I implemented this, and it seems to work — as in, signals arrive and handlers run. It's extremely unlikely that I managed to hit the interesting code path where eip is inside that piece of code, so who knows whether that works or not — especially given this has been apparently broken in glibc fo

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Sergey Bugaev
On Tue, Feb 28, 2023 at 5:37 PM Samuel Thibault wrote: > Now it also has another meaning: since it clobbers memory, gcc is > not allowed to keep values in registers, i.e. this is a memory > synchronization barrier concerning the compiler. If for instance we have > prepared some data in memory befo

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Samuel Thibault
Sergey Bugaev, le mar. 28 févr. 2023 17:14:05 +0300, a ecrit: > On Tue, Feb 28, 2023 at 4:26 PM Luca Dariz wrote: > > >> +/* check if we need to place some arguments on the stack */ > > >> +_syscall64_args_stack: > > >> +mov EXT(mach_trap_table)(%rax),%r10 /* get number of arguments >

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Samuel Thibault
Sergey Bugaev, le mar. 28 févr. 2023 10:45:47 +0300, a ecrit: > On Tue, Feb 28, 2023 at 10:18 AM Samuel Thibault > wrote: > > > > Sergey Bugaev, le mar. 28 févr. 2023 09:39:40 +0300, a ecrit: > > > > + : \ > > > > + : "c" (regadd

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Sergey Bugaev
On Tue, Feb 28, 2023 at 4:26 PM Luca Dariz wrote: > >> +/* check if we need to place some arguments on the stack */ > >> +_syscall64_args_stack: > >> +mov EXT(mach_trap_table)(%rax),%r10 /* get number of arguments */ > >> +subq$6,%r10 /* the first 6 args are alr

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Samuel Thibault
Luca Dariz, le mar. 28 févr. 2023 14:25:59 +0100, a ecrit: > Il 27/02/23 23:02, Samuel Thibault ha scritto: > > > +#if defined(__x86_64__) && ! defined(USER32) > > > +#define kernel_trap(trap_name,trap_number,number_args) \ > > > +ENTRY(trap_name) \ > > > + movq

Re: [PATCH 5/5] x86_64: add 64-bit syscall entry point

2023-02-28 Thread Luca Dariz
Il 27/02/23 23:02, Samuel Thibault ha scritto: Luca Dariz, le lun. 27 févr. 2023 21:45:01 +0100, a ecrit: diff --git a/i386/i386/ldt.h b/i386/i386/ldt.h index b15f11a5..4490f99f 100644 --- a/i386/i386/ldt.h +++ b/i386/i386/ldt.h @@ -45,9 +45,14 @@ #define USER_SCALL 0x07