aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* x86_64: Attempt to fix ast_from_interruptSergey Bugaev2023-05-171-1/+2
| | | | Message-Id: <20230517181150.65810-1-bugaevc@gmail.com>
* Fix task_info for TASK_THREAD_TIMES_INFO.Flavio Cruz2023-05-172-1/+13
| | | | | | We are checking for the existence of time_value64_t but we didn't add that to the task_thread_times_info structure. Message-Id: <ZGRDbS0XIm1fJwkG@jupiter.tail36e24.ts.net>
* x86_64: Fix reporting fsgs base in thread_get_state ()Sergey Bugaev2023-05-151-1/+1
| | | | | Fixes 31dd30a94a682955c3c9e2f42252b4a07687067a "add setting gs/fsbase". Message-Id: <20230515074434.1351060-1-bugaevc@gmail.com>
* x86_64: Check for AST when exiting a syscallSergey Bugaev2023-05-121-3/+25
| | | | | | | | | | ...like it's already done when exiting a trap. This is required, since handing a syscall can result in an AST; in particular this happens when the current thread is being terminated, which sets AST_TERMINATE and expects the thread to never return to userspace. Fixes a kernel crash upon calling exit () or pthread_exit () in glibc. Message-Id: <20230511192859.890693-1-bugaevc@gmail.com>
* x86_64: Fix updating fsgs base on context switchSergey Bugaev2023-05-121-4/+5
| | | | | | | | | | | | Commit 31dd30a94a682955c3c9e2f42252b4a07687067a "add setting gs/fsbase" added the code to set fs and gs bases on context_switch. However, this was only being done when switching context via the explicit switch_context() method, but not in other cases where the context is switched, such as with call_continuation(). Instead, put setting fsgs base into switch_ktss(), where it will be called in all cases. Message-Id: <20230511135844.837338-1-bugaevc@gmail.com>
* Do not expose CPU_TYPE_X86_64 when running 32bit userlandSamuel Thibault2023-05-111-1/+1
| | | | So that userland's uname -m still reports i686-AT386.
* Keep host_get_kernel_version for USER32-on-x86_64 caseSamuel Thibault2023-05-112-2/+2
|
* Remove host_kernel_version RPC for x86_64Flavio Cruz2023-05-112-4/+10
| | | | | | | We can fast track the simplification of the RPC ABI for x86_64 if we don't have MACH_MSG_TYPE_STRING used in RPCs which forces msgt_size to use more than 8 bits. Message-Id: <ZFht+/9cVPHuV90D@jupiter.tail36e24.ts.net>
* Delete include/mach/rpc.hFlavio Cruz2023-05-065-38/+0
| | | | | File is unused. Message-Id: <ZFSSbAzZ+7KYKtOF@jupiter.tail36e24.ts.net>
* x86_64: Add CPU_TYPE_X86_64 CPU typeSamuel Thibault2023-05-062-0/+5
|
* Use designated initializers in kern/ipc_kobject.cFlavio Cruz2023-05-051-7/+8
| | | | | msgt_deallocate was not initialized explicitly, this fixes that too. Message-Id: <ZFM2cLr1Ms/B3v8U@jupiter.tail36e24.ts.net>
* Improve portability for device/net_io.c and use designated initializersFlavio Cruz2023-05-051-15/+17
| | | | Message-Id: <ZFMz+B3dsMAWl3hM@jupiter.tail36e24.ts.net>
* 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-023-13/+3
| | | | | | | | | * 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-015-21/+116
| | | | | | | | | | | * 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>
* x86_64: add 64-bit syscall entry pointLuca Dariz2023-05-019-20/+294
| | | | | | | | | | | | | | | | | | | | | | | | | While theoretically we could still use the same call gate as for 32-bit userspace, it doesn't seem very common, and gcc seems to not encode properly the instruction. Instead we use syscall/sysret as other kernels (e.g. XNU,Linux). This version still has some limitations, but should be enough to start working on the 64-bit user space. * i386/i386/i386asm.sym: add more constants to fill pcb->iss * i386/i386/ldt.c: configure 64-bit syscall entry point. We can just check for the SEP bit as MSR are always available on x86_64. * i386/i386/ldt.h: swap CS/DS segments order if !USER32 as required by sysret * i386/i386/locore.h: add syscall64 prototype * i386/i386/msr.h: add MSR definitions and C read/write helpers * i386/include/mach/i386/syscall_sw.h: remove old BSD_TRAP * x86_64/Makefrag.am: selectively install syscall_sw.h depending on USER32 * x86_64/include/syscall_sw.h: add entry point template from user space * x86_64/locore.S: implement syscall64 entry point and use it when a 64-bit user-space is configured Message-Id: <20230419194703.410575-4-luca@orpolo.org>
* Use c_string for dev_name_t in the device subsystem.Flavio Cruz2023-04-294-0/+39
| | | | | | | | | | | | Added device_open_new and device_open_new_request and reused the old MiG ID for xxx_device_set_status which has not been in used in the past decade. Note that device_open_new is gated on defining DEVICE_ENABLE_DEVICE_OPEN_NEW because otherwise some hurd servers wouldn't compile anymore unless patched. This macro allows us to control the rollout. Message-Id: <ZEi1LV+9ShuXqtcr@jupiter.tail36e24.ts.net>
* Update task_basic_info and thread_basic_info to include time_value64_t data.Flavio Cruz2023-04-274-9/+37
| | | | | | 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>
* fix copyoutmsg for 64-bit userspaceLuca Dariz2023-04-201-3/+2
| | | | | * x86_64/copy_user.c: use the correct user/kernel msg structure Message-Id: <20230419194703.410575-2-luca@orpolo.org>
* fix address fault for 32-on-64-bit syscallLuca Dariz2023-04-201-2/+2
| | | | | | * x86_64/locore.S: the faulty address is found in %rbp and not in %rsi, so copy that in CR2 Message-Id: <20230419194703.410575-1-luca@orpolo.org>
* Fix Xen buildSamuel Thibault2023-04-113-30/+32
|
* Fix missing shipping required headerSamuel Thibault2023-04-101-0/+1
|
* Delete include/mach/default_pager_helper.defsFlavio Cruz2023-04-102-54/+0
| | | | | Not used. Message-Id: <ZDN13tll1jYc1jYh@jupiter.tail36e24.ts.net>
* Remove host_get_boot_info and host_get_kernel_boot_info since they are not used.Flavio Cruz2023-04-075-58/+2
| | | | | | 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-043-10/+19
| | | | | | | | | | | * 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-037-21/+37
| | | | | | | | | 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-032-50/+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>
* Add i386_fsgs_base_stateSergey Bugaev2023-04-031-0/+8
| | | | Message-Id: <20230319151017.531737-2-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-138-104/+81
| | | | | | | | 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 host_get_time64 in glue codeFlavio Cruz2023-03-131-1/+4
| | | | Message-Id: <ZA64CbpYEz+BgiEw@jupiter.tail36e24.ts.net>
* Use c_string to define host_get_kernel_version and host_get_kernel_boot_info.Flavio Cruz2023-03-135-4/+40
| | | | | | | | | | | | | | 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>
* ioapic: Timer calibrated in 10 mach ticksDamien Zammit2023-03-111-5/+4
| | | | | | | | hz variable is the number of mach ticks in 1 second. We want to know how many lapic ticks in 1 mach tick. Therefore, we set a timer for 10 mach ticks and divide the lapic stopwatch counter value by 10. Message-Id: <20230311072937.450161-1-damien@zamaudio.com>
* Align mach_msg_type_t and mach_msg_type_long_t with the same alignment as ↵Flavio Cruz2023-03-083-48/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lock_mon: Fix warningsSamuel Thibault2023-03-073-9/+16
|
* kern: Fix MACH_LOCK_MON lock monitoring debugDamien Zammit2023-03-076-11/+24
| | | | | | | | 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>
* apic: Drop declaration of inexisting functionSamuel Thibault2023-03-071-1/+0
|
* lapic timer: Calibrate via mach timer not PITDamien Zammit2023-03-073-38/+54
| | | | | | | | | | | Previously the lapic timer was calibrated by one-shot PIT timer2. This method can be buggy and generally unused in emulation environments. This patch reworks the timer calibration to use a mach timer based on regular PIT interrupts to remapped IOAPIC pin. This also changes the primary clock source to use PIT timer0 remapped to an IOAPIC pin when APIC mode is enabled, instead of a periodic lapic timer. Message-Id: <20230306070452.292697-1-damien@zamaudio.com>
* Support alignment requirements for a 64 bit kernel.Flavio Cruz2023-02-273-113/+101
| | | | | | | | | | | | | 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>
* x86_64: fix user trap during syscall with an invalid user stackLuca Dariz2023-02-272-12/+12
| | | | | | | * i386/i386/locore.h: user vm_offset_t in the recovery_table * x86_64/locore.S: fix RECOVERY() location and keep user regs in %rbx, as it seems the convention. This only applies to 32-bit userspace. Message-Id: <20230227204501.2492152-5-luca@orpolo.org>
* fix port name copyinLuca Dariz2023-02-271-0/+2
| | | | | | | * x86_64/copy_user.c: in mach_msg_user_header_t there are some holes that need to be cleared, to adapt to the different layout of mach_msg_header_t. Message-Id: <20230227204501.2492152-4-luca@orpolo.org>
* fix copyin/outmsg header for ! USER32Luca Dariz2023-02-271-2/+2
| | | | | | * x86_64/copy_user.c: fix copyin/out, we already have a pointer to user/kernel buffers Message-Id: <20230227204501.2492152-3-luca@orpolo.org>
* x86_64: allow compilation if ! USER32Luca Dariz2023-02-271-2/+4
| | | | | | * i386/intel/pmap.c: remove #error and allow compilation, keeping a reminder to fix the pmap module. Message-Id: <20230227204501.2492152-2-luca@orpolo.org>
* lapic timer: Calibrate based on 10 PIT sleeps for 10msDamien Zammit2023-02-261-8/+11
| | | | | | NB: This relies on a fix for QEMU as one-shot PIT mode is currently broken in qemu. Message-Id: <20230226013110.50606-1-damien@zamaudio.com>
* pit: Use corrected clock frequencyDamien Zammit2023-02-261-1/+1
| | | | | | All PC compatibles operate the PIT at a clock rate of (105/88) MHz Message-Id: <20230226063555.66284-1-damien@zamaudio.com>
* pit: Fix shadowed hz variable && define modes correctlyDamien Zammit2023-02-262-8/+9
| | | | Message-Id: <20230226013052.50577-1-damien@zamaudio.com>
* kd_mouse: Fix IBM mouse irq getting stuck and blocking consoleDamien Zammit2023-02-251-2/+5
| | | | | | TESTED: With and without apic/smp Message-Id: <20230225061420.16985-1-damien@zamaudio.com>