aboutsummaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* Make exception subcode a longSergey Bugaev2023-04-031-1/+1
| | | | | | | | | 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>
* Remove bootstrap.defsSergey Bugaev2023-04-031-49/+0
| | | | | | | | | | | | 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>
* Use c_string to define symtab_name_t.Flavio Cruz2023-04-032-17/+20
| | | | | | | | | | 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>
* Drop spurious tabsSamuel Thibault2023-03-131-11/+11
|
* Track task and thread time using time_value64_t.Flavio Cruz2023-03-131-0/+5
| | | | | | | | 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>
* Use c_string to define host_get_kernel_version and host_get_kernel_boot_info.Flavio Cruz2023-03-132-0/+20
| | | | | | | | | | | | | | 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>
* Align mach_msg_type_t and mach_msg_type_long_t with the same alignment as ↵Flavio Cruz2023-03-081-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Support alignment requirements for a 64 bit kernel.Flavio Cruz2023-02-271-10/+24
| | | | | | | | | | | | | 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>
* Add TIME_VALUE64_TO_TIMESPEC and TIMESPEC_TO_TIME_VALUE64Flavio Cruz2023-02-231-0/+12
| | | | | We can use these in userland with the new time_value64_t struct. Message-Id: <Y/RRck2JffqNenif@jupiter.tail36e24.ts.net>
* Delete include/mach/msg_type.hFlavio Cruz2023-02-201-42/+0
| | | | | File is not included anywhere. Message-Id: <Y/K1haNulJ63eDBd@jupiter.tail36e24.ts.net>
* x86_64: load Elf64 bootstrap modules if ! USER32Luca Dariz2023-02-161-0/+36
| | | | | | | | | * 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>
* Make mach_msg_header_t have the same size for both 64 bit kernel and userland.Flavio Cruz2023-02-131-2/+13
| | | | | | | | 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>
* time_value: Fix rpc_time_value_t compatibility.Samuel Thibault2023-02-131-1/+6
| | | | | | | 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.
* Consider protected payloads in mach_msg_header_t when resizing messages.Flavio Cruz2023-02-121-1/+8
| | | | | | | | | | 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>
* fix rpc time value for 64 bitLuca Dariz2023-02-122-8/+8
| | | | | | | | | | | | * 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>
* Define rpc_vm_size_array_t and rpc_vm_offset_array_tFlavio Cruz2023-01-311-3/+5
| | | | | | | | | | 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>
* Add host_set_time64 and host_adjust_time64Flavio Cruz2023-01-281-0/+18
| | | | | | Same existing logic, just with 64 bits. Old RPCs are implemented by calling into the new RPCs. Message-Id: <Y9TJAmL2byOWup5x@jupiter.tail36e24.ts.net>
* Use standard types in include/device/input.hFlavio Cruz2023-01-281-2/+2
| | | | | | | | | | --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>
* Rename msg_is_misaligned and msg_alignSamuel Thibault2023-01-191-2/+2
| | | | message.h is installed so we need to hide these behind a mach_ prefix
* Add host_get_time64 RPC to return the time as time_value64_tFlavio Cruz2023-01-193-13/+44
| | | | | | 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.
* replace mach_port_t with mach_port_name_tLuca Dariz2023-01-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* add conversion helpers for invalid mach port namesLuca Dariz2023-01-181-2/+6
| | | | | | | | * 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>
* update writev syscall signature with rpc typesLuca Dariz2023-01-181-0/+4
| | | | | | | | | | * 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>
* update syscall signature with rpc_vm_* and mach_port_name_tLuca Dariz2023-01-181-14/+4
| | | | | | | | | * 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 <luca@orpolo.org> Message-Id: <20230116105857.240210-4-luca@orpolo.org>
* x86_64: expand and shrink messages in copy{in, out}msg routinesLuca Dariz2023-01-181-1/+13
| | | | | | | | | | | | | | | | | | | * 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 pointer magic * ipc/ipc_mqueue.c: use msg_usize() to check if we can actually receive the message * ipc/mach_msg.c: Likewise for continuations in receive path * x86_64/Makefrag.am: add x86_64/copy_user.c * x86_64/copy_user.c: new file to handle message expansion and shrinking during copyinmsg/copyoutmsg for 64 bit kernels. - port names -> port pointers on all 64-bit builds - 32-bit pointer -> 64 bit pointer when using 32-bit userspace * x86_64/locore.S: remove copyinmsg() and copyoutmsg() Message-Id: <20230116105857.240210-3-luca@orpolo.org>
* add msg_user_header_t for user-side msg structureLuca Dariz2023-01-181-1/+16
| | | | | | | | | | | * 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 Message-Id: <20230116105857.240210-2-luca@orpolo.org>
* Delete ffs and strrchr prototypes.Flavio Cruz2023-01-151-4/+0
| | | | | | | | We use __builtin_ffs instead of ffs. strrchr is not used. Also removed the commented out memset implementation since it is implemented in arch-specific code. Message-Id: <Y8NOXbVzhBJknR29@mercury.tail36e24.ts.net>
* Use rpc_uintptr_t for protected payloads.Flavio Cruz2023-01-133-2/+4
| | | | | | | Not only is uintptr_t more accurate for what protected payloads are but we also provide compatibility for 64 + 32 bits. Also the use of natural_t in the RPC definition is wrong since it is always 32 bits. Message-Id: <Y7+LHVbmYxO/cSKs@jupiter.tail36e24.ts.net>
* Export input structures used by Hurd in device/input.h.Flavio Cruz2023-01-092-52/+106
| | | | | | Also delete sys/ioctl.h and merge it with device/input.h since it is only needed here. Message-Id: <Y7uirJzaJeOBzAmq@jupiter.tail36e24.ts.net>
* Introduce time_value64_t to keep track of real time in the kernelFlavio Cruz2023-01-032-54/+26
| | | | | | | | | | | | time_value64_t uses int64_t to track seconds and nanoseconds and hence is Y2038 proof. It does not have nano second resolution but it could be provided in the future. Removed include/sys/time.h as it remaps time_value_t into timeval which can create confusion. The timestamp from keyboard and mouse events is no longer set and replaced with rpc_time_value for better compatibility.
* Fix inttypes.h format constants for uintptr_t and intptr_t.Flavio Cruz2022-12-271-9/+11
| | | | | | | | The format constants are not correct for 32 bits and there was duplication for PRIx* constants (replaced with octal constants). Fixed a few format warnings too. Message-Id: <Y6o5KsvtPavCYe8f@mars>
* Use uintptr_t to define vm_size_t/vm_offset_t/vm_addressFlavio Cruz2022-12-271-5/+1
| | | | Message-Id: <Y6j9bnHphZp0ZPYC@mars>
* Use -Wstrict-prototypes and fix warningsFlavio Cruz2022-12-212-3/+1
| | | | | | | Most of the changes include defining and using proper function type declarations (with argument types declared) and avoiding using the K&R style of function declarations. Message-Id: <Y6Jazsuis1QA0lXI@mars>
* time_value: Fix usage in e.g. c89 programsSamuel Thibault2022-12-191-2/+2
| | | | | | The inline keyword was not defined there, so we need to use __inline__. This fixes make check in glibc.
* Remove custom stdint.h and rely on freestanding headersFlavio Cruz2022-12-192-73/+0
| | | | | GCC already provides this so we don't need to have our own. Message-Id: <Y5+02FVA6jf4GPgA@mars>
* Use long_natural_t for recnum_tFlavio Cruz2022-12-182-2/+12
| | | | | | | | | | | | For 64 bits, device operations will provide an addressing space of 64 bits. Also define the translation functions if long_natural_t or long_integer_t are ever used in RPCs. Note that MIG does not implicitly inherit the translation functions from types hence the need to redefine them for recnum_t. Message-Id: <Y59MFzekEA0YUXIw@mars>
* Use struct for time_value_t and define seconds as long_integer_t.Flavio Cruz2022-12-172-2/+38
| | | | | | | On 64 bit kernels, seconds will be 64 bits long and won't suffer from the 2038 problem. We also add a new type rpc_time_value_t to handle the conversion between 32 bit userland and 64 bit kernel. Message-Id: <Y50kIaIgaIdGjDAk@mars>
* Define vm_size_t and vm_offset_t as __mach_uintptr_t.Flavio Cruz2022-12-061-1/+1
| | | | | | | | | | This allows *printf to use %zd/%zu/%zx to print vm_size_t and vm_offset_t. Warnings using the incorrect specifiers were fixed. Note that MACH_PORT_NULL became just 0 because GCC thinks that we were comparing a pointer to a character (due to it being an unsigned int) so I removed the explicit cast. Message-Id: <Y47UNdcUF35Ag4Vw@reue>
* Make task_info.h structs more portableFlavio Cruz2022-12-063-22/+22
| | | | | | | | | | Changed vm_size_t to rpc_size_t so that both userland and kernel agree on the same size. Also changed the denominator for the maximum struct sizes to be integer_t to match the other declarations. Introduced long_natural_t and rpc_long_natural_t to represent large counters. Replaced rpc_unsigned_long with rpc_long_natural_t. Message-Id: <Y47UhaOzKnqhgYq4@reue>
* task: Add task_set_essentialSamuel Thibault2022-12-031-0/+8
| | | | | | | | Whenever a Hurd essential task crashes, startup just reboots the system since there's not much that can be done at that point. When we have a kernel debugger, however, we could at least get crashing information, so let's let Hurd's startup tell the kernel which tasks are essential, and trigger the debugger whenever they crash.
* Update ipc/ directory to use mach_port_name_tFlavio Cruz2022-11-302-5/+5
| | | | | | | | | | | | | | | Make it explicit where we use port names versus actual ports. For the 64 bit kernel, port names and ports are of different size so this corrects the syscall arguments and internal structs to have the right size. This patch also uncovered several issues we need to solve to make GNUMach work well on 64 bits. First, the mach_msg call will receive 4 byte port names while the kernel "thinks" they are 8 bytes, which will be a problem. Also, when we send a message, the kernel translates the port names into port pointers in the message copied from user space. This also won't work on 64 bits. In this patch, I added several TODOs to fix the issues later. Message-Id: <Y4cCzNmc6vC4bjsX@viriathus>
* Use portable rpc types to define 'struct sample'.Flavio Cruz2022-11-282-5/+11
| | | | Message-Id: <Y4QQFkTUR4M60Gx0@viriathus>
* Update mach_port_status_t definition to use the new structFlavio Cruz2022-11-282-8/+18
| | | | | Also update C definition to use proper types. Message-Id: <Y4QKgh0zHdB8pWhD@viriathus>
* Delete mach_debug/pc_info.hFlavio Cruz2022-11-281-43/+0
| | | | | mach/pc_sample.h has the definitions that the kernel actually uses. Message-Id: <Y4QKGtUdbz+AVO3l@viriathus>
* Update mach_debug interfaces to use struct.Flavio Cruz2022-11-255-36/+93
| | | | | | | | | | | | | | | | | | | | | | The new interfaces will be compatible both with a 64 bits kernel and userland and 64 bits kernel and 32 bit userland. Also removed many of the uses of natural_t where an unsigned int suffices. Ideally we should replace natural_t with something more portable such as uintptr_t or a basic int type for counters since for the most part we don't need counters to have the same width as the pointer type. * i386/include/mach/i386/vm_types.h: Define rpc_unsigned_long. * include/mach/mach_types.defs: Define type rpc_vm_offset_t. * include/mach_debug/hash_info.h: Use unsigned int instead of natural_t. * include/mach_debug/mach_debug_types.defs: Update cache_info_t, hash_info_bucket_t, vm_region_info_t, vm_object_info_t and vm_page_info_t to use struct. * include/mach_debug/slab_info.h: Use rpc_vm_size_t and rpc_unsigned_long for compatibility with 32 bits userland. * include/mach_debug/vm_info.h: Update struct fields to use the correct types and avoid natural_t whenever we just want to keep a count of something. Message-Id: <Y32lp1SuV01ImCx9@viriathus>
* Delete ipc_info.h since it is not usedFlavio Cruz2022-11-252-78/+0
| | | | Message-Id: <Y35PHuUNCFb6sQO0@viriathus>
* default_pager_types.defs: define existing struct types as true structsFlavio Cruz2022-11-111-4/+13
| | | | Message-Id: <Y23fab31RM6HcCyb@viriathus>
* Remove unused mig type definitions in gnumachFlavio Cruz2022-11-062-21/+0
| | | | | | | | | | | | | | | | | | | | | * include/mach/mach_types.defs: host_basic_info_data_t, host_sched_info_data_t, host_load_info_data_t, processor_basic_info_data_t, processor_set_basic_info_data_t, processor_set_sched_info_data_t, hread_basic_info_data_t, thread_sched_info_data_t, task_basic_info_data_t, task_events_info, task_thread_times_info_data_t, machine_info_data_t, machine_slot_data_t * include/mach_debug/mach_debug_types.defs: ipc_info_name_t, ipc_info_name_array_t Tested by bootstrapping a Hurd system from scratch. Message-Id: <Y2dD7Z60Bwybg4jF@viriathus>
* std_types: Drop char, short and int type definitionsSamuel Thibault2022-09-181-3/+0
| | | | | These are provided by mig since ecf59842e472 ("Make MIG recognize the basic C integral types."), released in snapshot v1.8+git20200618.
* copyinmsg: Set msgh_size inside copyinmsg rather than the callerSamuel Thibault2022-08-281-1/+1
| | | | | In the 32/64 conversion case it is copyinmsg that will know the eventual size.