aboutsummaryrefslogtreecommitdiff
path: root/x86_64
Commit message (Collapse)AuthorAgeFilesLines
* x86_64: expand and shrink messages in copy{in, out}msg routinesLuca Dariz2023-01-183-81/+363
| | | | | | | | | | | | | | | | | | | * 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>
* Set max-page-size when linking the kernel to 0x1000.Flavio Cruz2023-01-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* intr: Drop irq parameterSamuel Thibault2022-12-241-5/+2
| | | | This is not actually used.
* x86_64: stdint.h no longer exists so don't install itFlavio Cruz2022-12-191-1/+0
| | | | Message-Id: <Y6Bw/vU85SK5GrMZ@mars>
* x86_64: fix buildSamuel Thibault2022-11-271-1/+1
|
* Revert "x86_64: fix installing x86_64-specific headers"Samuel Thibault2022-11-271-17/+17
| | | | | | | | 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.
* Update kdb_kintr according to new interrupt stack layoutSamuel Thibault2022-11-272-2/+8
| | | | | | | | 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.
* x86_64: Add missing int_entry_table entries for APICSamuel Thibault2022-11-151-0/+15
| | | | | 214866d58ac2 ("Add ioapic support disabled by default") missed adding them for x86_64.
* interrupt: Fix saving irq/ipl when linux drivers are disabledSamuel Thibault2022-09-171-13/+31
| | | | | | | | | | | | | | 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!
* x86_64: fix buildSamuel Thibault2022-09-171-1/+1
|
* copyinmsg: Set msgh_size inside copyinmsg rather than the callerSamuel Thibault2022-08-281-2/+4
| | | | | In the 32/64 conversion case it is copyinmsg that will know the eventual size.
* x86_64: fix installing x86_64-specific headersSamuel Thibault2022-08-281-17/+17
|
* Fix inclusability of <mach/mach_types.h>Samuel Thibault2022-08-281-0/+1
| | | | | Now that mach/machine/vm_types.h uses stdint types, we have to ship a header that defines them.
* Fix building x86_64 xen platformSamuel Thibault2022-08-273-46/+38
| | | | | 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.
* add rpc_versions for vm typesLuca Dariz2022-08-271-1/+11
| | | | | | | | | | | | | | | * 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>
* fix register corruption in irq on qemuLuca Dariz2022-08-271-6/+6
| | | | | | | | | 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>
* x86_64 boothdr: Fix _start symbol for multiboot address overridesSamuel Thibault2022-08-271-7/+5
| | | | | | 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.
* add support for booting from grub with x86_64Luca Dariz2022-08-273-11/+272
| | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Ship x86_64/x86_64 and x86_64/include/mach/x86_64Samuel Thibault2022-02-061-1/+3
| | | | | * Makefrag.am (EXTRA_DIST): Ship the x86_64/x86_64 and x86_64/include/mach/x86_64 symlinks.
* Makefrag.am: Move architecture condition inside architecture Makefrag.amSamuel Thibault2022-02-061-17/+10
| | | | | 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: Fix installation target of headersSamuel Thibault2021-09-181-2/+2
| | | | | | | * 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>
* ioapic: Refactor EOIDamien Zammit2021-04-051-1/+0
| | | | Message-Id: <20210405115921.184572-2-damien@zamaudio.com>
* Don't call EOI on spurious interruptsDamien Zammit2021-04-051-6/+3
| | | | Message-Id: <20210405052916.174771-4-damien@zamaudio.com>
* SMP: fix getting the interrupt stack address and sizeSamuel Thibault2021-04-041-0/+1
| | | | | | | * 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.
* Add ioapic support disabled by defaultDamien Zammit2021-04-041-1/+23
| | | | | | | 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>
* x86: Pave the way for xsave/xrstor supportSamuel Thibault2020-11-281-1/+5
| | | | | | | | | | | | | * 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.
* Disable com3 and com4Samuel Thibault2020-11-221-1/+2
| | | | | | | | We do not support shared IRQs for these, so avoid boot issues when running on a system with more than 2 com ports. * i386/configfrag.ac (ncom) [at:i?86]: Set to 2. * x86_64/configfrag.ac (ncom) [at:x86_64]: Set to 2.
* 64bit: fix buildSamuel Thibault2020-07-181-0/+2
| | | | | | | * 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.
* mach_trap_table: Fix 64bit versionSamuel Thibault2020-04-061-1/+1
| | | | | | | The addition of the mach_trap_name field made the 64bit unused field spurious. * kern/syscall_sw.h (mach_trap_t): Remove `unused' field.
* Share ncom, lpr, PAE definitions between i386 and x86_64Samuel Thibault2020-03-291-12/+3
| | | | | | | | | | | | Otherwise the x86_64 configfrag would overwrite i386's. * i386/configfrag.ac: Remove ncom, nlpr, pae, NCOM, NLPR, PAE definitions. * i386/configfrag.ac: Remove ncom, nlpr, NCOM, NLPR, PAE definitions. Enable PAE. * configfrag-first.ac: New file, defines ncom, nlpr, pae. * configure.ac: Include configfrag-first.ac * configfrag.ac: Define NCOM, NLPR, PAE.
* x86_64: drop unused functionsSamuel Thibault2020-03-291-122/+0
| | | | | * x86_64/locore.S (dr6, dr0, dr1, dr2, dr3): Remove functions. (dr_msk, dr_addr): Remove variables.
* x86_64: Fix map address given to linkerSamuel Thibault2020-03-291-1/+1
| | | | | | | See VM_MIN_KERNEL_ADDRESS. * x86_64/Makefrag.am (gnumach_LINKFLAGS): Set _START to _START_MAP+0x40000000 instead of +0xC0000000.
* Enable x86_64 build for atEtienne Brateau2020-03-291-0/+6
| | | | * x86_64/Makefrag.am: Add instructions to build
* spl: Fix assembly filesEtienne Brateau2020-03-291-4/+4
| | | | * x86_64/spl.S: fix instruction length
* Enable at x86_64 buildSamuel Thibault2020-03-281-0/+19
| | | | | | | | | | * x86_64/configfrag.ac (ncom, nplr) [!at:x86_64]: Set to 0. (ncom) [at:x86_64]: Set to 4. (nlpr) [at:x86_64]: Set to 1. (ATX86_64): Define to 1. (NCOM): Define. (NLPR): Define. * configure.ac [at:x86_64]: Accept combination.
* kdasm: Fix 64bit buildSamuel Thibault2020-03-281-3/+3
| | | | | * x86_64/kdasm.S (count): Fix type to 32bit. (kd_slmscu, kd_slmscd): Fix getting count as 32bit.
* IDT: fix entries formatSamuel Thibault2020-03-281-2/+2
| | | | | * i386/i386/idt.c (idt_init_entry): Set entrypoint type to unsigned long. * x86_64/idt_inittab.S (IDT_ENTRY): Fix entry format accordingly.
* interrupt: Add 64bit variantSamuel Thibault2020-03-281-0/+84
| | | | * x86_64/interrupt.S: New file.
* kdasm: Add 64bit variantSamuel Thibault2020-03-281-0/+133
| | | | | | * i386/i386at/kdasm.S (start, count, value, from, to): Use B_ARG* instead of reimplementing them. * x86_64/kdasm.S: New file.
* build system: Add 64bit variantSamuel Thibault2020-03-282-0/+319
| | | | | | | | | 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.
* Add 64bit/32bit compatibility symlinksSamuel Thibault2020-03-282-0/+2
| | | | | | This makes inclusions easier. * x86_64/include/mach/x86_64, x86_64/x86_64: New symlinks.
* xen: Add 64bit variantSamuel Thibault2020-03-282-0/+335
| | | | * x86_64/xen_boothdr.S, x86_64/xen_locore.S: New files.
* spl: Add 64bit variantSamuel Thibault2020-03-281-0/+255
| | | | * x86_64/spl.S: New file.
* locore: Add 64bit variantSamuel Thibault2020-03-281-0/+1580
| | | | * x86_64/locore.S: New file.
* ldscript: Add 64bit variantSamuel Thibault2020-03-281-0/+219
| | | | * x86_64/ldscript: New file.
* idt_inittab: Add 64bit variantSamuel Thibault2020-03-281-0/+146
| | | | * x86_64/idt_inittab.S: New file.
* debug_trace: Add 64bit variantSamuel Thibault2020-03-281-0/+56
| | | | * x86_64/debug_trace.S: New file.
* cswitch: Add 64bit variantSamuel Thibault2020-03-281-0/+150
| | | | * x86_64/cswitch.S: New file.
* setjmp: Add 64bit variantSamuel Thibault2020-03-281-0/+65
* x86_64/_setjmp.S: New file * i386/i386/setjmp.h (jmp_buf): Add 64bit variant.