summaryrefslogtreecommitdiff
path: root/i386
AgeCommit message (Collapse)Author
2024-03-03pmap: Avoid leaking USER bit in page tablesSamuel Thibault
We should only set USER - for user processes maps - for 32bit Xen support This was not actually posing problem since in 32bit segmentation protects us, and in 64bit the l4 entry for the kernel is already set. But better be safe than sorry.
2024-03-03kernel traps: also catch general protection faultsSamuel Thibault
If userland passes a kernel pointer, it's not a page fault that we get, but a general protection fault. We also want to go through the recovery in that case, to make e.g. copyin/out return an error.
2024-02-23spl: Introduce assert_splvm and use it in process_pmap_updatesSamuel Thibault
Suggested-by: Damien Zammit <damien@zamaudio.com>
2024-02-22vm_map_lookup: Add parameter for keeping map lockedDamien Zammit
This adds a parameter called keep_map_locked to vm_map_lookup() that allows the function to return with the map locked. This is to prepare for fixing a bug with gsync where the map is locked twice by mistake. Co-Authored-By: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240222082410.422869-3-damien@zamaudio.com>
2024-02-19Introduce and use assert_splsched()Samuel Thibault
2024-02-19process_pmap_updates: Use _nocheck form of lock, already at splvmDamien Zammit
2024-02-18locore: Remove unnecessary call to CPU_NUMBERDamien Zammit
The cpu number is already in edx register, so use that.
2024-02-12Replace kernel header includes in include/mach/mach_types.h with forward ↵Flavio Cruz
declarations. I was trying to reuse TASK_NAME_SIZE in kern/thread.h but it was impossible because files included from kern/task.h end up requiring kern/thread.h (through percpu.h), creating a recursive dependency. With this change, mach_types.h only defines forward declarations and modules have to explicitly include the appropriate header file if they want to be able touch those structures. Most of the other includes are required because we no longer grab many different includes through mach_types.h. Message-ID: <20240212062634.1082207-1-flaviocruz@gmail.com>
2024-02-11smp: Fix unable to enter kdb during bootDamien Zammit
Message-ID: <20240211115958.1889648-1-damien@zamaudio.com>
2024-02-10Fix build with APIC without SMPSamuel Thibault
2024-02-09smp: Fix compile error with missing apboot_addrDamien Zammit
Message-ID: <20240209021108.1715770-1-damien@zamaudio.com>
2024-02-09smp: Fix INIT/STARTUP IPI sequenceDamien Zammit
TESTED: works in qemu TESTED: works hardware with AMD cpu Message-ID: <20240207050158.1640853-5-damien@zamaudio.com>
2024-02-09SMP: Fix allocating the apboot pageSamuel Thibault
vm_page_grab_contig does not necessarily allocate at the beginning of the DMA segment, so rather allocate by hand very early.
2024-02-08fpu: Fix cpuid feature detectionOlivier Valentin
Make sure to fetch capabilities from cpuid(0xd,0x1) Message-ID: <20240208165015.4700-3-valentio@free.fr>
2024-02-08Revert "fpu: Fix cpuid feature detection"Olivier Valentin
This reverts commit f8d0f98e80b3d7d9b24fa077818113fb0f4b3970. Message-ID: <20240208165015.4700-2-valentio@free.fr>
2024-02-08smp: Use HPET instead of pit one-shot that is unreliableDamien Zammit
NB: Every x86 board that uses ACPI most likely has a HPET since 2005. We can roll back to PIT in the cases where its not present, but the PIT one shot code is definitely currently broken. Message-ID: <20240207050158.1640853-4-damien@zamaudio.com>
2024-02-08Add HPET timer for small accurate delaysDamien Zammit
TESTED: This works in qemu correctly TESTED: This works on an AMD board with ACPI v2.0 correctly Message-ID: <20240207050158.1640853-3-damien@zamaudio.com>
2024-02-08separate lapic_enable from lapic_setupDamien Zammit
This initializes the lapic without turning on the IOAPIC interrupts during SMP init. Message-ID: <20240207050158.1640853-2-damien@zamaudio.com>
2024-02-05apboot: avoid self-modifying codeSamuel Thibault
self-modifying code is generally frowned upon, Intel largely says the support is model-dependent. We can as well just relocate from the C code like we did for the temporary gdt.
2024-02-05smp: Remove hardcoded AP_BOOT_ADDRDamien Zammit
This took some time to figure out. Involves a hand-crafted 16 bit assembly instruction [1] because it requires an immediate for the memory address of far jump. This required self-modifying code to inject the next instruction, therefore I added a near jump to clear the instruction cache queue in case the pipeline cached the unmodified jump location. [1] Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual
2024-02-05Fix apic_send_ipi function clobbering read only fieldsDamien Zammit
This was the root cause of failing to INIT. We were clobbering remote_read_status. And also, we need to reference the .r register when writing the ICR regs otherwise I think it writes all of the block. Message-ID: <20240205113327.1568218-2-damien@zamaudio.com>
2024-02-01ACPI: Support XSDT (ACPI >= v2.0)Damien Zammit
This enables gnumach to additionally parse the XSDT table if the revision of ACPI is 2. TESTED: Still works on qemu (ACPI v1.0) TESTED: Works on a x86 board with XSDT (ACPI v2.0) Message-ID: <20240131021218.1335821-1-damien@zamaudio.com>
2024-02-01model_dep: Fix serial console with APIC enabledDamien Zammit
Move cninit() further down so that IOAPIC has a chance to initialize before the com port interrupt is unmasked in the IOAPIC, fixing a fault and reboot. Message-ID: <20240131100210.1354522-1-damien@zamaudio.com>
2024-01-30Add vm_pages_physSamuel Thibault
For rumpdisk to efficiently determine the physical address, both for checking whether it is below 4GiB, and for giving it to the disk driver, we need a gnumach primitive (and that is not conditioned by MACH_VM_DEBUG like mach_vm_region_info and mach_vm_object_pages_phys are).
2024-01-30apic: Set up LAPICs in xAPIC modeDamien Zammit
Clear flag in msr for xAPIC mode. Message-ID: <20240130080405.1304381-1-damien@zamaudio.com>
2024-01-29Support up to two IOAPICs with up to 32 GSIs on eachDamien Zammit
Previously, only IOAPIC[0] was supported. Now this supports up to two IOAPICs. Message-ID: <20240129100652.1262126-1-damien@zamaudio.com>
2024-01-27fpu: Fix cpuid feature detectionOlivier Valentin
Make sure to fetch capabilities from cpuid(0xd,0x1) and max structure sizes from cpuid(0xd,0x0). Message-ID: <20240124080019.8136-1-valentio@free.fr>
2024-01-27ioapic: Remove IMCR toggleDamien Zammit
Since we are not using legacy MP tables but intending to use ACPI to configure interrupt routing, we can assume all boards have virtual wire mode, thus do not require setting of IMCR register. (This may fix crashes on machines that do not have IMCR registers). Message-ID: <20240124035138.1044855-2-damien@zamaudio.com>
2024-01-20console: Fix baud rate on com ports, use 115200 default baud, 8 data bitsDamien Zammit
TESTED: By booting gnumach off an HP T620 with console=com0 and receiving 115200 8N1 console on another machine connected via the serial port in minicom. Without this patch, part of the console is garbled by mismatching com params (9600 7N1). Message-ID: <20240119031214.691086-1-damien@zamaudio.com>
2023-12-17x86_64: Support 8 byte inlined port rights to avoid message resizing.Flavio Cruz
If a port is inlined in a message, the user has to use mach_port_name_inlined_t to define each port. Out of line memory continues to use mach_port_name_t since that memory has to be copied to the kernel anyway. Both copyinmsg and copyoutmsg can be reduced to nothing (if we ignore USER32) as a follow up but kept this patch simple for ease of review.
2023-12-03Revert "x86_64: Support 8 byte inlined port rights to avoid message resizing."Samuel Thibault
This reverts commit 29d4bcaafc4c2040df27a6247603c68e7757205c.
2023-12-03Xen: fix buildSamuel Thibault
2023-12-03x86_64: Support 8 byte inlined port rights to avoid message resizing.Flavio Cruz
If a port is inlined in a message, the user has to use mach_port_name_inlined_t to define each port. Out of line memory continues to use mach_port_name_t since that memory has to be copied to the kernel anyway. Both copyinmsg and copyoutmsg can be reduced to nothing (if we ignore USER32) as a follow up but kept this patch simple for ease of review. Message-ID: <ZWg00XzFPqqL1yF-@jupiter.tail36e24.ts.net>
2023-10-28locore: Homogeneize 32bit and 64bitSamuel Thibault
2023-10-2864bit: Fix locore buildSamuel Thibault
To allow references to int_stack_base to be quite unconstrained, we need to use 64bit register indexing. CPU_NUMBER_NO_GS was missing a 64bit variant. CPU_NUMBER_NO_STACK assumes being passed a 32bit register.
2023-10-2864bit: Fix types in lock.hSamuel Thibault
simple locks use natural_t, and indexes for bt/bts/btr have to be 32bit.
2023-10-27Factorize more push/pop codeSamuel Thibault
2023-10-27locore: Also factorize segment management on i386Samuel Thibault
and harmonize i386/x86_64. This btw fixes not using dx in 32-on-64's alltraps.
2023-10-03Fix interrupt handlingDamien Zammit
Logic for interrupts: - interrupt.S raises spl (thus IF cleared) - interrupt.S EOI - interrupt.S calls the handler - for pure in-kernel handlers, they do whatever they want with IF cleared. - when a userland handler is registers, queue_intr masks the irq. - interrupt.S lowers spl with splx_cli, thus IF still cleared - iret, that sets IF - later on, userland acks the IRQ, that unmasks the irq The key to this change is that all interrupts, including IPIs, are treated the same way. Eg. the spl level is now raised before an IPI and restored after. Also, EOI is not needed inside irq_acknowledge. With this change and the experimental change not to dispatch threads direct to idle processors in the scheduler, I no longer observe kernel faults, but an occasional hang does occur. Message-Id: <20231002033906.124427-1-damien@zamaudio.com>
2023-10-02Fix non-PAE buildSamuel Thibault
2023-10-01copyinmsg: Check that we have not overflownSamuel Thibault
This if of course too late in case of a failure, but better assert than get awful bugs, and it's really not supposed to happen.
2023-10-01com/lpr: Handle masking of interrupts in the driverDamien Zammit
Message-Id: <20231001045755.95707-1-damien@zamaudio.com>
2023-10-01kd: Handle masking of keyboard interrupt in the driverDamien Zammit
Message-Id: <20231001045731.95682-1-damien@zamaudio.com>
2023-10-01pmap: Factorize l4 base accessSamuel Thibault
This also makes the code more coherent with other levels.
2023-10-01ddb: Add whatis commandSamuel Thibault
This is convenient when tracking buffer overflows
2023-09-30ioapic: Add simple locking for non-atomic accessesDamien Zammit
Message-Id: <20230930063032.75232-3-damien@zamaudio.com>
2023-09-30ioapic: Detect version of IOAPIC for correct EOI handlingDamien Zammit
Message-Id: <20230930063032.75232-2-damien@zamaudio.com>
2023-09-28x86_64: Drop segments from thread statusSamuel Thibault
They are useless on x86_64.
2023-09-28x86_64: remove more unneeded segment selectors handling on full 64bitSamuel Thibault
This follows aaa33bd1ef300380279d9e2875b61a7abaf2c88d
2023-09-27percpu: simplify access in NCPUS==1 caseSamuel Thibault