aboutsummaryrefslogtreecommitdiff
path: root/kern
Commit message (Collapse)AuthorAgeFilesLines
* Use designated initializers in kern/exception.cFlavio Cruz2023-05-041-28/+28
| | | | Message-Id: <ZFLq5/a9zzRHOlSf@jupiter.tail36e24.ts.net>
* Implement mig_deallocate to free memory when kernel server RPC succeedsFlavio Cruz2023-05-021-0/+10
| | | | | | | | | | | | In case the kernel interfaces use dynamically sized strings, we will end up calling mig_deallocate to free the out of line string that was copied into the kernel. As a matter of contract such type of data is freed automatically either in kernel code when the RPC fails or in the MiG stub if it succeeds. This was tested by changing task_set_name to use dynamic strings and making sure out of line data is passed when strlen(name) > 4. Message-Id: <ZFB64/0vOJ3x15ub@jupiter.tail36e24.ts.net>
* Use mig_support.h prototypes instead of duplicating them.Flavio Cruz2023-05-022-10/+2
| | | | | | | | | * 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>
* add setting gs/fsbaseLuca Dariz2023-05-011-0/+3
| | | | | | | | | | | * 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 handling, skipping the base address and avoid resetting it by manually re-loading fs/gs Message-Id: <20230419194703.410575-5-luca@orpolo.org>
* Update task_basic_info and thread_basic_info to include time_value64_t data.Flavio Cruz2023-04-272-9/+23
| | | | | | 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>
* Remove host_get_boot_info and host_get_kernel_boot_info since they are not used.Flavio Cruz2023-04-071-23/+0
| | | | | | host_get_kernel_boot_info was added recently to fix the use of MACH_MSG_TYPE_STRING. Message-Id: <ZC5Sz8a4FCT6IjCY@jupiter.tail36e24.ts.net>
* Align the user stack correctly for 64 bit programs.Flavio Cruz2023-04-041-2/+1
| | | | | | | | | | | * i386/i386/thread.h: Define USER_STACK_ALIGN which is 16-byte for 64 bit programs as recommended by the System V AMD64 guidelines. Also define KERNEL_STACK_ALIGN which can differ from user land. * i386/i386/pcb.c: Use USER_STACK_ALIGN to align the bootstrap arguments and ultimately the stack where the program starts on. * kern/bootstrap.c: Do not align arg_len here since it will be aligned in set_user_regs. Message-Id: <ZCpOb6vNEfPclKPr@jupiter.tail36e24.ts.net>
* Make exception subcode a longSergey Bugaev2023-04-033-16/+32
| | | | | | | | | 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>
* Track task and thread time using time_value64_t.Flavio Cruz2023-03-137-104/+76
| | | | | | | | 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/+16
| | | | | | | | | | | | | | 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>
* Update thread and task creation time to use time_value64_tFlavio Cruz2023-03-124-12/+9
| | | | Message-Id: <ZAzYoE7+ugFsH5JA@jupiter.tail36e24.ts.net>
* lock_mon: Fix warningsSamuel Thibault2023-03-073-9/+16
|
* kern: Fix MACH_LOCK_MON lock monitoring debugDamien Zammit2023-03-074-4/+17
| | | | | | | | TESTED: - by setting MACH_LOCK_MON to 1 in configfrag.ac and running "show all slocks" in kdb - does not break default configured kernel Message-Id: <20230306070512.292715-1-damien@zamaudio.com>
* x86_64: fix argument passing to bootstrap modules if ! USER32Luca Dariz2023-02-161-5/+5
| | | | | * kern/bootstrap.c: replace integers with long/vm_offset_t Message-Id: <20230216213318.2048699-3-luca@orpolo.org>
* x86_64: load Elf64 bootstrap modules if ! USER32Luca Dariz2023-02-161-5/+5
| | | | | | | | | * 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>
* Document spl levels of locks taken during interruptsSamuel Thibault2023-02-155-9/+15
|
* timer: Fix atomicity of timer readsSamuel Thibault2023-02-151-0/+4
| | | | | | Similarly to update_mapped_time/read_mapped_time, one need to synchronize the writes and read to make sure they are performed in the expected order.
* smp: Fix more busy loopsSamuel Thibault2023-02-153-7/+9
| | | | | We need to avoid the kernel optimizing away the reads from memory. Use a standard relaxing instruction for that.
* add more explicit names for user space virtual space limitsLuca Dariz2023-02-121-2/+2
| | | | | | | | | | * 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 Message-Id: <20230212172818.1511405-7-luca@orpolo.org>
* fix rpc time value for 64 bitLuca Dariz2023-02-124-3/+15
| | | | | | | | | | | | * 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>
* lock: Add missing def_simple_lock_data definition for ncpus=1Samuel Thibault2023-02-091-0/+2
|
* slock: Fix initialization of statically-allocated slocksSamuel Thibault2023-02-0810-18/+15
| | | | (this is actually a no-op for i386)
* Add host_set_time64 and host_adjust_time64Flavio Cruz2023-01-281-18/+49
| | | | | | Same existing logic, just with 64 bits. Old RPCs are implemented by calling into the new RPCs. Message-Id: <Y9TJAmL2byOWup5x@jupiter.tail36e24.ts.net>
* Fix several warnings for -Wmissing-prototypesFlavio Cruz2023-01-247-39/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * device/ds_routines.c: use static qualifier. * device/subrs.c: delete unused functions. * i386/i386/ast_check.c: include prototypes in kern/ast.h * i386/i386/db_disasm.c: Include prototypes in ddb/db_examine.h * i386/i386/db_interface.h: Define prototype for kdb_kentry. Expose debug methods feep and kd_debug_put. * i386/i386/db_trace.c: delete left over cthreads support, functions are not used. * i386/i386/model_dep.h: Define prototype for c_boot_entry. * i386/i386at/acpi_parse_apic.c: Static qualifiers. * i386/i386at/autoconf.c: Include header file for prototypes and remove dead code. * i386/i386at/autoconf.h: Fix prototype. * i386/i386at/com.c: Add static qualifiers, delete dead code. * i386/i386at/com.c: ditto. * i386/i386at/com.h: Define prototypes for debug functions. * i386/i386at/int_init.c: Include header. * i386/i386at/kd.c: Include header for debug interface. Remove dead kd_cmdreg_read and make xga_getpos static. * i386/i386at/kd_mouse.c: Static qualifiers. * i386/i386at/lpr.c: Dead lprpr. * i386/i386at/model_dep.c: Remove exit function. * kern/mach_clock.c: Include mig prototypes. * kern/mach_clock.h: Remove duplicates of mig prototypes. * kern/machine.c: Use static. * kern/startup.c: slave_main is unused. * kern/thread.h: Define thread_stats that is useful for debugging. * kern/timer.c: Keep db_thread_times since it can be used for debugging. * kern/timer.h: ditto. * linux/dev/glue/misc.c: Use mig header for host_get_time. Message-Id: <Y8oyiecaflCaYhaW@mercury.tail36e24.ts.net>
* Remove existing old style definitions and use -Wold-style-definition.Flavio Cruz2023-01-194-19/+10
| | | | Message-Id: <Y8mYd/pt/og4Tj5I@mercury.tail36e24.ts.net>
* Add host_get_time64 RPC to return the time as time_value64_tFlavio Cruz2023-01-192-26/+49
| | | | | | 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.
* Include mig generated headers to avoid warnings with -Wmissing-prototypes.Flavio Cruz2023-01-1915-280/+21
| | | | | | This also reverts 566c227636481b246d928772ebeaacbc7c37145b and 963b1794d7117064cee8ab5638b329db51dad854 Message-Id: <Y8d75KSqNL4FFInm@mercury.tail36e24.ts.net>
* replace mach_port_t with mach_port_name_tLuca Dariz2023-01-182-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* update writev syscall signature with rpc typesLuca Dariz2023-01-182-6/+6
| | | | | | | | | | * 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-182-34/+37
| | | | | | | | | * 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>
* add msg_user_header_t for user-side msg structureLuca Dariz2023-01-181-1/+1
| | | | | | | | | | | * 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>
* Add static qualifiersFlavio Cruz2023-01-182-2/+2
| | | | | stack_statistics, swapin_thread_continue, and memory_object_lock_page are not used outside their module.
* fix warningsLuca Dariz2023-01-161-1/+1
| | | | | | | * 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>
* add required includeLuca Dariz2023-01-161-0/+2
| | | | | | | * kern/syscall_sw.h: add missing include Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20230116130426.246584-2-luca@orpolo.org>
* Delete ffs and strrchr prototypes.Flavio Cruz2023-01-151-21/+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>
* Create kern/mach4.h and kern/mach_host.h and define the RPC prototypes for ↵Flavio Cruz2023-01-1310-0/+242
| | | | | | | 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>
* Preemptively fix warnings that will be caused by -Wmissing-prototypesFlavio Cruz2023-01-101-0/+40
| | | | | | | 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>
* Move cpu_down and other functions inside SMP ifdefFlavio Cruz2023-01-072-60/+60
| | | | | | | cpu_down is shown as not required when disabling SMP so moving it inside NCPUS > 1 to eliminate the warning. Note that the diff ended up looking a bit different due the way functions are laid out. Message-Id: <Y7ZH6aI3fhWNzyrY@jupiter.tail36e24.ts.net>
* Fix ddb warnings introduced with -Wstrict-prototypesFlavio Cruz2023-01-051-1/+3
| | | | | | | Changed some ddb command functions to have the expected signature but not all of them due to the being difficult to inter-dependency between header files (for those just used cast). Message-Id: <Y7UO9HTfpZ8U0Nfy@mars>
* Introduce time_value64_t to keep track of real time in the kernelFlavio Cruz2023-01-032-15/+16
| | | | | | | | | | | | 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.
* convert K&R into ansi.Guy-Fleury Iteriteka2023-01-011-13/+7
| | | | Message-Id: <Y7GBIF6mBjV6kBM+@falom>
* Delete kern_timestamp system call since it is not usedFlavio Cruz2022-12-276-141/+0
| | | | Message-Id: <Y6r72z4cKVCMDSKy@mars>
* Fix some warnings with -Wmissing-prototypes.Flavio Cruz2022-12-2714-36/+30
| | | | | | | | | | | 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>
* Use -Wstrict-prototypes and fix warningsFlavio Cruz2022-12-213-10/+8
| | | | | | | 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>
* Delete thread_get_state_KERNEL and thread_set_state_KERNELFlavio Cruz2022-12-111-41/+0
| | | | | | These are not used. Message-Id: <Y5V95ibk9Z+3OJxN@jupiter.tail36e24.ts.net>
* Update kern/ directory to use mach_port_name_t.Flavio Cruz2022-12-078-17/+17
| | | | | Make it clear where exactly we use port names vs port addresses. Message-Id: <Y5AdJGuzXBMO7YRK@reue>
* Use long_natural_t in kern/task.h and kern/slab.hFlavio Cruz2022-12-072-12/+12
| | | | | | RPC interfaces already use long_natural_t so internally we can also use this type. Message-Id: <Y5AdPNqg4l5jAZ3n@reue>
* 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>
* task: Add task_set_essentialSamuel Thibault2022-12-032-1/+18
| | | | | | | | 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-306-78/+79
| | | | | | | | | | | | | | | 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>