| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
* 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>
|
| |
|
|
|
|
|
|
|
|
|
| |
File was removed in a previous patch for i386.
To avoid future problems, include some common files between i386 and
x86_64 in i386/Makefrag_x86.am. It is also easier to see what is different and
what lacks support for x86_64 (e.g., SMP).
Message-Id: <Y9DXOiP+ClYdj68Z@jupiter.tail36e24.ts.net>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* i386/i386/io_map.c: code is unused.
* i386/i386/io_perm.c: include mig prototypes.
* i386/i386/mp_desc.c: Deleted interrupt_stack_alloc since it is not
used.
* i386/i386/seg.h: Moved descriptor structs to i386/include/mach/i386/mach_i386_types.h
as that represents the interface types for RPCs.
Defined aliases for real_descriptor since those are used by the i386 RPCs. Inlined many
functions here too and removed seg.c.
* i386/i386/seg.c: Removed. All the functions are inline now.
* i386/i386/trap.c: Use static.
* i386/i386/trap.h: Define missing prototypes.
* i386/i386/tss.h: Use static inline for ltr.
* i386/i386/user_ldt.c: Include mig prototypes.
* i386/include/mach/i386/mach_i386.defs: Define real_descriptor_t types
since those are used in the RPC definition. Now both prototypes and
definitions will match.
* i386/include/mach/i386/mach_i386_types.h: Move struct descriptor
from seg.h since we need those for the RPC interfaces. Removed include
of io_perm.h since it generates circular includes otherwise.
* i386/intel/pmap.c: pmap_map is unused. Added static qualifier for
several functions.
* i386/intel/pmap.h: pmap_update_interrupt declared for non-SMP and SMP.
Message-Id: <Y89+R2VekOQK4IUo@jupiter.lan>
|
|
|
|
| |
message.h is installed so we need to hide these behind a mach_ prefix
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With the exception of linux, x86_64 ld default's max-page-size
is 2MB (default for i386 is 4K) and compiling gnumach with x86_64-pc-gnu-ld
will generate a kernel image where the boot section starts at the file offset
2MB. This makes it unbootable on grub because the file is no longer multiboot.
Here's the objdump -h output before the patch:
Sections:
Idx Name Size VMA LMA File off Algn
0 .boot 0000c000 0000000001000000 0000000001000000 00200000 2**12
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text 0009078f 000000004100c000 000000000100c000 0020c000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .rodata 000110fc 000000004109c7a0 000000000109c7a0 0029c7a0 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .eh_frame 000101f0 00000000410ad8a0 00000000010ad8a0 002ad8a0 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .data 000070a0 00000000412bdaa0 00000000012bdaa0 002bdaa0 2**5
CONTENTS, ALLOC, LOAD, DATA
5 .bss 00023f10 00000000412c5000 00000000012c5000 002c4b40 2**12
ALLOC
6 .comment 00000012 0000000000000000 0000000000000000 002c4b40 2**0
CONTENTS, READONLY
After, when forcing ld's max-page-size to be 4K:
Sections:
Idx Name Size VMA LMA File off Algn
0 .boot 0000c000 0000000001000000 0000000001000000 00001000 2**12
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text 0009078f 000000004100c000 000000000100c000 0000d000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .rodata 000110fc 000000004109c7a0 000000000109c7a0 0009d7a0 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .eh_frame 000101f0 00000000410ad8a0 00000000010ad8a0 000ae8a0 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .data 000070a0 00000000410beaa0 00000000010beaa0 000beaa0 2**5
CONTENTS, ALLOC, LOAD, DATA
5 .bss 00023f10 00000000410c6000 00000000010c6000 000c5b40 2**12
ALLOC
6 .comment 00000012 0000000000000000 0000000000000000 000c5b40 2**0
CONTENTS, READONLY
It is also possible that something is wrong with the linker script but
couldn't find anything concrete so far. After this patch the kernel is
bootable with x86_64-pc-gnu-ld (and far smaller in size).
Message-Id: <Y7uJYpIsovhShREj@jupiter.tail36e24.ts.net>
|
|
|
|
| |
This is not actually used.
|
|
|
|
| |
Message-Id: <Y6Bw/vU85SK5GrMZ@mars>
|
| |
|
|
|
|
|
|
|
|
| |
This reverts commit 8c58257c4da364ffcb797f9d454c37de939a052b.
These headers are actually coming from i386. This change was making
`make dist` try to build the x86_64/include/mach/x86_64 directory in the
dist tarball.
|
|
|
|
|
|
|
|
| |
e2fcf261076b ("interrupt: Fix saving irq/ipl when linux drivers are
disabled") changed the stack layout for interrupt handlers, but missed
updating kdb_kintr's code that tries to mangle it.
This restores the control-alt-d shortcut.
|
|
|
|
|
| |
214866d58ac2 ("Add ioapic support disabled by default") missed adding
them for x86_64.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When Linux drivers are disabled, in hardclock() the linux_timer_intr()
call is dropped, and gcc can tail-recursion-optimize the call to
clock_interrupt(). To do so, it overwrites the hardclock() parameters to
suit the clock_interrupt parameters layout. This however means it thrashes
the backups that the interrupt() function had made of irq/ipl, leading to
mayhem.
interrupt should thus really properly separate its irq/ipl backups from the
interrupt function parameters.
Thanks a lot to Etienne Brateau for the tricky investigation!
|
| |
|
|
|
|
|
| |
In the 32/64 conversion case it is copyinmsg that will know the
eventual size.
|
| |
|
|
|
|
|
| |
Now that mach/machine/vm_types.h uses stdint types, we have to ship a
header that defines them.
|
|
|
|
|
| |
On Xen we do not have a separate boot section, we directly start at the
kernel map address. We thus do not have a map shift.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* vm_types.h: add new types and conversion functions
* mach_types.defs: adapt vm types depending on kernel user/server
* vm_info.h: adapt rpc structure to have uniformly-sized members also
on 64-bit
* x86_64/configfrag.c: add new option to select the user-space variant.
Note that with this change the user-space interface is somehow fixed,
i.e. it can't support 32-bit and 64-bit tasks at the same time.
If this would be needed at some point, this change needs to be reworked.
Signed-off-by: Luca Dariz <luca@orpolo.org>
Message-Id: <20220403145955.120742-3-luca@orpolo.org>
|
|
|
|
|
|
|
|
|
| |
rbx was used to compute the irq index in iunit and ivect arrays,
however it should be preserved by pushing it in to the stack. As a
solution, we use rax instead, which is caller-saved.
Signed-off-by: Luca Dariz <luca@orpolo.org>
Message-Id: <20220205175129.309469-4-luca@orpolo.org>
|
|
|
|
|
|
| |
We shouldn't be needing that since we won't use a.out for 64bit, but using
address override in the multiboot header could be useful at least for
testing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure: compile for native x86_64 by default instead of xen
* x86_64/Makefrag.am: introduce KERNEL_MAP_BASE to reuse the constant
in both code and linker script
* x86_64/ldscript: use a .boot section for the very first operations,
until we reach long mode. This section is not really allocated, so
it doesn't need to be freed later. The vm system is later
initialized starting from .text and not including .boot
* link kernel at 0x4000000 as the xen version, higher values causes
linker errors
* we can't use full segmentation in long mode, so we need to create a
temporary mapping during early boot to be able to jump to high
addresses
* build direct map for first 4G in boothdr, it seems required by Linux
drivers
* add INTEL_PTE_PS bit definition to enable 2MB pages during bootstrap
* ensure write bit is set in PDP entry access rights. This only
applies to PAE-enabled kernels, mandatory for x86_64. On xen
platform it seems to be handled differently
Signed-off-by: Luca Dariz <luca@orpolo.org>
Message-Id: <20220205175129.309469-2-luca@orpolo.org>
|
|
|
|
|
| |
* Makefrag.am (EXTRA_DIST): Ship the x86_64/x86_64 and
x86_64/include/mach/x86_64 symlinks.
|
|
|
|
|
| |
Otherwise we cannot use _DIST there and have them all taken into account.
As a consequence, we can drop duplicate _DIST between i386 and x86_64.
|
|
|
|
|
|
|
| |
* x86_64/Makefrag.am (include_mach_i386dir): Rename to include_mach_x86_64dir, set to $(includedir)/mach/x86_64.
(include_mach_i386_HEADERS): Rename to include_mach_x86_64_HEADERS.
Reported-by: Andrea Monaco <andrea.monaco@autistici.org>
|
|
|
|
| |
Message-Id: <20210405115921.184572-2-damien@zamaudio.com>
|
|
|
|
| |
Message-Id: <20210405052916.174771-4-damien@zamaudio.com>
|
|
|
|
|
|
|
| |
* i386/i386at/boothdr.S (_eintstack): Add missing common.
* i386/xen/xen_boothdr.S (_eintstack): Add missing common.
* x86_64/xen/xen_boothdr.S (_eintstack): Add missing common.
* i386/i386/mp_desc.c (intstack, eintstack): Add missing underscore.
|
|
|
|
|
|
|
| |
Use --enable-ncpus=x --enable-apic where x > 1 for SMP+APIC support.
Use neither for no SMP and old PIC support.
Message-Id: <20210404050812.145483-1-damien@zamaudio.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* i386/i386/fpu.h (xgetbv, get_xcr0, xsetbv, set_xcr0): New inline
functions.
(xsave, xrstor): New macros.
* i386/i386/locore.S (cpu_features): Extend to two words.
(cpu_features_edx, cpu_features_ecx): New labels.
(discover_x86_cpu_type): Also save ecx cpuid(1) report.
* x86_64/locore.S: Likewise.
* i386/i386/locore.h (cpu_features): Extend to two words.
(CPU_FEATURE_XSAVE): New macro.
* i386/i386/proc_reg.h (CR4_OSXSAVE): New macro.
|