[PATCH 15/15] enable syscalls on x86_64

2022-06-28 Thread Luca Dariz
Signed-off-by: Luca Dariz --- x86_64/locore.S | 3 --- 1 file changed, 3 deletions(-) diff --git a/x86_64/locore.S b/x86_64/locore.S index 198ac40a..615a2105 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -1056,9 +1056,6 @@ syscall_entry_2: pushq %rax/* save

[PATCH 08/15] use port name type in mach_port_names()

2022-06-28 Thread Luca Dariz
* ipc/mach_port.c: use mach_port_name_t instead of mach_port_t, since they could have different size. Fortunately we can keep the same optimization about allocationg memory, since mach_port_type_t has the same size as a name. Signed-off-by: Luca Dariz --- ipc/mach_port.c | 12 ++--

[PATCH 04/15] compute mach port size from the corresponding type

2022-06-28 Thread Luca Dariz
* ipc/ipc_machdep.h: re-define PORT_T_SIZE_IN_BITS to be computed from mach_port_t instead of being hardcoded. Signed-off-by: Luca Dariz --- ipc/ipc_machdep.h | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ipc/ipc_machdep.h b/ipc/ipc_machdep.h index c205ba45..

[PATCH 00/15] Add preliminary support for 32-bit userspace on a x86_64 kernel

2022-06-28 Thread Luca Dariz
This patch set contains three kind of changes: * changes for IPC on x86_64 (e.g. msg alignment, copyin/copyout) * 32-bit userland support on 64-bit kernel (e.g. exception stack alignment) * minor fixes and cleanup This is just a preliminary version, not everything is working yet. I've tested th

[PATCH 12/15] fix warnings for 32 bit builds

2022-06-28 Thread Luca Dariz
Signed-off-by: Luca Dariz --- device/cirbuf.c| 4 ++-- i386/i386/debug_i386.c | 1 + i386/i386at/biosmem.c | 2 -- i386/i386at/com.c | 2 +- i386/i386at/mem.c | 1 + kern/boot_script.c | 1 + kern/bootstrap.h | 5 - kern/exception.c | 1 + vm/vm_debug.c

[PATCH 14/15] hack vm memory object proxy creation for vm arrays

2022-06-28 Thread Luca Dariz
* vm/memory_object_proxy.c: truncate vm array types as if they were the rpc_ version because MIG can't handle that. This rpc can't handle more than one element anyway. Note that the same issue with vm arrays is present at least with syscall emulation, but that functionality seems unused for no

[PATCH 13/15] cleanup headers in printf.c

2022-06-28 Thread Luca Dariz
* kern/printf.c: remove unnecessary #include and reorder This allows the file to be reused for minimal user-space tests. Signed-off-by: Luca Dariz --- kern/printf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/printf.c b/kern/printf.c index 50f23623..cbc27ae6 100

[PATCH 10/15] x86_64: expand and shrink messages in copy{in, out}msg routines

2022-06-28 Thread Luca Dariz
* i386/i386/copy_user.h: new file to handle 32/64 bit differences (currently only msg_usize()) * include/mach/message.h: add mach_msg_user_header_t using port names instead of ports * ipc/ipc_kmsg.c: - use mach_msg_user_header_t * ipc/ipc_mqueue.c: use msg_usize() to check if we can actually

[PATCH 11/15] update syscall signature with rpc_vm_* and mach_port_name_t

2022-06-28 Thread Luca Dariz
* i386/i386/copy_user.h: add copyin/copyout helpers for ports and vm addresses. * include/mach/mach_types.h: replace mach_port_t with mach_port_name_t * kern/ipc_host.c: Likewise * kern/ipc_tt.c: Likewise * kern/ipc_tt.h: Likewise * kern/syscall_sw.c Likewise * kern/syscall_subr.c Likewise * kern

[PATCH 09/15] x86_64: fix exception stack alignment

2022-06-28 Thread Luca Dariz
* i386/i386/pcb.c: - increase alignment of pcb cache to 16 - ensure the stack is properly aligned when switching ktss * i386/i386/thread.h: - add padding tomake iss field end aligned to 16 bytes * i386/i386/trap.c: - ensure the state we get after the trap points to the correct place in

[PATCH 06/15] kmsg: fix msg body alignment

2022-06-28 Thread Luca Dariz
* ipc/ipc_kmsg.c: align msg body to 4 bytes as done in mig Signed-off-by: Luca Dariz --- ipc/ipc_kmsg.c | 49 ++--- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index b9d29853..09801924 100644 --- a/ip

[PATCH 05/15] sign-extend mask in vm_map() with 32-bit userspace

2022-06-28 Thread Luca Dariz
* vm/vm_user.c: sign-extend mask with USER32 Signed-off-by: Luca Dariz --- vm/vm_user.c | 5 + 1 file changed, 5 insertions(+) diff --git a/vm/vm_user.c b/vm/vm_user.c index ad1fa75d..81c87d78 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -338,6 +338,11 @@ kern_return_t vm_map( if

[PATCH 07/15] fix host_info structure definition

2022-06-28 Thread Luca Dariz
* include/mach/host_info.h: replace vm_size_t with rpc_ version for 64 bit compatibility. Ideally it should use phys_addr_t or another unit like KB or MB Signed-off-by: Luca Dariz --- include/mach/host_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mach/ho

[PATCH 02/15] simplify ipc_kmsg_copyout_body() usage

2022-06-28 Thread Luca Dariz
* ipc/ipc_kmsg.h: change prototype of ipc_kmsg_copyout_body() * ipc/ipc_kmsg.c: change prototype and usage of ipc_kmsg_copyout_body() by incorporating common code * ipc/mach_msg.c: change usage of ipc_kmsg_copyout_body() Signed-off-by: Luca Dariz --- ipc/ipc_kmsg.c | 24 ---

[PATCH 03/15] fix argument passing to bootstrap modules

2022-06-28 Thread Luca Dariz
* kern/bootstrap.c: use rpc_ vm types to put the bootstrap module arguments on the stack, make it consistent with user-space types. Signed-off-by: Luca Dariz --- kern/bootstrap.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/kern/bootstrap.c b/kern

[PATCH 01/15] fix rpc types for KERNEL_USER stubs

2022-06-28 Thread Luca Dariz
* include/mach/mach_types.defs: use rpc_ vm types for KERNEL_USER stubs. This change fixes two use cases: * internal rpc, e.g. when a memory object is initialized as a consequence of vm_map(); for example, the bootstrap modules use the "time" kernel device and memory-map it during startup. Thi

[PATCH 1/3] fix message fields alignment for 64 bit

2022-06-28 Thread Luca Dariz
On x86_64 alignment of structures is different, as the pointer size is different. For simplicity we keep the same 4-byte alignment as used on 32-bit. This simplifies the support for 32-bit rpc on 64-bit kernels, and also it seems not worth as an optimization, as we would need to add more code in t

[PATCH 0/3] enforce alignment of message body

2022-06-28 Thread Luca Dariz
The patches to MIG improve support for running on a 64-bit kernel, by keeping the same alignment of 32-bit kernels. They are an extension of the previous patch set: https://mail.gnu.org/archive/html/bug-hurd/2022-04/msg00010.html Luca Dariz (3): fix message fields alignment for 64 bit add c

[PATCH 3/3] fill msg size in the header for user stubs

2022-06-28 Thread Luca Dariz
* user.c: - adjust comment in generated file - set msgh_size with the same value passed to mach_msg() Signed-off-by: Luca Dariz --- user.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/user.c b/user.c index 9a84fe4..886198b 100644 --- a/user.c +++ b/user.c @@ -159,

[PATCH 2/3] add check for whole message size

2022-06-28 Thread Luca Dariz
* user.c: ensure fixed-length messages have the correct size. In addition to the single-fields check, this also include padding. Signed-off-by: Luca Dariz --- user.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/user.c b/user.c index 9aff07c..9a84fe4 100644 --- a/us