summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)Author
2024-02-12Add thread_set_name RPC.Flavio Cruz
Like task_set_name, we use the same size as the task name and will inherit the task name, whenever it exists. This will be used to implement pthread_setname_np. Message-ID: <20240212062634.1082207-2-flaviocruz@gmail.com>
2024-02-12Replace kernel header includes in include/mach/mach_types.h with forward ↵Flavio Cruz
declarations. I was trying to reuse TASK_NAME_SIZE in kern/thread.h but it was impossible because files included from kern/task.h end up requiring kern/thread.h (through percpu.h), creating a recursive dependency. With this change, mach_types.h only defines forward declarations and modules have to explicitly include the appropriate header file if they want to be able touch those structures. Most of the other includes are required because we no longer grab many different includes through mach_types.h. Message-ID: <20240212062634.1082207-1-flaviocruz@gmail.com>
2024-01-30Add vm_pages_physSamuel Thibault
For rumpdisk to efficiently determine the physical address, both for checking whether it is below 4GiB, and for giving it to the disk driver, we need a gnumach primitive (and that is not conditioned by MACH_VM_DEBUG like mach_vm_region_info and mach_vm_object_pages_phys are).
2023-12-29expose MACH_MSG_USER_ALIGNMENT for manually-built messagesLuca Dariz
Message-ID: <20231228194301.745811-11-luca@orpolo.org>
2023-12-17Reorder mach_msg_type_t fields to ensure msgt_name and msgt_size are byte ↵v1.8+git20231217Flavio Cruz
aligned msgt_unused appears right after msgt_size since msgt_size can be reduced to only 8 bits in the future, so we leave the door opened to make msgt_unused 13 bits long.
2023-12-17x86_64: Support 8 byte inlined port rights to avoid message resizing.Flavio Cruz
If a port is inlined in a message, the user has to use mach_port_name_inlined_t to define each port. Out of line memory continues to use mach_port_name_t since that memory has to be copied to the kernel anyway. Both copyinmsg and copyoutmsg can be reduced to nothing (if we ignore USER32) as a follow up but kept this patch simple for ease of review.
2023-12-03Revert "Reorder mach_msg_type_t fields to ensure msgt_name and msgt_size are ↵Samuel Thibault
byte aligned" This reverts commit 2db6b9b7b23b3bab944665b3b6012d24dd425d97.
2023-12-03Revert "x86_64: Support 8 byte inlined port rights to avoid message resizing."Samuel Thibault
This reverts commit 29d4bcaafc4c2040df27a6247603c68e7757205c.
2023-12-03x86_64: Support 8 byte inlined port rights to avoid message resizing.Flavio Cruz
If a port is inlined in a message, the user has to use mach_port_name_inlined_t to define each port. Out of line memory continues to use mach_port_name_t since that memory has to be copied to the kernel anyway. Both copyinmsg and copyoutmsg can be reduced to nothing (if we ignore USER32) as a follow up but kept this patch simple for ease of review. Message-ID: <ZWg00XzFPqqL1yF-@jupiter.tail36e24.ts.net>
2023-12-03Reorder mach_msg_type_t fields to ensure msgt_name and msgt_size are byte ↵Flavio Cruz
aligned msgt_unused appears right after msgt_size since msgt_size can be reduced to only 8 bits in the future, so we leave the door opened to make msgt_unused 13 bits long. Message-ID: <ZWGT6a6GeqFAtOUn@jupiter.tail36e24.ts.net>
2023-11-12Fix indentSamuel Thibault
2023-11-07mach/message.h: Fix C++98 buildSamuel Thibault
static_assert was introduced in C++11.
2023-11-03mach/message.h: Fix C++ buildSamuel Thibault
2023-09-25Update the 64bit RPC ABI to be simplerFlavio Cruz
* Make full use of the 8 bytes available in mach_msg_type_t by moving into the unused 4 bytes. This allows us to use 32bits for mach_msg_type_number_t whether we use the longform or not. * Make mach_msg_type_long_t exactly the same as mach_msg_type_t. Updating MiG is strongly encouraged since it will generate better code to handle this new format. After this change, any compatibility with compiled binaries for Hurd x86_64 will break since the message format is different. However, the new schema simplifies the overall ABI, without having "holes" and also avoids the need to have a 16 byte mach_msg_type_long_t. Was able to boot a basic system up to a bash shell. Message-Id: <ZIfqFe5bPNPeH4xg@jupiter.lan>
2023-08-28mach_vm_object_pages: Extend for PAESamuel Thibault
2023-08-12x86_64: Fix loading ELF symbolsSamuel Thibault
2023-08-12elf64: Update namesSamuel Thibault
Apparently the ELF world changed their mind on the naming of integers, let's get coherent with it. Elf64_Quarter (16b) disappeared, replaced by Elf64_Half (now 16b instead of Elf64_32b). And previous Elf64_Half (16b) thus now need to be Elf64_Word (16b).
2023-05-17Fix task_info for TASK_THREAD_TIMES_INFO.Flavio Cruz
We are checking for the existence of time_value64_t but we didn't add that to the task_thread_times_info structure. Message-Id: <ZGRDbS0XIm1fJwkG@jupiter.tail36e24.ts.net>
2023-05-11Keep host_get_kernel_version for USER32-on-x86_64 caseSamuel Thibault
2023-05-11Remove host_kernel_version RPC for x86_64Flavio Cruz
We can fast track the simplification of the RPC ABI for x86_64 if we don't have MACH_MSG_TYPE_STRING used in RPCs which forces msgt_size to use more than 8 bits. Message-Id: <ZFht+/9cVPHuV90D@jupiter.tail36e24.ts.net>
2023-05-06Delete include/mach/rpc.hFlavio Cruz
File is unused. Message-Id: <ZFSSbAzZ+7KYKtOF@jupiter.tail36e24.ts.net>
2023-05-06x86_64: Add CPU_TYPE_X86_64 CPU typeSamuel Thibault
2023-05-02Use mig_support.h prototypes instead of duplicating them.Flavio Cruz
* include/mach/mig_support.h: Drop the ifndef because this file is only used internally to compile gnumach. We export mig_support.h from glibc already. * kern/ipc_mig.c: len should be vm_size_t. * kern/ipc_mig.h: Drop duplicate prototypes. Message-Id: <ZFBjEk07CaQgx9Ru@jupiter.tail36e24.ts.net>
2023-04-29Use c_string for dev_name_t in the device subsystem.Flavio Cruz
Added device_open_new and device_open_new_request and reused the old MiG ID for xxx_device_set_status which has not been in used in the past decade. Note that device_open_new is gated on defining DEVICE_ENABLE_DEVICE_OPEN_NEW because otherwise some hurd servers wouldn't compile anymore unless patched. This macro allows us to control the rollout. Message-Id: <ZEi1LV+9ShuXqtcr@jupiter.tail36e24.ts.net>
2023-04-27Update task_basic_info and thread_basic_info to include time_value64_t data.Flavio Cruz
RPCs remain compatible with existing clients but if they know about the new size then we will populate the new fields. Message-Id: <ZDzPLCJccKeRB5Pd@mars.tail36e24.ts.net>
2023-04-10Delete include/mach/default_pager_helper.defsFlavio Cruz
Not used. Message-Id: <ZDN13tll1jYc1jYh@jupiter.tail36e24.ts.net>
2023-04-07Remove host_get_boot_info and host_get_kernel_boot_info since they are not used.Flavio Cruz
host_get_kernel_boot_info was added recently to fix the use of MACH_MSG_TYPE_STRING. Message-Id: <ZC5Sz8a4FCT6IjCY@jupiter.tail36e24.ts.net>
2023-04-03Make exception subcode a longSergey Bugaev
On EXC_BAD_ACCESS, exception subcode is used to pass the faulting memory address, so it needs to be (at least) pointer-sized. Thus, make it into a long. This requires matching changes in glibc and the Hurd. Message-Id: <20230319151017.531737-4-bugaevc@gmail.com>
2023-04-03Remove bootstrap.defsSergey Bugaev
As far as I can see, this file was imported in the very beginning of GNU Mach history, and unused since then. Nobody implements or uses this interface. GNU Mach uses a different way to pass the privileged ports to the bootstrap tasks: instead of the task(s) actively asking for the ports in an RPC, the ports are preemptively inserted into the IPC space(s) of the task(s), as configured by the boot script. Remove bootstrap.defs so as to not confuse anyone into thinking it works. Message-Id: <20230319151017.531737-3-bugaevc@gmail.com>
2023-04-03Use c_string to define symtab_name_t.Flavio Cruz
As mentioned in 5447f965, the c_string type correctly uses msgt_size/msgt_number, resulting in a more compact ABI that doesn't require mach_msg_type_long_t. I redefined host_load_symbol_table with a new Id since this is just a debug RPC and is not used anywhere. Message-Id: <ZBFgyJp+Pcb7zFhf@mars.tail36e24.ts.net>
2023-03-13Drop spurious tabsSamuel Thibault
2023-03-13Track task and thread time using time_value64_t.Flavio Cruz
Changed kern/timer.c to use the higher precision time_value64_t. Of course, this won't suffer from the 2038 overflow but it does provide nanosecond precision (if gnumach ever uses a better timer) and moves us closer to only having time_value64_t. Message-Id: <ZA63tGcv3bETUJFJ@jupiter.tail36e24.ts.net>
2023-03-13Use c_string to define host_get_kernel_version and host_get_kernel_boot_info.Flavio Cruz
The existing definitions for kernel_version_t and kernel_boot_info_t use (MACH_MSG_TYPE_STRING, length*8) which result in message types that have a single element of 512 or 4096 bytes (set as msgt_size). This results in MiG generating mach_msg_type_long_t. Using c_string has the benefit of moving this size to be defined as msgt_number which doesn't overflow. This will allow us to simplify the 64 bit RPC ABI since all msgt_size can be defined with just 8 bits (as it should be expected). The resulting implementation is the same but we still need to define new RPCs since server and user expect different mach_msg_type_t. Message-Id: <ZA63pS8j9J6NwuXY@jupiter.tail36e24.ts.net>
2023-03-08Align mach_msg_type_t and mach_msg_type_long_t with the same alignment as ↵Flavio Cruz
uintptr_t. With this change, any 64 bit code using the IPC subsystem without relying on MiG will work without any changes. We have a few examples of this inside gnumach but also in the Hurd servers. For example, in hurd/console/display.c typedef struct { mach_msg_header_t Head; mach_msg_type_t ticknoType; natural_t tickno; mach_msg_type_t changeType; file_changed_type_t change; mach_msg_type_t startType; loff_t start; mach_msg_type_t endType; loff_t end; } Request; This will now work correctly in 64 bits, without requiring any explicit padding. As a follow up, we can simplify mach_msg_type_long_t so that we only need an 8 byte structure where the second field will include the number of elements for the long form. This is already included in mach_msg_type_t as unused_msgtl_number. Message-Id: <ZAbhOfOzsb8qPFs6@jupiter.tail36e24.ts.net>
2023-02-27Support alignment requirements for a 64 bit kernel.Flavio Cruz
We introduce both a user alignment and a kernel alignment. These are separate requirements since for 64 bit with a 32 bit kernel we need to ensure the kernel can consume messages that are 8-byte aligned. This change removes any possibility of undefined behavior and also allows the kernel to support 64 bit RPCs for the userland. A lot of the code that performs alignment was simplified under the assumption that the message headers are well aligned. To enforce that going forward, a few static assertions were added. Message-Id: <Y/KrixiC9Njmu7ef@jupiter.tail36e24.ts.net>
2023-02-23Add TIME_VALUE64_TO_TIMESPEC and TIMESPEC_TO_TIME_VALUE64Flavio Cruz
We can use these in userland with the new time_value64_t struct. Message-Id: <Y/RRck2JffqNenif@jupiter.tail36e24.ts.net>
2023-02-20Delete include/mach/msg_type.hFlavio Cruz
File is not included anywhere. Message-Id: <Y/K1haNulJ63eDBd@jupiter.tail36e24.ts.net>
2023-02-16x86_64: load Elf64 bootstrap modules if ! USER32Luca 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 Message-Id: <20230216213318.2048699-2-luca@orpolo.org>
2023-02-13Make mach_msg_header_t have the same size for both 64 bit kernel and userland.Flavio Cruz
This has several advantages: 1) We don't need to resize mach_msg_header_t, it is just a copy. 2) Mig won't require any changes because it statically computes the size of mach_msg_header_t, otherwise we would need two sizes (28 vs 32 bytes). Message-Id: <Y+l8UhXXX9Qo9tVA@jupiter.tail36e24.ts.net>
2023-02-13time_value: Fix rpc_time_value_t compatibility.Samuel Thibault
5fdc928d3d29 ("fix rpc time value for 64 bit") broke hurd build because structures are never compatible in C. For userland we however know that rpc_time_value is the same as time_value, so we can just typedef rpc_time_value_t to struct time_value as userland is used to.
2023-02-12Consider protected payloads in mach_msg_header_t when resizing messages.Flavio Cruz
Protected payloads will be 8-byte longs which are the same size as kernel ports. Also aligned all the structures to be 4-byte aligned since it makes it easier to parse them as padding won't be added to mach_msg_user_header_t before the protected payload. Message-Id: <Y+krwRFIUeyRszl9@jupiter.tail36e24.ts.net>
2023-02-12fix rpc time value for 64 bitLuca 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_rpc() by converting time_value_t to the corresponding rpc structures inline. Message-Id: <20230212170313.1501404-5-luca@orpolo.org>
2023-01-31Define rpc_vm_size_array_t and rpc_vm_offset_array_tFlavio Cruz
When generating stubs, Mig will will take the vm_size_array_t and define the input request struct using rpc_vm_size_t since the size is variable. This will turn cause a mismatch between types (vm_size_t* vs rpc_vm_size_t*). We could also ask Mig to produce a prototype by using rpc_vm_size_t*, however we would need to change the implementation of the RPC to use rpc_* types anyway since we want to avoid another allocation of the array. Message-Id: <Y9iwScHpmsgY3V0N@jupiter.tail36e24.ts.net>
2023-01-28Add host_set_time64 and host_adjust_time64Flavio Cruz
Same existing logic, just with 64 bits. Old RPCs are implemented by calling into the new RPCs. Message-Id: <Y9TJAmL2byOWup5x@jupiter.tail36e24.ts.net>
2023-01-28Use standard types in include/device/input.hFlavio Cruz
--enable-platform=xen won't compile because u_char is not included from sys/types.h. Also, we are forcing users of include/device/input.h to include glibc headers that export such types which should not be necessary. For i386/i386at/kd.h we include input.h to get Scancode. Message-Id: <Y9S7oIyVFazVAOqb@jupiter.tail36e24.ts.net>
2023-01-19Rename msg_is_misaligned and msg_alignSamuel Thibault
message.h is installed so we need to hide these behind a mach_ prefix
2023-01-19Add host_get_time64 RPC to return the time as time_value64_tFlavio Cruz
Also updated the mapped time to support the new 64-bit time while keeping compatible with the user land programs currently using it so they can be migrated in parallel.
2023-01-18replace mach_port_t with mach_port_name_tLuca 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_to_port() for conversion where appropriate, - use regular copyout() insted of copyout_port() when we deal with mach_port_name_t already before copyout, - use the new helper ipc_kmsg_copyout_object_to_port() when we really want to place a port name in the space of a mach_port_t. * include/mach/notify.h: Likewise * ipc/ipc_entry.c: Likewise * ipc/ipc_kmsg.c: Likewise * ipc/ipc_kmsg.h: Likewise, and add ipc_kmsg_copyout_object_to_port() * ipc/ipc_marequest.c: Likewise * ipc/ipc_object.c: Likewise * ipc/ipc_port.c: Likewise * ipc/ipc_space.h: Likewise * ipc/mach_msg.c: Likewise * ipc/mach_port.c: Likewise * kern/exception.c: Likewise * kern/ipc_mig.c: Likewise Message-Id: <20230116105857.240210-8-luca@orpolo.org>
2023-01-18add conversion helpers for invalid mach port namesLuca 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. Message-Id: <20230116105857.240210-7-luca@orpolo.org>
2023-01-18update writev syscall signature with rpc typesLuca 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 argument type * kern/ipc_mig.h: Likewise Message-Id: <20230116105857.240210-5-luca@orpolo.org>