| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
File is unused.
Message-Id: <ZFSSbAzZ+7KYKtOF@jupiter.tail36e24.ts.net>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
| |
(this is actually a no-op for i386)
|
|
|
|
|
| |
Compiler will complain otherwise that kr is not initialized.
Message-Id: <Y89oVcEnyPIiQ4ef@jupiter.tail36e24.ts.net>
|
|
|
|
| |
Message-Id: <Y8mYd/pt/og4Tj5I@mercury.tail36e24.ts.net>
|
|
|
|
| |
message.h is installed so we need to hide these behind a mach_ prefix
|
|
|
|
|
|
| |
This also reverts 566c227636481b246d928772ebeaacbc7c37145b and
963b1794d7117064cee8ab5638b329db51dad854
Message-Id: <Y8d75KSqNL4FFInm@mercury.tail36e24.ts.net>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
| |
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Message-Id: <Y5V+BovjWo1CCjBc@jupiter.tail36e24.ts.net>
|
|
|
|
|
| |
A few places that I missed in 958686efa2175abe3f7044890c2c2370e29147f2.
Message-Id: <Y4g+4THLC/1NvnkM@viriathus>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
| |
Message-Id: <Y35PHuUNCFb6sQO0@viriathus>
|
|
|
|
|
| |
In the 32/64 conversion case it is copyinmsg that will know the
eventual size.
|
|
|
|
|
| |
and restore the checks for offset alignment in the message, even if
currently it is trivially always alright.
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
| |
* ipc/mach_port.c (mach_port_destroy, mach_port_deallocate): Cast sizeof
to int.
|
|
|
|
| |
* ipc/mach_port.c (mach_port_mod_refs): Fix passing string size.
|
|
|
|
| |
* ipc/mach_port.c (mach_port_destroy, mach_port_deallocate): Fix format.
|
| |
|
|
|
|
| |
* configure.ac: Fix patching Makefile.in in $srcdir.
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
| |
* ddb/db_command.c (db_debug_all_traps_cmd): New declaration and
function.
(db_debug_port_references_cmd): Likewise.
* doc/mach.texi: Describe new commands.
* i386/i386/db_interface.h (db_debug_all_traps): New declaration.
* i386/i386/trap.c (db_debug_all_traps): New function.
* ipc/mach_port.c (db_debug_port_references): New function.
* ipc/mach_port.h (db_debug_port_references): New declaration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
First, user wiring is removed, simply because it has never been used.
Second, make the VM system track wiring requests to better handle
protection. This change makes it possible to wire entries with
VM_PROT_NONE protection without actually reserving any page for
them until protection changes, and even make those pages pageable
if protection is downgraded to VM_PROT_NONE.
* ddb/db_ext_symtab.c: Update call to vm_map_pageable.
* i386/i386/user_ldt.c: Likewise.
* ipc/mach_port.c: Likewise.
* vm/vm_debug.c (mach_vm_region_info): Update values returned
as appropriate.
* vm/vm_map.c (vm_map_entry_copy): Update operation as appropriate.
(vm_map_setup): Update member names as appropriate.
(vm_map_find_entry): Update to account for map member variable changes.
(vm_map_enter): Likewise.
(vm_map_entry_inc_wired): New function.
(vm_map_entry_reset_wired): Likewise.
(vm_map_pageable_scan): Likewise.
(vm_map_protect): Update wired access, call vm_map_pageable_scan.
(vm_map_pageable_common): Rename to ...
(vm_map_pageable): ... and rewrite to use vm_map_pageable_scan.
(vm_map_entry_delete): Fix unwiring.
(vm_map_copy_overwrite): Replace inline code with a call to
vm_map_entry_reset_wired.
(vm_map_copyin_page_list): Likewise.
(vm_map_print): Likewise. Also print map size and wired size.
(vm_map_copyout_page_list): Update to account for map member variable
changes.
* vm/vm_map.h (struct vm_map_entry): Remove `user_wired_count' member,
add `wired_access' member.
(struct vm_map): Rename `user_wired' member to `size_wired'.
(vm_map_pageable_common): Remove function.
(vm_map_pageable_user): Remove macro.
(vm_map_pageable): Replace macro with function declaration.
* vm/vm_user.c (vm_wire): Update call to vm_map_pageable.
|
|
|
|
|
| |
* ipc/mach_debug.c (mach_port_kernel_object): Check that the receiver
is valid.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since the replacement of the zone allocator, kernel objects have been
wired in memory. Besides, as of 5e9f6f (Stack the slab allocator
directly on top of the physical allocator), there is a single cache
used to allocate map entries.
Those changes make the pageability attribute of VM maps irrelevant.
* device/ds_routines.c (mach_device_init): Update call to kmem_submap.
* ipc/ipc_init.c (ipc_init): Likewise.
* kern/task.c (task_create): Update call to vm_map_create.
* vm/vm_kern.c (kmem_submap): Remove `pageable' argument. Update call
to vm_map_setup.
(kmem_init): Update call to vm_map_setup.
* vm/vm_kern.h (kmem_submap): Update declaration.
* vm/vm_map.c (vm_map_setup): Remove `pageable' argument. Don't set
`entries_pageable' member.
(vm_map_create): Likewise.
(vm_map_copyout): Don't bother creating copies of page entries with
the right pageability.
(vm_map_copyin): Don't set `entries_pageable' member.
(vm_map_fork): Update call to vm_map_create.
* vm/vm_map.h (struct vm_map_header): Remove `entries_pageable' member.
(vm_map_setup, vm_map_create): Remove `pageable' argument.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
* ipc/ipc_object.c (ikot_print_array): Add entry for IKOT_PAGER_PROXY.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|