summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2016-05-18GNU Mach 1.7v1.7Thomas Schwinge
* version.m4 (AC_PACKAGE_VERSION): Set to 1.7. * NEWS: Finalize for 1.7.
2016-05-18Fix gcc-6 warningsSamuel Thibault
* ddb/db_elf.c (elf_db_sym_init): Turn `i' into unsigned. * device/ds_routines.c (ds_device_open, device_writev_trap): Likewise. * i386/i386/user_ldt.c (i386_set_ldt): Likewise for `i', `min_selector', and `first_desc'. (i386_get_ldt): Likewise for `ldt_count'. (user_ldt_free): Likewise for `i'. * i386/i386/xen.h (hyp_set_ldt): Turn `count' into unsigned long. * i386/intel/pmap.c (pmap_bootstrap): Turn `i', `j' and 'n' into unsigned. (pmap_clear_bootstrap_pagetable): Likewise for `i' and `j'. * ipc/ipc_kmsg.c (ipc_msg_print): Turn `i' and `numwords' into unsigned. * kern/boot_script.c (boot_script_parse_line): Likewise for `i'. * kern/bootstrap.c (bootstrap_create): Likewise for `n' and `i'. * kern/host.c (host_processors): Likewise for `i'. * kern/ipc_tt.c (mach_ports_register): Likewise. * kern/mach_clock.c (tickadj, bigadj): turn into unsigned. * kern/processor.c (processor_set_things): Turn `i' into unsigned. * kern/task.c (task_threads): Likewise. * kern/thread.c (consider_thread_collect, stack_init): Likewise. * kern/strings.c (memset): Turn `i' into size_t. * vm/memory_object.c (memory_object_lock_request): Turn `i' into unsigned. * xen/block.c (hyp_block_init): Use %u format for evt. (device_open): Drop unused err variable. (device_write): Turn `copy_npages', `i', `nbpages', and `j' into unsigned. * xen/console.c (hypcnread, hypcnwrite, hypcnclose): Turn dev to dev_t. (hypcnclose): Return void. * xen/console.h (hypcnread, hypcnwrite, hypcnclose): Fix prototypes accordingly. * xen/evt.c (form_int_mask): Turn `i' into int. * xen/net.c (hyp_net_init): Use %u format for evt. (device_open): Remove unused `err' variable.
2016-05-17Revert "Fix getting ELF symbol bind and type"Samuel Thibault
This reverts commit a8a52cafb5621b475737ffdc81f63703d5b37904. It seems to be breaking backtracing in ddb...
2016-05-16Fix pageout deadlockRichard Braun
The pageout daemon uses small, internal, temporary objects to transport the data out to memory managers, which are expected to release the data once written out to backing store. Releasing this data is done with a vm_deallocate call. The problem with this is that vm_map is allowed to merge these objects, in which case vm_deallocate will only remove a reference instead of releasing the underlying pages, causing the pageout daemon to deadlock. This change makes the pageout daemon mark these objects so that they don't get merged. * vm/vm_object.c (vm_object_bootstrap): Update template. (vm_object_coalesce): Don't coalesce if an object is used for pageout. * vm/vm_object.h (struct vm_object): New `used_for_pageout` member. * vm/vm_pageout.c (vm_pageout_page): Mark new objects for pageout.
2016-05-15Fix warningRichard Braun
ddb/db_output.c (db_printf): Return 0. ddb/db_printf.h (db_printf): Change declaration to return an int.
2016-04-21Fix xen bootSamuel Thibault
* i386/i386/pcb.c (pcb_init): Make sure there is a thread before calling current_task().
2016-04-20Fix type of program counter argumentJustus Winter
* i386/i386/hardclock.c (hardclock): Use '0' instead of 'NULL'. * vm/vm_fault (vm_fault_cleanup): Likewise.
2016-04-20xen: fix buildJustus Winter
* i386/xen/xen.c (hypclock_machine_intr): Fix 'clock_interrupt' call. * xen/time.c (clkstart): Likewise.
2016-04-20Add kernel profiling through samplingSamuel Thibault
* NEWS: Advertise feature. * configfrac.ac (--enable-kernsample): Add option. * kern/pc_sample.h (take_pc_sample): Add usermode and pc parameter. (take_pc_sample_macro): Take usermode and pc parameters, pass as such to take_pc_sample. * kern/pc_sample.c (take_pc_sample): Use pc parameter when usermode is 1. * kern/mach_clock.c (clock_interrupt): Add pc parameter. Pass usermode and pc to take_pc_sample_macro call. * i386/i386/hardclock.c (hardclock): Pass regs->eip to clock_interrupt call on normal interrupts, NULL on interrupt interrupt. * vm/vm_fault.c (vm_fault_cleanup): Set usermode to 1 and pc to NULL in take_pc_sample_macro call.
2016-04-17Add memory barrier to spl*Samuel Thibault
* i386/i386/spl.S (mb): Define macro (SETIPL, spl0, spl7): Call mb.
2016-04-17Avoid using C99 for variable declaration for nowSamuel Thibault
* kern/gsync.c (gsync_setup): Declare `i' variable out of for loop.
2016-04-15update NEWS fileSamuel Thibault
2016-04-15Lightweight synchronization mechanismAgustina Arzille
* Makefrag.am (libkernel_a_SOURCES): Add kern/gsync.c and kern/gsync.h. * include/mach/gnumach.defs (gsync_wait, gsync_wake, gsync_requeue): New routines. * include/mach/kern_return.h (KERN_TIMEDOUT, KERN_INTERRUPTED): New error codes. * kern/gsync.c: New file. * kern/gsync.h: New file. * kern/startup.c: Include <kern/gsync.h> (setup_main): Call gsync_setup.
2016-04-15Update NEWS fileJustus Winter
2016-04-15Add --disable-assert flag to disable assertionsJustus Winter
* configfrag.ac: Use 'AC_HEADER_ASSERT'. Signed-off-by: Justus Winter <justus@gnupg.org>
2016-04-15i386: Fix error handlingJustus Winter
* i386/i386at/model_dep.c (i386at_init): Fix error handling. Signed-off-by: Justus Winter <justus@gnupg.org>
2016-04-05Fix bootstraping issues with stdint.h.Flavio Cruz
* include/mach/std_types.h: Do not include stdint.h. * kern/rdxtree.h: Replace sys/types.h with stdint.h.
2016-04-04Follow-up stdint useSamuel Thibault
7bbfa39f59dcbc55b21d31abb9e2febef6a51ebb ('Use uint32_t instead of unsigned32_t.') missed some Xen code * xen/net.c (recompute_checksum): Use stdint.h types. * xen/time.c (hyp_get_stime): Likewise.
2016-04-04Use uint32_t instead of unsigned32_t.Flavio Cruz
Implement stdint.h and use it in gnumach. Remove old type definitions such as signed* and unsigned*. * Makefile.am: Add -ffreestanding. * i386/i386/xen.h: Use uint64_t. * i386/include/mach/i386/machine_types.defs: Use uint32_t and int32_t. * i386/include/mach/i386/vm_types.h: Remove definitions of int*, uint*, unsigned* and signed* types. * i386/xen/xen.c: Use uint64_t. * include/device/device_types.defs: Use uint32_t. * include/mach/std_types.defs: Use POSIX types. * include/mach/std_types.h: Include stdint.h. * include/stdint.h: New file with POSIX types. * include/sys/types.h: Include stdint.h. * ipc/ipc_kmsg.c: Use uint64_t. * kern/exception.c: Use uint32_t. * linux/dev/include/linux/types.h: Remove POSIX types. * xen/block.c: Use uint64_t. * xen/net.c: Do not use removed unsigned*_t types. * xen/ring.h: Use uint32_t instead. * xen/store.c: Use uint32_t. * xen/store.h: Use uint32_t. * xen/time.c: Use POSIX types only. * xen/time.h: Use uint64_t.
2016-03-19Make kernel mapping start address configurableSamuel Thibault
and move it to 16MiB by default to free 24bit DMA area * i386/configfrag.ac (--with-_START_MAP): Add option, default to 0x1000000. * i386/Makefrag.am (_START_MAP): Set to $(_START_MAP). (_START): Set to _START_MAP+0xC0000000.
2016-03-19Fix getting ELF symbol bind and typeSamuel Thibault
ddb/db_elf.c (elf_db_search_symbol): Use ELF32_ST_BIND and ELF32_ST_TYPE to access symbol bind and type.
2016-03-13Avoid panics on physical memory exhaustionRichard Braun
* vm/vm_resident (vm_page_grab_contig): Return NULL instead of calling panic on memory exhaustion.
2016-03-11Ship missing filesSamuel Thibault
Makefrag.am (libkernel_a_SOURCES): Add kern/log2.h. (EXTRA_DIST): Add kern/exc.defs. i386/Makefrag.am (libkernel_a_SOURCES): Add i386/i386at/elf.h.
2016-03-11Merge remote-tracking branch 'remotes/origin/rbraun/vm_cache_policy'Richard Braun
Finally ;-).
2016-03-09Fix stack allocation on XenRichard Braun
Stack allocation on Xen can fail because of fragmentation. This change makes stack allocation use the slab allocator. * kern/thread.c (thread_stack_cache): New global variable. (stack_alloc): Use kmem_cache_alloc instead of vm_page_grab_contig. (stack_collect): Use kmem_cache_free instead of vm_page_free_contig. (kmem_cache_init): Initialize thread_stack_cache.
2016-03-09Relax slab allocation alignment constraintRichard Braun
* kern/slab.c (kmem_pagealloc_virtual): Pass alignment to function, call kmem_alloc_aligned when greater than a page. (kmem_pagealloc): Pass alignment to function. (kmem_slab_create): Update call to kmem_pagealloc. (kalloc): Likewise. (kmem_cache_compute_properties): Fix handling of color with large slab sizes. (kmem_cache_init): Allow alignment greater than the page size.
2016-03-06Inherit fpu control word from parent to childSamuel Thibault
* i386/i386/thread.h (struct pcb): Add init_control field. * i386/i386/fpu.h (fpinherit): New prototype. * i386/i386/fpu.c (fpinit): Add thread parameter. When init_control field is set, use that value instead of a hardcoded one. (fpinherit): New function. (fp_load): Pass thread parameter to fpinit(). * kern/thread.c (thread_create): Pass parent task to pcb_init(). * i386/i386/pcb.c (pcb_init): Add parent_task parameter, call fpinherit when it is equal to current_task().
2016-02-28ipc: add missing kernel object typeJustus Winter
* ipc/ipc_object.c (ikot_print_array): Add entry for IKOT_PAGER_PROXY.
2016-02-28doc: clarify memory object initializationJustus Winter
* doc/mach.texi: Mention another way how a memory manager can signal that an object is ready.
2016-02-28i386: add parts of cpu.h from x15Justus Winter
* i386/Makefrag.am (libkernel_a_SOURCES): Add new file. * i386/i386/cpu.h: New file.
2016-02-26include: avoid generating unused client stubsJustus Winter
* include/mach/mach.defs: Avoid generating unused client stubs, some of which use an unreasonable amount of stack space and showed up in compiler warnings.
2016-02-26Document thread_sleep about events woken from interrupt handlersSamuel Thibault
* kern/sched_prim.c (thread_sleep): Document case of events woken from interrupt handlers.
2016-02-26Document why code is not racySamuel Thibault
* i386/i386at/kd_mouse.c (kd_mouse_read): Document why the assert_wait/thread_block pair is not racy.
2016-02-23Include the exception protocol in 'gnumach.msgids'Justus Winter
* Makefrag.am: Include the exception protocol in 'gnumach.msgids'. * kern/exc.defs: New file.
2016-02-22Remove kmem cache flags from the debugging interfaceRichard Braun
* include/mach_debug/slab_info.h (CACHE_FLAGS_NO_CPU_POOL, CACHE_FLAGS_SLAB_EXTERNAL, CACHE_FLAGS_NO_RECLAIM, CACHE_FLAGS_VERIFY, CACHE_FLAGS_DIRECT): Remove macros. * kern/slab.c (host_slab_info): Pass raw cache flags to caller.
2016-02-22Fix slab allocator option handlingRichard Braun
The slab allocator has grown to use multiple ways to allocate slabs as well as track them, which got a little messy. One consequence is the breaking of the KMEM_CF_VERIFY option. In order to make the code less confusing, this change expresses all options as explicit cache flags and clearly defines their relationships. The special kmem_slab and vm_map_entry caches are initialized accordingly. * kern/slab.c (KMEM_CF_DIRECTMAP): Rename to ... (KMEM_CF_PHYSMEM): ... this new macro. (KMEM_CF_DIRECT): Restore macro. (KMEM_CF_USE_TREE, KMEM_CF_USE_PAGE): New macros. (KMEM_CF_VERIFY): Update value. (kmem_pagealloc_directmap): Rename to... (kmem_pagealloc_physmem): ... this new function. (kmem_pagefree_directmap): Rename to ... (kmem_pagefree_physmem): ... this new function. (kmem_pagealloc, kmem_pagefree): Update macro names. (kmem_slab_use_tree): Remove function. (kmem_slab_create, kmem_slab_destroy): Update according to the new cache flags. (kmem_cache_compute_sizes): Rename to ... (kmem_cache_compute_properties): ... this new function, and update to properly set cache flags. (kmem_cache_init): Update call to kmem_cache_compute_properties. (kmem_cache_alloc_from_slab): Check KMEM_CF_USE_TREE instead of calling the defunct kmem_slab_use_tree function. (kmem_cache_free_to_slab): Update according to the new cache flags. kmem_cache_free_verify): Add assertion. (slab_init): Update initialization of kmem_slab_cache. * kern/slab.h (KMEM_CACHE_DIRECTMAP): Rename to ... (KMEM_CACHE_PHYSMEM): ... this new macro. * vm/vm_map.c (vm_map_init): Update initialization of vm_map_entry_cache.
2016-02-22Optimize slab lookup on the free pathRichard Braun
Caches that use external slab data but allocate slabs from the direct physical mapping can look up slab data in constant time by associating the slab data directly with the underlying page. * kern/slab.c (kmem_slab_use_tree): Take KMEM_CF_DIRECTMAP into account. (kmem_slab_create): Set page private data if relevant. (kmem_slab_destroy): Clear page private data if relevant. (kmem_cache_free_to_slab): Use page private data if relevant. * vm/vm_page.c (vm_page_init_pa): Set `priv' member to NULL. * vm/vm_page.h (vm_page_set_priv, vm_page_get_priv): New functions.
2016-02-22Fix unused variable warningsRichard Braun
* kern/slab.c (slab_init): Remove unused variables.
2016-02-20Avoid slab allocation failures caused by memory fragmentationRichard Braun
Since the slab allocator has been changed to sit directly on top of the physical allocator, failures caused by fragmentation have been observed, as one could expect. This change makes the slab allocator revert to kernel virtual memory when allocating larger-than-page slabs. This solution is motivated in part to avoid the complexity of other solutions such as page mobility, and also because a microkernel cannot be extended to new arbitrary uncontrolled usage patterns such as a monolithic kernel with loadable modules. As such, large objects are rare, and their use infrequent, which is compatible with the use of kernel virtual memory. * kern/slab.c: Update module description. (KMEM_CF_SLAB_EXTERNAL, KMEM_CF_VERIFY): Update values. (KMEM_CF_DIRECT): Remove macro. (KMEM_CF_DIRECTMAP): New macro. (kmem_pagealloc_directmap, kmem_pagefree_directmap, kmem_pagealloc_virtual, kmem_pagefree_virtual): New functions. (kmem_pagealloc, kmem_pagefree, kmem_slab_create, kmem_slab_destroy, kalloc, kfree): Update to use the new pagealloc functions. (kmem_cache_compute_sizes): Update the algorithm used to determine slab size and other cache properties. (kmem_slab_use_tree, kmem_cache_free_to_slab, host_slab_info): Update to correctly use the cache flags. (slab_init): Add KMEM_CACHE_DIRECTMAP to the kmem_slab_cache init flags. * kern/slab.h (KMEM_CACHE_VERIFY): Change value. (KMEM_CACHE_DIRECTMAP): New macro. * vm/vm_map.c (vm_map_init): Add KMEM_CACHE_DIRECTMAP to the vm_map_entry_cache init flags.
2016-02-16Avoid panics on physical memory exhaustionRichard Braun
* vm/vm_resident (vm_page_grab): Return NULL instead of calling panic on memory exhaustion.
2016-02-14Reduce VM_KERNEL_MAP_SIZESamuel Thibault
Now that KMEM_MAP_SIZE (128MiB) has been removed. * i386/i386/vm_param.h (VM_KERNEL_MAP_SIZE): Decrease by 128MiB.
2016-02-07vm: initialize external mapsJustus Winter
* vm/vm_external.c (vm_external_create): Initialize allocated maps.
2016-02-07Fix page cache accountingRichard Braun
* vm/vm_object.c (vm_object_bootstrap): Set template object `cached' member to FALSE. (vm_object_cache_add, vm_object_cache_remove): New functions. (vm_object_collect, vm_object_deallocate, vm_object_lookup, vm_object_lookup_name, vm_object_destroy): Use new cache management functions. (vm_object_terminate, vm_object_collapse): Make sure object isn't cached. * vm/vm_object.h (struct vm_object): New `cached' member.
2016-02-07vm: allocate a large map for all objects larger than SMALL_SIZEJustus Winter
* vm/vm_external.c (vm_external_create): Allocate a large map for all objects larger than SMALL_SIZE. 'vm_external_state_{g,s}et' can deal with offsets larger than 'LARGE_SIZE', so currently objects larger than 'LARGE_SIZE' are missing out on the optimization.
2016-02-07vm: remove unused field from struct vm_externalJustus Winter
* vm/vm_external.h (struct vm_external): Remove unused field 'existence_count'.
2016-02-07Remove kmem mapRichard Braun
Now that the slab allocator doesn't use kernel virtual memory any more, this map has become irrelevant. * kern/slab.c (KMEM_MAP_SIZE): Remove macro. (kmem_map_store, kmem_map): Remove variables. (slab_init): Remove call kmem_submap. * kern/slab.h (kmem_map): Remove extern declaration.
2016-02-06Change computation of slab sizeRichard Braun
Allocating directly out of the physical memory allocator makes the slab allocator vulnerable to failures due to fragmentation. This change makes the slab allocator use the lowest possible size for its slabs to reduce the chance of contiguous allocation failures. * kern/slab.c (KMEM_MIN_BUFS_PER_SLAB, KMEM_SLAB_SIZE_THRESHOLD): Remove macros. (kmem_cache_compute_sizes): Update the algorithm used to determine slab size and other cache properties.
2016-02-02Fix various memory managment errorsRichard Braun
A few errors were introduced in the latest changes. o Add VM_PAGE_WAIT calls around physical allocation attempts in case of memory exhaustion. o Fix stack release. o Fix memory exhaustion report. o Fix free page accounting. * kern/slab.c (kmem_pagealloc, kmem_pagefree): New functions (kmem_slab_create, kmem_slab_destroy, kalloc, kfree): Use kmem_pagealloc and kmem_pagefree instead of the raw page allocation functions. (kmem_cache_compute_sizes): Don't store slab order. * kern/slab.h (struct kmem_cache): Remove `slab_order' member. * kern/thread.c (stack_alloc): Call VM_PAGE_WAIT in case of memory exhaustion. (stack_collect): Call vm_page_free_contig instead of kmem_free to release pages. * vm/vm_page.c (vm_page_seg_alloc): Fix memory exhaustion report. (vm_page_setup): Don't update vm_page_free_count. (vm_page_free_pa): Check page parameter. (vm_page_mem_free): New function. * vm/vm_page.h (vm_page_free_count): Remove extern declaration. (vm_page_mem_free): New prototype. * vm/vm_pageout.c: Update comments not to refer to vm_page_free_count. (vm_pageout_scan, vm_pageout_continue, vm_pageout): Use vm_page_mem_free instead of vm_page_free_count, update types accordingly. * vm/vm_resident.c (vm_page_free_count, vm_page_free_count_minimum): Remove variables. (vm_page_free_avail): New variable. (vm_page_bootstrap, vm_page_grab, vm_page_release, vm_page_grab_contig, vm_page_free_contig, vm_page_wait): Use vm_page_mem_free instead of vm_page_free_count, update types accordingly, don't set vm_page_free_count_minimum. * vm/vm_user.c (vm_statistics): Likewise.
2016-02-02Fix unused variable warningsRichard Braun
* i386/i386at/biosmem.c (biosmem_bootstrap): Remove unused variables.
2016-02-02Stack the slab allocator directly on top of the physical allocatorRichard Braun
In order to increase the amount of memory available for kernel objects, without reducing the amount of memory available for user processes, a new allocation strategy is introduced in this change. Instead of allocating kernel objects out of kernel virtual memory, the slab allocator directly uses the direct mapping of physical memory as its backend. This largely increases the kernel heap, and removes the need for address translation updates. In order to allow this strategy, an assumption made by the interrupt code had to be removed. In addition, kernel stacks are now also allocated directly from the physical allocator. * i386/i386/db_trace.c: Include i386at/model_dep.h (db_i386_reg_value): Update stack check. * i386/i386/locore.S (trap_from_kernel, all_intrs, int_from_intstack): Update interrupt handling. * i386/i386at/model_dep.c: Include kern/macros.h. (int_stack, int_stack_base): New variables. (int_stack_high): Remove variable. (i386at_init): Update interrupt stack initialization. * i386/i386at/model_dep.h: Include i386/vm_param.h. (int_stack_top, int_stack_base): New extern declarations. (ON_INT_STACK): New macro. * kern/slab.c: Include vm/vm_page.h (KMEM_CF_NO_CPU_POOL, KMEM_CF_NO_RECLAIM): Remove macros. (kmem_pagealloc, kmem_pagefree, kalloc_pagealloc, kalloc_pagefree): Remove functions. (kmem_slab_create): Allocate slab pages directly from the physical allocator. (kmem_slab_destroy): Release slab pages directly to the physical allocator. (kmem_cache_compute_sizes): Update the slab size computation algorithm to return a power-of-two suitable for the physical allocator. (kmem_cache_init): Remove custom allocation function pointers. (kmem_cache_reap): Remove check on KMEM_CF_NO_RECLAIM. (slab_init, kalloc_init): Update calls to kmem_cache_init. (kalloc, kfree): Directly fall back on the physical allocator for big allocation sizes. (host_slab_info): Remove checks on defunct flags. * kern/slab.h (kmem_slab_alloc_fn_t, kmem_slab_free_fn_t): Remove types. (struct kmem_cache): Add `slab_order' member, remove `slab_alloc_fn' and `slab_free_fn' members. (KMEM_CACHE_NOCPUPOOL, KMEM_CACHE_NORECLAIM): Remove macros. (kmem_cache_init): Update prototype, remove custom allocation functions. * kern/thread.c (stack_alloc): Allocate stacks from the physical allocator. * vm/vm_map.c (vm_map_kentry_cache, kentry_data, kentry_data_size): Remove variables. (kentry_pagealloc): Remove function. (vm_map_init): Update calls to kmem_cache_init, remove initialization of vm_map_kentry_cache. (vm_map_create, _vm_map_entry_dispose, vm_map_copyout): Unconditionnally use vm_map_entry_cache. * vm/vm_map.h (kentry_data, kentry_data_size, kentry_count): Remove extern declarations. * vm/vm_page.h (VM_PT_STACK): New page type. * device/dev_lookup.c (dev_lookup_init): Update calls to kmem_cache_init. * device/dev_pager.c (dev_pager_hash_init, device_pager_init): Likewise. * device/ds_routines.c (mach_device_init, mach_device_trap_init): Likewise. * device/net_io.c (net_io_init): Likewise. * i386/i386/fpu.c (fpu_module_init): Likewise. * i386/i386/machine_task.c (machine_task_module_init): Likewise. * i386/i386/pcb.c (pcb_module_init): Likewise. * i386/intel/pmap.c (pmap_init): Likewise. * ipc/ipc_init.c (ipc_bootstrap): Likewise. * ipc/ipc_marequest.c (ipc_marequest_init): Likewise. * kern/act.c (global_act_init): Likewise. * kern/processor.c (pset_sys_init): Likewise. * kern/rdxtree.c (rdxtree_cache_init): Likewise. * kern/task.c (task_init): Likewise. * vm/memory_object_proxy.c (memory_object_proxy_init): Likewise. * vm/vm_external.c (vm_external_module_initialize): Likewise. * vm/vm_fault.c (vm_fault_init): Likewise. * vm/vm_object.c (vm_object_bootstrap): Likewise. * vm/vm_resident.c (vm_page_module_init): Likewise. (vm_page_bootstrap): Remove initialization of kentry_data.