| 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>
|
|
|
|
| |
Message-Id: <20230925002417.467022-1-damien@zamaudio.com>
|
|
|
|
| |
Message-Id: <20230925002353.466997-1-damien@zamaudio.com>
|
|
|
|
| |
They are called from context that has gs initialized.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This speeds up smp again, by storing the struct processor
in a percpu area and avoiding an expensive cpu_number every call
of current_processor(), as well as getting the cpu_number by
an offset into the percpu area. Untested on 64 bit
and work remains to use other percpu arrays.
TESTED: (NCPUS=8) -smp 1 boots to login shell ~2x slower than uniprocessor
TESTED: (NCPUS=8) -smp 2 boots to INIT but hangs there
TESTED: (NCPUS=8) -smp 4 gets stuck seemingly within rumpdisk and hangs
TESTED: (NCPUS=1) uniprocessor is a bit faster than normal
Message-Id: <20230924103428.455966-3-damien@zamaudio.com>
|
|
|
|
| |
Message-Id: <20230924052824.449219-2-damien@zamaudio.com>
|
| |
|
|
|
|
| |
Message-Id: <20230816014440.2322705-1-damien@zamaudio.com>
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
With the kernel gone to -2GB, the base+index addressing needs to use a 64bit
register index.
|
|
|
|
|
|
|
|
|
|
|
|
| |
5da1aea7ab3c ("Acknoledge interrupt after handler call") moved the IRQ ack
to after calling the handler because of overflows. But that was because the
interrupts were getting enabled at some point. Now that all spl levels
above 0 just disable interrupts, once we have called spl7 we are safe
until splx_cli is called (and even that doesn't release interrupts, only
the eventual iret will).
And if the handler triggers another IRQ, it will be lost, so we do want
to ack the IRQ before handling it.
|
| |
|
|
|
|
|
| |
In case interrupts were already disabled before TIME_TRAP_[US]ENTRY are
called, we don't want to execute sti.
|
|
|
|
| |
Message-Id: <20230805154843.2003098-1-damien@zamaudio.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* i386/i386/db_interface.c: don't set unused segment selectors on full
64-bit
* i386/i386/db_trace.c: likewise.
* i386/i386/i386asm.sym: likewise.
* i386/i386/pcb.c:: likewise.
* i386/i386/thread.h: remove ES/DS/FS/GS from thread state on !USER32,
as they are unused in this configuration. Only SS and CS are kept.
* x86_64/locore.S: convert segment handling macros to no-op on full
64-bit
Message-Id: <20230729174753.1145878-5-luca@orpolo.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The actual values are not saved together with the rest of the thread
state, both because it would be quite espensive (reading MSR, unless
rdfsbase instructions are supported, but that's optional) and not
really needed. The only way the user has to change its value is with a
specific RPC, so we can intercept the change easily. Furthermore,
Leaving the values there exposes them to being corrupted in case of a
double interruption, e.g. an irq is handled just before iretq but
after starting to restore the thread state. This solution was
suggested by Sergey Bugaev.
* i386/i386/db_trace.c: remove fsbase/gsbase from the registers
available
* i386/i386/debug_i386.c: remove fsbase/gsbase from the printed thread
state
* i386/i386/i386asm.sym: remove fsbase/gsbase as it's not needed in
asm anymore
* i386/i386/pcb.c: point fsbase/gsbase to the new location
* i386/i386/thread.h: move fsbase/gsbase to the machine state
* x86_64/locore.S: generalize segment-handling including es/ds/gs/fs
and remove fsbase/gsbase handling. Also, factor out kernel segment
selector setting to a macro.
Message-Id: <20230729174753.1145878-4-luca@orpolo.org>
|
|
|
|
| |
Message-Id: <20230729174753.1145878-3-luca@orpolo.org>
|
|
|
|
|
|
|
|
| |
* i386/i386/pcb.c: simplify exception stack location and adapt thread
gettrs/setters
* i386/i386/thread.h: don't include V86 fields on full 64-bit
* x86_64/locore.S: don't include checks for V86 mode on full 64-bit
Message-Id: <20230729174753.1145878-2-luca@orpolo.org>
|
|
|
|
|
|
|
|
| |
* x86_64/locore.S: ensure the thread state is filled completely even
on recursive interrups. The value of the segment selectors is not
very important in this case, but we still need to align the stack to
the bottom of i386_interrupt_state.
Message-Id: <20230729174753.1145878-1-luca@orpolo.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* i386/i386/idt.c: add selector for the interrupt-specific stack
* i386/i386/ktss.c: configure ist1 to use a dedicated stack
* i386/i386/trap.c: add double fault handler, which just prints the
state and panics. There is not much else to do in this case but it's
useful for troubleshooting
* x86_64/idt_inittab.S: allow to specify an interrupt stack for custom
handlers
* x86_64/locore.S: add double fault handler
Message-Id: <20230729174514.1145656-1-luca@orpolo.org>
|
|
|
|
|
|
|
|
|
|
|
| |
When entering a syscall we're still using the user stack, so we can't
reliably handle exceptions or interrupts, otherwise a user thread can
easily crash the machine with an invalid stack. Instead, disable
interrupts and (hopefullly) avoid traps in the fragments where we need
to have the user stack in RSP.
* i386/i386/ldt.c: mask interrupts and IOPL on syscall entry
* x86_64/locore.S: keep interrupts disabled when we use the user stack
|
|
|
|
|
| |
* x86_64/boothdr.S: there is no reason to not use it right away
Message-Id: <20230615214931.189270-1-luca@orpolo.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When copying messages from user space, some messages may have
mach_msg_type_t with msgt_number = 0 and no data after. This is a valid
message and we want to allow that.
I found this bug when testing "[PATCH gnumach] Update the
64bit RPC ABI to be simpler" and attempting to run a basic Hurd x86_64 that can start a
bash shell. When mach_msg_type_long_t is the same size as
mach_msg_type_t this bug happens quite frequently and prevents the
system from starting properly.
Message-Id: <ZIaiHnfrv6Y9hEel@jupiter.lan>
|
| |
|
|
|
|
|
|
|
| |
* i386/i386at/acpi_parse_apic.c: use vm_offset_t instead of uint32_t
for vm addresses
* x86_64/Makefrag.am: support --enable-apic
Message-Id: <20230521204918.492957-1-luca@orpolo.org>
|
| |
|
|
|
|
|
|
| |
* x86_64/locore.S: fix PUSH_FSGS -> _ISR and always make room for
fsgsbase on a 64-bit kernel.
Message-Id: <20230518210839.655403-1-luca@orpolo.org>
|
|
|
|
| |
Message-Id: <20230517181150.65810-1-bugaevc@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
...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>
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
* x86_64/copy_user.c: use the correct user/kernel msg structure
Message-Id: <20230419194703.410575-2-luca@orpolo.org>
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
| |
* 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>
|
| |
|
|
|
|
| |
Message-Id: <20230213084919.1157074-6-damien@zamaudio.com>
|
|
|
|
|
|
|
|
| |
This has several advantages:
1) We don't need to resize mach_msg_header_t, it is just a copy.
2) Mig won't require any changes because it statically computes the size
of mach_msg_header_t, otherwise we would need two sizes (28 vs 32 bytes).
Message-Id: <Y+l8UhXXX9Qo9tVA@jupiter.tail36e24.ts.net>
|
|
|
|
|
|
|
|
|
|
| |
Protected payloads will be 8-byte longs which are the same size as
kernel ports.
Also aligned all the structures to be 4-byte aligned since it makes it
easier to parse them as padding won't be added to mach_msg_user_header_t
before the protected payload.
Message-Id: <Y+krwRFIUeyRszl9@jupiter.tail36e24.ts.net>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* i386/i386/vm_param.h: adjust constants to the new kernel map
- the boothdr.S code already sets up a temporary map to higher
addresses, so we can use INIT_VM_MIN_KERNEL_ADDRESS as in xen
- increase the kernel map size to accomodate for bigger structures
and more memory
- adjust kernel max address and directmap limit
* i386/i386at/biosmem.c: enable directmap check also on x86_64
* i386/include/mach/i386/vm_param.h: increase user virtual memory
limit as it's not conflicting with the kernel's anymore
* i386/intel/pmap.h: adjust lin2pdenum_cont() and INTEL_PTE_PFN to the
new kernel map
* x86_64/Makefrag.am: change KERNEL_MAP_BASE to be above 4G, and
according to mcmodel=kernel. This will allow to use the full memory
address space.
Message-Id: <20230212172818.1511405-10-luca@orpolo.org>
|
|
|
|
|
|
|
| |
* i386/i386/trap.c: change from int to a proper type to hold a
register value
* x86_64/locore.S: use 64-bit register to avoid address truncation
Message-Id: <20230212172818.1511405-8-luca@orpolo.org>
|
|
|
|
|
|
|
| |
* x86_64/interrupt.S: use 64-bit registers as variables could be
stored at high addresses
* x86_64/locore.S: Likewise
Message-Id: <20230212172818.1511405-3-luca@orpolo.org>
|
|
|
|
|
| |
Signed-off-by: Luca Dariz <luca@orpolo.org>
Message-Id: <20230212170313.1501404-7-luca@orpolo.org>
|