diff options
author | Luca Dariz <luca@orpolo.org> | 2023-04-19 21:47:02 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-01 02:00:28 +0200 |
commit | 660bc8ab3813737b3857648b7ec60d88494aeed1 (patch) | |
tree | 1566958542f4af9707992aa02faac3c925d08186 /x86_64/include | |
parent | 589735c3220793d1e9423bf6ec751b4625309aac (diff) | |
download | gnumach-660bc8ab3813737b3857648b7ec60d88494aeed1.tar.gz gnumach-660bc8ab3813737b3857648b7ec60d88494aeed1.tar.bz2 gnumach-660bc8ab3813737b3857648b7ec60d88494aeed1.zip |
x86_64: add 64-bit syscall entry point
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 start working on the 64-bit user
space.
* i386/i386/i386asm.sym: add more constants to fill pcb->iss
* i386/i386/ldt.c: configure 64-bit syscall entry point. We can just
check for the SEP bit as MSR are always available on x86_64.
* i386/i386/ldt.h: swap CS/DS segments order if !USER32 as required by
sysret
* i386/i386/locore.h: add syscall64 prototype
* i386/i386/msr.h: add MSR definitions and C read/write helpers
* i386/include/mach/i386/syscall_sw.h: remove old BSD_TRAP
* x86_64/Makefrag.am: selectively install syscall_sw.h depending on
USER32
* x86_64/include/syscall_sw.h: add entry point template from user
space
* x86_64/locore.S: implement syscall64 entry point and use it when a
64-bit user-space is configured
Message-Id: <20230419194703.410575-4-luca@orpolo.org>
Diffstat (limited to 'x86_64/include')
-rw-r--r-- | x86_64/include/syscall_sw.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/x86_64/include/syscall_sw.h b/x86_64/include/syscall_sw.h new file mode 100644 index 00000000..4e03f28c --- /dev/null +++ b/x86_64/include/syscall_sw.h @@ -0,0 +1,40 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +#ifndef _MACH_X86_64_SYSCALL_SW_H_ +#define _MACH_X86_64_SYSCALL_SW_H_ + +#include <mach/machine/asm.h> + +#define kernel_trap(trap_name,trap_number,number_args) \ +ENTRY(trap_name) \ + movq $ trap_number,%rax; \ + movq %rcx,%r10; \ + syscall; \ + ret; \ +END(trap_name) + +#endif /* _MACH_X86_64_SYSCALL_SW_H_ */ |