| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
There might be good reasons why Mach on x86 shouldn't be built as PIC/
PIE, but there are also very good reasons to support PIE on other
architectures. Potentially implementing KASLR is one such reason; but
also the Linux AArch64 boot protocol (that the AArch64 port will use for
booting) lets the bootloader load the kernel image at any address,
which makes PIC pretty much required.
Message-ID: <20240327161841.95685-11-bugaevc@gmail.com>
|
|
|
|
| |
Message-ID: <20240309140244.347835-3-luca@orpolo.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
| |
* 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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
* device/ds_routines.c (ds_device_intr_register, ds_device_intr_ack)
[__x86_64__]: Disable.
* x86_64/Makefrag.am (libkernel_a_SOURCES): Add i386/i386/irq.c and
i386/i386/irq.h.
|
|
|
|
|
|
|
| |
See VM_MIN_KERNEL_ADDRESS.
* x86_64/Makefrag.am (gnumach_LINKFLAGS): Set _START to
_START_MAP+0x40000000 instead of +0xC0000000.
|
|
|
|
| |
* x86_64/Makefrag.am: Add instructions to build
|
|
Only Xen platform for now.
* Makefrag.am [HOST_x86_64]: Include x86_64/Makefrag.am.
* configure.ac: Include x86_64/configfrag.ac.
[default:x86_64] (host_platform): Set platform to xen.
* x86_64/Makefrag.am, x86_64/configfrag.ac: New files.
|