On 5 Mar 2023, at 20:46, Sergey Bugaev wrote:
>
> Speaking of wrapping the syscall and INTR_MSG_TRAP, I might need a
> little help — is there a proper way to tell GCC that my inline
> assembly needs a specific register as input _and_ clobbers it? In
> Rust, this would be, for instance,
>
> asm!(
Speaking of wrapping the syscall and INTR_MSG_TRAP, I might need a
little help — is there a proper way to tell GCC that my inline
assembly needs a specific register as input _and_ clobbers it? In
Rust, this would be, for instance,
asm!("whatever", inout("rdi") msg => _)
but GCC doesn't like
asm
Hello,
Sergey Bugaev, le dim. 05 mars 2023 23:12:42 +0300, a ecrit:
> On Wed, Mar 1, 2023 at 9:44 AM Luca Dariz wrote:
> > Il 28/02/23 15:14, Sergey Bugaev ha scritto:
> > > - nothing else is clobbered, in particular not rflags (or is the
> > > "reserved" half of rflags clobbered?) and not the re
On Wed, Mar 1, 2023 at 9:44 AM Luca Dariz wrote:
> Il 28/02/23 15:14, Sergey Bugaev ha scritto:
> > - nothing else is clobbered, in particular not rflags (or is the
> > "reserved" half of rflags clobbered?) and not the registers that
> > contain args
>
> if we follow the usual calling conventions,
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
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
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
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
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
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
>
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
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
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
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
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" (regaddr), "a" (low), "d" (high) \
> > > + : "memory"
Sergey Bugaev, le mar. 28 févr. 2023 09:39:40 +0300, a ecrit:
> > + : \
> > + : "c" (regaddr), "a" (low), "d" (high) \
> > + : "memory" \
> > +);
> > +}
>
> Why "memory" here? C
> But then glibc does not actually use mach/syscall_sw.h, it has its own
> syscall impl
Uh, actually looks like it does both. Fun! :)
Sergey
On Mon, Feb 27, 2023 at 11:46 PM Luca Dariz wrote:
>
> While theoretically we could still use the same call gate as for
> 32-bit userspace, it doesn't seem very common, and gcc seems to not
> encode properly the instruction. Instead we use syscall/sysret as
> other kernels (e.g. XNU,Linux). This v
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/* system call gate */
> #ifdef __x86_6
While theoretically we could still use the same call gate as for
32-bit userspace, it doesn't seem very common, and gcc seems to not
encode properly the instruction. Instead we use syscall/sysret as
other kernels (e.g. XNU,Linux). This version still has some
limitations, but should be enough to sta
20 matches
Mail list logo