summaryrefslogtreecommitdiff
path: root/ipc
AgeCommit message (Collapse)Author
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>
2023-11-29Use MACH_PORT_NAME_NULL and MACH_PORT_NAME_DEAD when checking for null or ↵Flavio Cruz
dead rights Comparing mach_port_name_t that is MACH_PORT_NAME_DEAD against MACH_PORT_DEAD will always return false. Message-ID: <ZWbMBrk7qrl15sKL@jupiter.tail36e24.ts.net>
2023-11-19ipc_entry_lookup_failed: Also write message id in bogus port warningSamuel Thibault
It may be enough to get an idea of the origin of the port without having to produce a stack trace.
2023-11-18ipc_entry_lookup: Generalize warnings about bogus port namesSamuel Thibault
Looking up a bogus port name is generally a sign of a real bug, such as a spurious mach port deallocation.
2023-11-07Fix assertion for i686 since mach_port_name_t and mach_port_t have the same sizeFlavio Cruz
Message-ID: <ZUlwWGgc2kXNH5dN@jupiter.tail36e24.ts.net>
2023-11-0164bit: Fix user memory leaks on non-inline port arraysSamuel Thibault
The userland allocation is for port names, not ports (as translated below), so we need to allocate less.
2023-10-01copyinmsg: Check that we have not overflownSamuel Thibault
This if of course too late in case of a failure, but better assert than get awful bugs, and it's really not supposed to happen.
2023-10-01ipc: Fix allocating kernel buffer for storing user messageSamuel Thibault
Otherwise ipc_kmsg_copyin_body will overflow.
2023-10-01Add and use ikm_cache_alloc/free/_trySamuel Thibault
2023-10-01mach_port_names: Make sure we did not overflow the allocated areaSamuel 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-06-18Fix copying in MACH_PORT_DEAD on x86_64Sergey Bugaev
We need to properly convert MACH_PORT_NAME_DEAD (which is 32-bit -1) into IO_DEAD, which is 64-bit -1. To reproduce: $ portinfo -va 1 (see the Mach crash trying to access a port at 0xffffffff) Message-Id: <20230615181731.119328-1-bugaevc@gmail.com>
2023-05-06Delete include/mach/rpc.hFlavio Cruz
File is unused. Message-Id: <ZFSSbAzZ+7KYKtOF@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-12fix port name size in notificationsLuca Dariz
* ipc/ipc_machdep.h: define PORT_NAME_T_SIZE_IN_BITS * ipc/ipc_notify.c: fix port name size in notification message templates Message-Id: <20230212170313.1501404-6-luca@orpolo.org>
2023-02-08slock: Fix initialization of statically-allocated slocksSamuel Thibault
(this is actually a no-op for i386)
2023-01-25Set kr if copy cannot be copied to user spaceFlavio Cruz
Compiler will complain otherwise that kr is not initialized. Message-Id: <Y89oVcEnyPIiQ4ef@jupiter.tail36e24.ts.net>
2023-01-19Remove existing old style definitions and use -Wold-style-definition.Flavio Cruz
Message-Id: <Y8mYd/pt/og4Tj5I@mercury.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-19Include mig generated headers to avoid warnings with -Wmissing-prototypes.Flavio Cruz
This also reverts 566c227636481b246d928772ebeaacbc7c37145b and 963b1794d7117064cee8ab5638b329db51dad854 Message-Id: <Y8d75KSqNL4FFInm@mercury.tail36e24.ts.net>
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-18x86_64: expand and shrink messages in copy{in, out}msg routinesLuca 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 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>
2023-01-18add msg_user_header_t for user-side msg structureLuca 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 Message-Id: <20230116105857.240210-2-luca@orpolo.org>
2023-01-16fix warningsLuca Dariz
* ipc/ipc_kmsg.c: drop useless cast. * ipc/ipc_port.c: upcast rpc_vm_offset_t to full vm_offset_t * kern/pc_sample.c: Likewise Message-Id: <20230116130426.246584-4-luca@orpolo.org>
2023-01-16remove unused file ipc/mach_rpc.cLuca Dariz
* Makefrag.am: remove ipc/mach_rpc.c * ipc/mach_rpc.c: remove file, all functions here seem unused. Message-Id: <20230116130426.246584-3-luca@orpolo.org>
2023-01-13Create kern/mach4.h and kern/mach_host.h and define the RPC prototypes for ↵Flavio Cruz
mach4.defs and mach_host.defs. Also move more mach_debug rpcs to kern/mach_debug.h. Message-Id: <Y7+LPMLOafUQrNHZ@jupiter.tail36e24.ts.net>
2023-01-13Use rpc_uintptr_t for protected payloads.Flavio Cruz
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>
2023-01-10Preemptively fix warnings that will be caused by -Wmissing-prototypesFlavio Cruz
Declared RPCs in ipc/mach_port.c and ddb/db_ext_symtab.c in their corresponding headers. Ideally these should be used by mig instead of mig declaring its own prototypes. Message-Id: <Y7z/BQhmsBbRgxhe@jupiter.tail36e24.ts.net>
2022-12-27Fix some warnings with -Wmissing-prototypes.Flavio Cruz
Marked some functions as static (private) as needed and added missing includes. This also revealed some dead code which was removed. Note that -Wmissing-prototypes is not enabled here since there is a bunch more warnings. Message-Id: <Y6j72lWRL9rsYy4j@mars>
2022-12-22Drop spurious changesv1.8+git20221224Samuel Thibault
2022-12-22Warn only once about not being able to recycle pagesSamuel Thibault
2022-12-21Use -Wstrict-prototypes and fix warningsFlavio Cruz
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>
2022-12-11Delete rpc copyout multiname codeFlavio Cruz
Message-Id: <Y5V+BovjWo1CCjBc@jupiter.tail36e24.ts.net>
2022-12-03Use mach_port_name_t in a few more placesFlavio Cruz
A few places that I missed in 958686efa2175abe3f7044890c2c2370e29147f2. Message-Id: <Y4g+4THLC/1NvnkM@viriathus>
2022-11-30Update ipc/ directory to use mach_port_name_tFlavio Cruz
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>
2022-11-29Add missing gitignore rulesSamuel Thibault
2022-11-25Delete ipc_info.h since it is not usedFlavio Cruz
Message-Id: <Y35PHuUNCFb6sQO0@viriathus>
2022-08-28copyinmsg: Set msgh_size inside copyinmsg rather than the callerSamuel Thibault
In the 32/64 conversion case it is copyinmsg that will know the eventual size.
2022-08-28kmsg: factorize uint32_t into an alignment typeSamuel Thibault
and restore the checks for offset alignment in the message, even if currently it is trivially always alright.
2022-08-28kmsg: fix msg body alignmentLuca Dariz
* ipc/ipc_kmsg.c: align msg body to 4 bytes as done in mig Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220628101054.446126-7-luca@orpolo.org>
2022-08-28use port name type in mach_port_names()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 <luca@orpolo.org> Message-Id: <20220628101054.446126-9-luca@orpolo.org>
2022-08-28compute mach port size from the corresponding typeLuca 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 <luca@orpolo.org> Message-Id: <20220628101054.446126-5-luca@orpolo.org>
2022-08-28simplify ipc_kmsg_copyout_body() usageLuca 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 <luca@orpolo.org> Message-Id: <20220628101054.446126-3-luca@orpolo.org>
2020-03-29mach_port: Fix 64bit warningsSamuel Thibault
* ipc/mach_port.c (mach_port_destroy, mach_port_deallocate): Cast sizeof to int.
2019-08-11Fix formatSamuel Thibault
* ipc/mach_port.c (mach_port_mod_refs): Fix passing string size.
2019-08-11Fix printf formatSamuel Thibault
* ipc/mach_port.c (mach_port_destroy, mach_port_deallocate): Fix format.
2018-08-13Drop spurious changesSamuel Thibault
2018-08-13Fix building out of sourceSamuel Thibault
* configure.ac: Fix patching Makefile.in in $srcdir.
2017-10-23Drop the register qualifier.Justus Winter
* i386/intel/pmap.c: Drop the register qualifier. * ipc/ipc_kmsg.h: Likewise. * kern/bootstrap.c: Likewise. * kern/profile.c: Likewise. * kern/thread.c: Likewise. * vm/vm_object.c: Likewise.