[PATCH] add some qemu debugging notes

2022-01-26 Thread Luca Dariz
Signed-off-by: Luca Dariz --- microkernel/mach/gnumach/debugging.mdwn | 48 - 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/microkernel/mach/gnumach/debugging.mdwn b/microkernel/mach/gnumach/debugging.mdwn index 9534c758..a134b618 100644 --- a/microkernel

Re: Asking help for a little project

2022-01-27 Thread Luca dariz
Hi! Il 27/01/22 09:49, Alessandro Sangiuliano ha scritto: So assuming the situation where my custom name server is booting near the hurd as a module from grub, how to get the other tasks to resume them? I think there could be two ways: * pass the task ports of all other tasks from the command

[PATCH 2/6] cleanup multiboot

2022-01-28 Thread Luca Dariz
* use _raw_ structs where we refer to the bootloader-provided data * remove unused structures * fix 64 bit boot Signed-off-by: Luca Dariz --- Makefrag.am| 1 - i386/i386at/model_dep.c| 23 +++--- i386/include/mach/i386/multiboot.h | 108

[PATCH 6/6] fix Task State Segment layout for 64 bit

2022-01-28 Thread Luca Dariz
Signed-off-by: Luca Dariz --- i386/i386/i386asm.sym | 4 i386/i386/ktss.c | 8 ++-- i386/i386/pcb.c | 4 i386/i386/tss.h | 24 ++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym

[PATCH 0/6] Add initial support for booting x86_64 from grub

2022-01-28 Thread Luca Dariz
tion for x86_64 seems to fail currently, and we should fix mig types for this. To test these patches, you can revert for example to this commit: 63ed32b1 mach_i386: include MACH_I386_IMPORTS I think however it's better to have this part reviewed, and address the mig issues in another r

[PATCH 1/6] add support for booting from grub with x86_64

2022-01-28 Thread Luca Dariz
ed by Linux drivers * enable also write page access check in kernel mode Signed-off-by: Luca Dariz --- configure.ac | 3 +- i386/configfrag.ac | 2 + i386/i386/vm_param.h | 4 +- i386/intel/pmap.c| 4 +- i386/intel/pmap.h| 4 + x86_64/Makefrag.am | 18 +++- x86_64/boot

[PATCH 5/6] enable user access

2022-01-28 Thread Luca Dariz
The pmap module is a bit limited on 64 bit paging, so this should be refined when we'll be able to use addresses over 4G. Signed-off-by: Luca Dariz --- i386/intel/pmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 918

[PATCH 3/6] fix register corruption in irq on qemu

2022-01-28 Thread Luca Dariz
it seems rbx is corrupted during interrupt handlers. This appears on first call to thread_continue() Signed-off-by: Luca Dariz --- x86_64/interrupt.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x86_64/interrupt.S b/x86_64/interrupt.S index eab643a5..4ea849af 100644 --- a/x86_64

[PATCH 4/6] fix console setting from cmdline

2022-01-28 Thread Luca Dariz
The leading space prevents it working if console=comX is the only argument. Signed-off-by: Luca Dariz --- i386/i386at/com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 3402a025..d1de51c0 100644 --- a/i386/i386at/com.c +++ b

[PATCH v2 0/6] Add initial support for booting x86_64 from grub

2022-02-05 Thread Luca Dariz
for write access in PDP table, it's not impacting current 32-bit builds (non-PAE) * updated command line fix for console=comX * better fix for rbx corruption in x86_64/interrupt.S * improved x86_64/boothdr.S, removing most magic numbers or adding an explanatory comment Luca Dariz (6): add

[PATCH 1/6] add support for booting from grub with x86_64

2022-02-05 Thread Luca Dariz
AE-enabled kernels, mandatory for x86_64. On xen platform it seems to be handled differently Signed-off-by: Luca Dariz --- configure.ac | 3 +- i386/configfrag.ac| 2 + i386/i386/i386asm.sym | 1 + i386/i386/vm_param.h | 2 +- i386/intel/pmap.c | 4 +- i386/in

[PATCH 3/6] fix register corruption in irq on qemu

2022-02-05 Thread Luca Dariz
rbx was used to compute the irq index in iunit and ivect arrays, however it should be preserved by pushing it in to the stack. As a solution, we use rax instead, that is preserved across function calls and is not used as a function argument. Signed-off-by: Luca Dariz --- x86_64/interrupt.S

[PATCH 6/6] fix Task State Segment layout for 64 bit

2022-02-05 Thread Luca Dariz
Signed-off-by: Luca Dariz --- i386/i386/i386asm.sym | 4 i386/i386/ktss.c | 8 ++-- i386/i386/pcb.c | 4 i386/i386/tss.h | 24 ++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym

[PATCH 4/6] fix console setting from cmdline

2022-02-05 Thread Luca Dariz
The leading space prevents it working if console=comX is the only argument, so handle this case separately. Signed-off-by: Luca Dariz --- i386/i386at/com.c | 5 + 1 file changed, 5 insertions(+) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 3402a025..fb291b87 100644 --- a/i386

[PATCH 2/6] cleanup multiboot

2022-02-05 Thread Luca Dariz
* use _raw_ structs where we refer to the bootloader-provided data * remove unused structures * fix 64 bit boot Signed-off-by: Luca Dariz --- Makefrag.am| 1 - i386/i386at/model_dep.c| 23 +++--- i386/include/mach/i386/multiboot.h | 108

[PATCH 5/6] enable user access

2022-02-05 Thread Luca Dariz
The pmap module is a bit limited on 64 bit paging, so this should be refined when we'll be able to use addresses over 4G. Signed-off-by: Luca Dariz --- i386/intel/pmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index d0b

[PATCH 0/2] refine architecture-specific data types on gnumach

2022-04-03 Thread Luca Dariz
adaptation the code will still work thanks to the implicit 32-to-64 extension, but it is a nice cleanup. Luca Dariz (2): add port name types add rpc_versions for vm types i386/include/mach/i386/vm_types.h | 37 +++ include/mach/mach_port.defs | 6

[PATCH 1/2] add port name types

2022-04-03 Thread Luca Dariz
d the regular header, so compilation fails. Signed-off-by: Luca Dariz --- include/mach/mach_port.defs | 6 ++ include/mach/port.h | 36 +--- include/mach/std_types.defs | 6 ++ kern/thread.c | 4 ++-- kern/thread.h

[PATCH 1/2] add separate port_size and mach_port_name_size definitions

2022-04-03 Thread Luca Dariz
bug-hurd/2012-04/msg00000.html Signed-off-by: Luca Dariz --- cpu.sym | 4 global.c | 4 global.h | 3 +++ lexxer.l | 24 parser.y | 7 +++ type.c | 10 +- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/cpu.sym b/cpu.sym index

[PATCH 2/2] add rpc_versions for vm types

2022-04-03 Thread Luca Dariz
change the user-space interface is somehow fixed, i.e. it can't support 32-bit and 64-bit tasks at the same time. If this would be needed at some point, this change needs to be reworked. Signed-off-by: Luca Dariz --- i386/include/mach/i386/vm_types.h | 37 +++ include

[PATCH 2/2] improve error message

2022-04-03 Thread Luca Dariz
* parser.y: add information about type names Signed-off-by: Luca Dariz --- parser.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parser.y b/parser.y index 8d6b2aa..8521a84 100644 --- a/parser.y +++ b/parser.y @@ -526,8 +526,8 @@ IPCType

[PATCH 0/2] refine architecture-specific data types on mig

2022-04-03 Thread Luca Dariz
These patches nees the mach_port_name_t type defined in gnumach headers in the other patch set. Luca Dariz (2): add separate port_size and mach_port_name_size definitions improve error message cpu.sym | 4 global.c | 4 global.h | 3 +++ lexxer.l | 24

[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

[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

[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

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

2022-06-28 Thread Luca Dariz
the ipc_kmsg* routines. * routine.c: align both short and long descriptors * utils.c: use a fixed alignment for data fields in structures representing messages. Signed-off-by: Luca Dariz --- routine.c | 3 +-- utils.c | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a

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

2022-06-28 Thread Luca Dariz
ng startup. This triggers a kernel-side rpc to initialize the memory object and install the map, which is completely transparent form user-space. * notifications from kernel to user-space Signed-off-by: Luca Dariz --- include/mach/mach_types.defs | 16 +++- 1 file changed, 11 insert

[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

[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 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

[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

[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

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

2022-06-28 Thread Luca Dariz
primarly useful during debug. Signed-off-by: Luca Dariz --- i386/i386/pcb.c| 10 +- i386/i386/thread.h | 3 +++ i386/i386/trap.c | 4 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 6e215b3e..4a6cbdb0 100644 --- a/i386/i3

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

2022-06-28 Thread Luca Dariz
copyin_port() and copyout_port() helpers Signed-off-by: Luca Dariz --- i386/i386/copy_user.h | 64 include/mach/mach_traps.h | 18 ++--- kern/ipc_host.c | 2 +- kern/ipc_mig.c| 78 --- kern/ipc_mig.h

[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 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

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

2022-06-28 Thread Luca Dariz
unused for now. A better fix could be to add a vm descriptor type in include/mach/message.h, but then probably we don't need to use the rpc_ types in MIG anymore, they would be needed only for the syscall definitions. Signed-off-by: Luca Dariz --- vm/memory_object_proxy.c | 5 + 1

[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 00/15] Add preliminary support for 32-bit userspace on a x86_64 kernel

2022-06-28 Thread Luca Dariz
imized yet (especially the new copyinmsg/copyoutmsg). These patches are based on the previous work: https://mail.gnu.org/archive/html/bug-hurd/2022-04/msg7.html https://mail.gnu.org/archive/html/bug-hurd/2022-02/msg00006.html Luca Dariz (15): fix rpc types for KERNEL_USER stubs

[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 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 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

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

2022-08-30 Thread Luca Dariz
> Il 30/08/2022 08:17 CEST Samuel Thibault ha scritto: > Luca, le mar. 30 août 2022 07:57:23 +0200, a ecrit: > > Il 28/08/22 15:13, Samuel Thibault ha scritto: > > > This was breaking the 32bit kernel case. I have pushed a fix for that, > > > that does this move of setting msgh_size to copyinmsg i

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

2023-01-16 Thread Luca Dariz
* i386/i386/copy_user.h: new file to handle 32/64 bit differences - add msg_usize() to recontruct the user-space message size - add copyin/copyout helpers for addresses and ports * include/mach/message.h: add msg alignment macros * ipc/ipc_kmsg.c: - copyin/out ports names instead of using poi

[PATCH 3/7] update syscall signature with rpc_vm_* and mach_port_name_t

2023-01-16 Thread Luca Dariz
* include/mach/mach_types.h: use mach port names * kern/ipc_mig.c: update vm types and use copyin/copyout helpers * kern/ipc_mig.h: Likewise Signed-off-by: Luca Dariz --- include/mach/mach_traps.h | 18 - kern/ipc_mig.c| 41

[PATCH 7/7] replace mach_port_t with mach_port_name_t

2023-01-16 Thread Luca Dariz
This is a cleanup following the introduction of mach_port_name_t. The same set of changes is applied to all files: - rename mach_port_t to mach_port_name_t where a port name is used, - use MACH_PORT_NAME_NULL and MACH_PORT_NAME_DEAD where appropriate, - use invalid_port_to_name() and invalid_name_t

[PATCH 5/7] adjust rdxtree key to the correct size

2023-01-16 Thread Luca Dariz
* Makefile.am: define RDXTREE_KEY_32 --- Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.am b/Makefile.am index fb557ba6..54fcf685 100644 --- a/Makefile.am +++ b/Makefile.am @@ -82,6 +82,9 @@ endif # We do not support or need position-independent AM_CFLAGS += \

[PATCH 6/7] add conversion helpers for invalid mach port names

2023-01-16 Thread Luca Dariz
* include/mach/port.h: add _NAME_ variants for port NULL and DEAD and add helpers to check for invalid port names * ipc/port.h: add helpers to properly convert to/from invalid mach port names. --- include/mach/port.h | 8 ++-- ipc/port.h | 20 2 files change

[PATCH 1/7] add msg_user_header_t for user-side msg structure

2023-01-16 Thread Luca Dariz
* include/mach/message.h: use mach_msg_user_header_t only in KERNEL, and define it as mach_msh_header_t for user space * ipc/ipc_kmsg.c: use mach_msg_user_header_t where appropriate * ipc/ipc_kmsg.h: Likewise * ipc/mach_msg.c: Likewise * ipc/mach_msg.h: Likewise * kern/thread.h: Likewise --- inc

[PATCH 4/7] update writev syscall signature with rpc types

2023-01-16 Thread Luca Dariz
* device/device_emul.h: write/writev: update trap argument types * device/ds_routines.c: update argument types and adjust copyin * device/ds_routines.h: write/writev: update trap argument type * include/device/device_types.h: add rpc_io_buf_vec_t type * kern/ipc_mig.c: write/writev: update trap arg

[PATCH 0/7] update rpc for x86_64

2023-01-16 Thread Luca Dariz
These patches address the comments raised in the previous submission and add support for 32-bit rpc and syscalls on a 64-bit kernel. Luca Dariz (7): add msg_user_header_t for user-side msg structure x86_64: expand and shrink messages in copy{in,out}msg routines update syscall signature with

[PATCH 3/4] remove unused file ipc/mach_rpc.c

2023-01-16 Thread Luca Dariz
* Makefrag.am: remove ipc/mach_rpc.c * ipc/mach_rpc.c: remove file, all functions here seem unused. --- Makefrag.am| 1 - ipc/mach_rpc.c | 150 - 2 files changed, 151 deletions(-) delete mode 100644 ipc/mach_rpc.c diff --git a/Makefrag.am b/M

[PATCH 2/4] add required include

2023-01-16 Thread Luca Dariz
* kern/syscall_sw.h: add missing include Signed-off-by: Luca Dariz --- kern/syscall_sw.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kern/syscall_sw.h b/kern/syscall_sw.h index 34eaf90b..9e76fc60 100644 --- a/kern/syscall_sw.h +++ b/kern/syscall_sw.h @@ -27,6 +27,8 @@ #ifndef

[PATCH 4/4] fix warnings

2023-01-16 Thread Luca Dariz
* ipc/ipc_kmsg.c: fix cast to the correct pointer type * ipc/ipc_port.c: upcast rpc_vm_offset_t to full vm_offset_t * kern/pc_sample.c: Likewise --- ipc/ipc_kmsg.c | 5 ++--- ipc/ipc_port.c | 2 +- kern/pc_sample.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ipc/ipc_

[PATCH 1/4] add missing argument names

2023-01-16 Thread Luca Dariz
* ddb/db_break.c: add argument name, compilation fails on Debian/Linux stable with gcc 10.2 otherwise. For some reason on Debian/Hurd a simple test program without argname succeeds, unless I force -std=c11 or similar; I suppose because newer gcc have different defaults. Gnumach seem to stil

Mixing 32 and 64 bit userspace tasks (was: Re: [PATCH gnumach] Define rpc_vm_size_array_t and rpc_vm_offset_array_t)

2023-02-03 Thread Luca Dariz
Il 01/02/23 10:36, Sergey Bugaev ha scritto: Note that another way to handle the size conversion between rpc_* and regular types would be to add some new VM types to include/mach/message.h; in this case, the shrink/expand would happen in copyinmsg()/copyoutmsg() instead of the mig-generated code

[PATCH 4/6] fix rpc time value for 64 bit

2023-02-12 Thread Luca Dariz
* include/mach/task_info.h: use rpc variant of time_value_t * include/mach/thread_info.h: Likewise * kern/mach_clock.c: use rpc variant of time_value_t in read_time_stamp() * kern/mach_clock.h: Likewise * kern/thread.c: use rpc variant of thread_read_times() * kern/timer.h_ add thread_read_times_

[PATCH 3/6] add L4 kmem cache for x86_64

2023-02-12 Thread Luca Dariz
* i386/intel/pmap.c: allocate the L4 page table from a dedicate kmem cache instead of the generic kernel map. Also improve readability of nested ifdef's. --- i386/intel/pmap.c | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/i386/intel/pm

[PATCH gnumach 0/6] minor fixes and las 32on64 compatibility issue

2023-02-12 Thread Luca Dariz
still be issues with internal mach devices, I didn't test them thoroughly. Luca Dariz (6): set unused members of thread state to 0 fix hardcoded physical address add L4 kmem cache for x86_64 fix rpc time value for 64 bit fix port name size in notifications enable syscalls on x86

[PATCH 6/6] enable syscalls on x86_64

2023-02-12 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 5b9c8ef4..95ece3cc 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -1075,9 +1075,6 @@ syscall_entry_2: pushq %rax/* save

[PATCH 1/6] set unused members of thread state to 0

2023-02-12 Thread Luca Dariz
* i386/i386/pcb.c: always set esp to 0, it seems unused. --- i386/i386/pcb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 9ac55a1c..924ed08b 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -706,6 +706,7 @@ kern_return_t thread_getstatus(

[PATCH 2/6] fix hardcoded physical address

2023-02-12 Thread Luca Dariz
* i386/i386at/com.c use proper helper to convert physical to virtual address. --- i386/i386at/com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 000475db..de21206c 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -276,7

[PATCH 5/6] fix port name size in notifications

2023-02-12 Thread Luca Dariz
* ipc/ipc_machdep.h: define PORT_NAME_T_SIZE_IN_BITS * ipc/ipc_notify.c: fix port name size in notification message templates --- ipc/ipc_machdep.h | 1 + ipc/ipc_notify.c | 8 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ipc/ipc_machdep.h b/ipc/ipc_machdep.h index 29

[PATCH 6/9] add more explicit names for user space virtual space limits

2023-02-12 Thread Luca Dariz
* i386/i386/vm_param.h: add VM_MAX/MIN_USER_ADDRESS to kernel headers. * i386/i386/db_interface.c * i386/i386/ldt.c * i386/i386/pcb.c * i386/intel/pmap.c * kern/task.c: replace VM_MAX/MIN_ADDRESS with VM_MAX/MIN_USER_ADDRESS --- i386/i386/db_interface.c | 4 ++-- i386/i386/ldt.c | 8 +++

[PATCH 2/9] fix x86_64 asm for higher kernel addresses

2023-02-12 Thread Luca Dariz
* x86_64/interrupt.S: use 64-bit registers as variables could be stored at high addresses * x86_64/locore.S: Likewise --- x86_64/interrupt.S | 4 ++-- x86_64/locore.S| 6 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/x86_64/interrupt.S b/x86_64/interrupt.S index fe2b3

[PATCH 9/9] move kernel virtual address space to upper addresses

2023-02-12 Thread Luca Dariz
* i386/i386/vm_param.h: adjust constants to the new kernel map - the boothdr.S code already sets up a temporary map to higher addresses, so we can use INIT_VM_MIN_KERNEL_ADDRESS as in xen - increase the kernel map size to accomodate for bigger structures and more memory - adjust kerne

[PATCH 5/9] use L4 page table directly on x86_64 instead of short-circuiting to pdpbase

2023-02-12 Thread Luca Dariz
This is a preparation to run the kernel on high addresses, where the user vm region and the kernel vm region will use different L3 page tables. * i386/intel/pmap.c: on x86_64, retrieve the value of pdpbase from the L4 table, and add the pmap_pdp() helper (useful also for PAE). * i386/intel/pmap.

[PATCH 4/9] factor out PAE-specific bootstrap

2023-02-12 Thread Luca Dariz
* i386/intel/pmap.c: move it to pmap_bootstrap_pae() --- i386/intel/pmap.c | 72 ++- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 15577a09..470be744 100644 --- a/i386/intel/pmap.c +++ b/i386/

[PATCH 8/9] separate initialization of kernel and user PTP tables

2023-02-12 Thread Luca Dariz
* i386/i386/vm_param.h: temporariliy fix kernel upper address * i386/intel/pmap.c: split kernel and user L3 map initialization. For simplicity in handling the different configurations, on 32-bit (+PAE) the name PDPNUM_KERNEL is used in place of PDPNUM, while only on x86_64 the PDPNUM_USER and

[PATCH 0/9 gnumach] move kernel vm map to high addresses on x86_64

2023-02-12 Thread Luca Dariz
towards being able to use more memory, as now also user-space has the same 3GB as on a 32-bit kernel, but the memory structure has not changed much otherwise. The kernel map is not immediatly following the user map anymore, so the main changes are on the pmap module. Luca Dariz (9): prepare pmap

[PATCH 3/9] factor out xen-specific bootstrap

2023-02-12 Thread Luca Dariz
* i386/intel/pmap.c: move it to pmap_bootstrap_xen() --- i386/intel/pmap.c | 107 -- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 9fe16368..15577a09 100644 --- a/i386/intel/pmap.c +++ b/i386/

[PATCH 7/9] extend data types to hold a 64-bit address

2023-02-12 Thread Luca Dariz
* i386/i386/trap.c: change from int to a proper type to hold a register value * x86_64/locore.S: use 64-bit register to avoid address truncation --- i386/i386/trap.c | 12 ++-- x86_64/locore.S | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/i386/i386/trap.c b/i

[PATCH 1/9] prepare pmap helpers for full 64 bit memory map

2023-02-12 Thread Luca Dariz
* i386/intel/pmap.c: start walking the page table tree from the L4 table instead of the PDP table in pmap_pte() and pmap_pde(), preparing for the kernel to run on high addresses. --- i386/intel/pmap.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --g

Re: [PATCH mig] Make MIG work for pure 64 bit kernel and userland.

2023-02-16 Thread Luca Dariz
Hi Sergey, thanks a lot for the detailed explanation! Il 12/02/23 19:16, Sergey Bugaev ha scritto: But look at what Apple MIG does: typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_port_descriptor_t port_a

[PATCH 2/4] x86_64: load Elf64 bootstrap modules if ! USER32

2023-02-16 Thread Luca Dariz
* i386/include/mach/i386/exec/elf.h: add Elf64 definitions and define common Elf structures, corresponding to 32/64 bit variants at compile time. * include/mach/exec/elf.h: add Elf64 definitions * kern/elf-load.c: use common Elf structures --- i386/include/mach/i386/exec/elf.h | 20 +++

[PATCH 1/4] x86_64: fix some compiler warnings

2023-02-16 Thread Luca Dariz
* i386/include/mach/i386/vm_param.h: extend the vm constants to ULL on x86_64 to avoid a shift overflow warning * i386/intel/pmap.c: fix cast and unused variables --- i386/include/mach/i386/vm_param.h | 4 ++-- i386/intel/pmap.c | 8 +++- 2 files changed, 5 insertions(+), 7 d

[PATCH 3/4] x86_64: fix argument passing to bootstrap modules if ! USER32

2023-02-16 Thread Luca Dariz
* kern/bootstrap.c: replace integers with long/vm_offset_t --- kern/bootstrap.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 91f4241e..8f66a4b5 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -579,7 +579,7 @@ build

[PATCH 4/4] x86_64: set user segments as 64-bit if ! USER32

2023-02-16 Thread Luca Dariz
* i386/i386/ldt.c: set the L bit if user-space is 64-bit --- i386/i386/ldt.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/i386/i386/ldt.c b/i386/i386/ldt.c index 70fa24e2..b86a0e3c 100644 --- a/i386/i386/ldt.c +++ b/i386/i386/ldt.c @@ -45,6 +45,12 @@ extern #endi

Re: [PATCH 6/6] enable syscalls on x86_64

2023-02-22 Thread Luca Dariz
Hi, Il 22/02/23 15:44, Sergey Bugaev ha scritto: On Sun, Feb 12, 2023 at 8:04 PM Luca Dariz wrote: -// TODO: test it before dropping ud2 - ud2 Hi; could you please tell me how you are testing this? What userland code do you run? How does it make syscalls, does it use lcall $7, $0

[PATCH 3/5] fix port name copyin

2023-02-27 Thread Luca Dariz
* x86_64/copy_user.c: in mach_msg_user_header_t there are some holes that need to be cleared, to adapt to the different layout of mach_msg_header_t. --- x86_64/copy_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x86_64/copy_user.c b/x86_64/copy_user.c index 86d23525..ae17c368 100

[PATCH 4/5] x86_64: fix user trap during syscall with an invalid user stack

2023-02-27 Thread Luca Dariz
* i386/i386/locore.h: user vm_offset_t in the recovery_table * x86_64/locore.S: fix RECOVERY() location and keep user regs in %rbx, as it seems the convention. This only applies to 32-bit userspace. --- i386/i386/locore.h | 4 ++-- x86_64/locore.S| 20 ++-- 2 files changed,

[PATCH 0/5] basic syscall support on x86_64

2023-02-27 Thread Luca Dariz
se gnumach fails to build. Luca Dariz (5): x86_64: allow compilation if ! USER32 fix copyin/outmsg header for ! USER32 fix port name copyin x86_64: fix user trap during syscall with an invalid user stack x86_64: add 64-bit syscall entry point i386/i386/i386asm.sym | 11 ++

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

2023-02-27 Thread Luca Dariz
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

[PATCH 2/5] fix copyin/outmsg header for ! USER32

2023-02-27 Thread Luca Dariz
* x86_64/copy_user.c: fix copyin/out, we already have a pointer to user/kernel buffers --- x86_64/copy_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x86_64/copy_user.c b/x86_64/copy_user.c index dd9fe2d7..86d23525 100644 --- a/x86_64/copy_user.c +++ b/x86_64/copy

[PATCH 1/5] x86_64: allow compilation if ! USER32

2023-02-27 Thread Luca Dariz
* i386/intel/pmap.c: remove #error and allow compilation, keeping a reminder to fix the pmap module. --- i386/intel/pmap.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 302a60cb..40f672b5 100644 --- a/i386/intel/pmap.c +++ b

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

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 st

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

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

2023-03-01 Thread Luca Dariz
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

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

2023-03-01 Thread Luca Dariz
Il 01/03/23 21:18, Samuel Thibault ha scritto: Luca Dariz, le mer. 01 mars 2023 18:40:37 +0100, a ecrit: +asm volatile("wrmsr" + : + : "c" (regaddr), "a" (low), "d" (high) + : "memory" /* w

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

2023-03-02 Thread Luca Dariz
Il 02/03/23 09:00, Samuel Thibault ha scritto: Luca Dariz, le jeu. 02 mars 2023 08:55:38 +0100, a ecrit: Il 01/03/23 21:18, Samuel Thibault ha scritto: Luca Dariz, le mer. 01 mars 2023 18:40:37 +0100, a ecrit: +asm volatile("wrmsr" + : + : "c

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

2023-03-02 Thread Luca Dariz
Il 02/03/23 14:14, Samuel Thibault ha scritto: Luca Dariz, le jeu. 02 mars 2023 09:20:15 +0100, a ecrit: Il 02/03/23 09:00, Samuel Thibault ha scritto: Luca Dariz, le jeu. 02 mars 2023 08:55:38 +0100, a ecrit: Il 01/03/23 21:18, Samuel Thibault ha scritto: Luca Dariz, le mer. 01 mars 2023 18

[PATCH v3 gnumach] x86_64: add 64-bit syscall entry point

2023-03-08 Thread Luca Dariz
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

[PATCH 5/5] add setting gs/fsbase

2023-04-19 Thread Luca Dariz
* i386/i386/i386asm.sym: add offsets for asm * i386/i386/pcb.c: switch FSBASE/GSBASE on context switch and implement accessors in thread setstatus/getstatus * i386/i386/thread.h: add new state to thread saved state * kern/thread.c: add i386_FSGS_BASE_STATE handler * x86_64/locore.S: fix fs/gs han

[PATCH 1/5] fix address fault for 32-on-64-bit syscall

2023-04-19 Thread Luca Dariz
* x86_64/locore.S: the faulty address is found in %rbp and not in %rsi, so copy that in CR2 --- x86_64/locore.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86_64/locore.S b/x86_64/locore.S index 47d9085c..ea5c71d6 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -12

[PATCH 3/5] fix exception message format for 64-bit userspace

2023-04-19 Thread Luca Dariz
* kern/exception.c: message fields need to be aligned to 8 bytes for a 64-bit userspace, so add the required padding if needed, as done by MIG. --- kern/exception.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/kern/exception.c b/kern/exception.c index 10435b5c..757f793e 100644 ---

[PATCH 2/5] fix copyoutmsg for 64-bit userspace

2023-04-19 Thread Luca Dariz
* x86_64/copy_user.c: use the correct user/kernel msg structure --- x86_64/copy_user.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/x86_64/copy_user.c b/x86_64/copy_user.c index b5084996..f76e44c9 100644 --- a/x86_64/copy_user.c +++ b/x86_64/copy_user.c @@ -430,7 +430,7

[PATCH 4/5 (v4)] x86_64: add 64-bit syscall entry point

2023-04-19 Thread Luca Dariz
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

Re: [PATCH 3/5] fix exception message format for 64-bit userspace

2023-04-20 Thread Luca Dariz
Hi Flavio, Il 20/04/23 04:04, Flávio Cruz ha scritto: On Wed, Apr 19, 2023 at 3:47 PM Luca Dariz <mailto:l...@orpolo.org>> wrote: * kern/exception.c: message fields need to be aligned to 8 bytes for a   64-bit userspace, so add the required padding if needed, as done by

Re: [PATCH 5/5] add setting gs/fsbase

2023-04-22 Thread Luca Dariz
Hi Sergey, Il 20/04/23 13:51, Sergey Bugaev ha scritto: On Wed, Apr 19, 2023 at 11:52 PM Sergey Bugaev wrote: We do reach the call to __thread_set_state (), but then it uses __mig_memcpy (), which is just 'return memcpy (...)'. And (because of the static build?), that memcpy () is the full real

  1   2   >