summaryrefslogtreecommitdiff
path: root/i386
AgeCommit message (Collapse)Author
2021-12-29ddb: Fix updating sp while progressing through framesSamuel Thibault
Notably trap/interrupt/syscall provide an exact SP value.
2021-12-29ddb: Unwind over RETSamuel Thibault
When we don't have a frame but PC points to a RET instruction (e.g. in the userland system call assembly code), we can trivially unwind it.
2021-12-28ddb: Fix accessing high memorySamuel Thibault
User processes loaded in high memory are not visible to ddb through the direct mapping. We can however read/write data through copy_from/to_phys.
2021-12-16rtc: drop message on setting RTC timeSamuel Thibault
We haven't seen the 2032 bug for a long time, f040677be3c0 ("kd: Do not read the CMOS ram") probably fixed it at last.
2021-11-28memmmap: Use biosmem_addr_available rather than vm_page_lookup_paSamuel Thibault
The segment code actually has vm_page entries for reserved pages, and thus memmmap would reject mapping ACPI pages. Taking the information from biosmem is much more precise, and indeed knows all hardware quirks which can now be dropped from memmmap.
2021-10-17memory_object_create_proxy: Make len parameter vm_size_array_tSamuel Thibault
This is a no-op on i386. * i386/include/mach/i386/vm_types.h (vm_size_array_t): New type. * include/mach/mach4.defs (vm_size_array_t): New type. (memory_object_create_proxy): Turn len parameter from vm_offset_array_t to vm_size_array_t. * vm/memory_object_proxy.c (memory_object_create_proxy): Turn len parameter from const vm_offset_t * to const vm_size_t *.
2021-09-23i386/i386/fpu.h: Fix xrstor and xrstors macrosSamuel Thibault
xrstor and xrstors also take the xsave support bitmask. We were otherwise not necessarily properly reloading all the FPU state, thus leading to various subtle bugs, notably with glibc 2.33's ifunc-optimized memcpy etc. * i386/i386/fpu.h (xrstor, xrstors): Pass fp_xsave_support in EDX:EAX.
2021-09-23i386/i386/fpu.h: Drop spurious backslashesSamuel Thibault
2021-08-27vm_page_grab: allow allocating in high memorySamuel Thibault
vm_page_grab was systematically using the VM_PAGE_SEL_DIRECTMAP selector to play safe with existing code. This adds a flags parameter to let callers of vm_page_grab specify their constraints. Linux drivers need 32bit dmas, Xen drivers use kvtophys to clear some data. Callers of kmem_pagealloc_physmem and vm_page_grab_phys_addr also use kvtophys. Otherwise allocations can go to highmem. This fixes the allocation jam in the directmap segment. * vm/vm_page.h (VM_PAGE_DMA, VM_PAGE_DMA32, VM_PAGE_DIRECTMAP, VM_PAGE_HIGHMEM): New macros. (vm_page_grab): Add flags parameter. * vm/vm_resident.c (vm_page_grab): Choose allocation selector according to flags parameter. (vm_page_convert, vm_page_alloc): Pass VM_PAGE_HIGHMEM to vm_page_grab. (vm_page_grab_phys_addr): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * vm/vm_fault.c (vm_fault_page): Pass VM_PAGE_HIGHMEM to vm_page_grab. * vm/vm_map.c (vm_map_copy_steal_pages): Pass VM_PAGE_HIGHMEM to vm_page_grab. * kern/slab.c (kmem_pagealloc_physmem): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * i386/intel/pmap.c (pmap_page_table_page_alloc): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * xen/block.c (device_read): Pass VM_PAGE_DIRECTMAP to vm_page_grab. * linux/dev/glue/block.c (alloc_buffer): Pass VM_PAGE_DMA32 to vm_page_grab.
2021-04-05rtc: Add read/write messagesSamuel Thibault
We are still having issues with bogus dates. This adds prints at boot and time set, to make sure what we actually read and write. * i386/i386at/rtc.c: Include <kern/printf.h> (readtodc): Warning about reaching CENTURY_START. Print the time read from RTC. (writetodc): Record in RTC remainder of division of year by 100 rather than subtracting 1900. Print the time written to RTC.
2021-04-05kd: Do not read the CMOS ramSamuel Thibault
This could conflict with read/writing the RTC. * i386/i386at/kd.c (kd_xga_init): Do not read the CRAM. We were always assuming VGA anyway.
2021-04-05apic: Also unmask irq 3 and 4 earlySamuel Thibault
We unmasked by hand kd's irq 1, but com0/1 also need unmasking. More generally we should unmask irqs as appropriate. * i386/i386at/model_dep.c (machine_init): Unmask irq 3 and 4.
2021-04-05ioapic: Fix arg passing of redirection entryDamien Zammit
Message-Id: <20210405115921.184572-3-damien@zamaudio.com>
2021-04-05ioapic: Refactor EOIDamien Zammit
Message-Id: <20210405115921.184572-2-damien@zamaudio.com>
2021-04-05ioapic: Use irq specific EOI properly when detectedDamien Zammit
Message-Id: <20210405052916.174771-5-damien@zamaudio.com>
2021-04-05Don't call EOI on spurious interruptsDamien Zammit
Message-Id: <20210405052916.174771-4-damien@zamaudio.com>
2021-04-05ioapic: target first processor for interruptsDamien Zammit
Message-Id: <20210405052916.174771-3-damien@zamaudio.com>
2021-04-05ioapic: Enable processor focus to BSPDamien Zammit
Message-Id: <20210405052916.174771-2-damien@zamaudio.com>
2021-04-04SMP: Fix warningsSamuel Thibault
2021-04-04SMP: fix getting the interrupt stack address and sizeSamuel Thibault
* 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.
2021-04-04Add ioapic support disabled by defaultDamien Zammit
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>
2021-04-03pit: Add more macrosSamuel Thibault
* i386/i386/pit.h (PITAUX_VAL, PIT_C2): New macros. (PIT_RATEMODE): Fix macro value.
2021-03-31Keep BIOS mapped even without LinuxSamuel Thibault
Not only Linux drivers need BIOS mapped. * i386/i386at/model_dep.c (i386at_init) [!LINUX_DEV]: Map the low memory. * i386/intel/pmap.c (pmap_create) [!LINUX_DEV]: Likewise.
2021-03-29apic: Reorder definesDamien Zammit
2021-03-28pic: Move to interrupts 0x20-0x2fDamien Zammit
* i386/i386/pic.h (PICM_VECTBASE): Set to 0x20. * i386/i386at/idt.h (IDTSZ): Set to 0x20 + 0x10. (PIC_INT_BASE): Set to 0x20.
2021-03-28Existing SMP apic code improvementsDamien Zammit
* i386/i386/apic.c (acpi_get_irq_override): New function. (apic_get_ioapic): Make it return IoApicData* rather than IoApicData. (apic_print_info): Manage IoApicData* rather than IoApicData. * i386/i386/apic.h (struct ApicReg): Use uint32_t instead of unsigned. (struct ioapic_route_entry): New structure. (union ioapic_route_entry_union): New union. (ApicLocalUnit): Rename base to gsi_base. Add ioapic field. (APIC_IRQ_OVERRIDE_POLARITY_MASK, APIC_IRQ_OVERRIDE_TRIGGER_MASK): New macros. (acpi_get_irq_override, ): New prototype. (apic_get_ioapic): Update prototype. (lapic): New declaration. (IMCR_SELECT, IMCR_DATA, MODE_IMCR, IMCR_USE_PIC, IMCR_USE_APIC, LAPIC_ENABLE, LAPIC_NMI, LAPIC_DISABLE, LAPIC_TIMER_PERIODIC, LAPIC_TIMER_DIVIDE_2, LAPIC_TIMER_DIVIDE_4, LAPIC_TIMER_DIVIDE_8, LAPIC_TIMER_DIVIDE_16, LAPIC_TIMER_BASEDIV, NINTR, IOAPIC_FIXED, IOAPIC_PHYSICAL, IOAPIC_LOGICAL, IOAPIC_NMI, IOAPIC_EXTINT, IOAPIC_ACTIVE_HIGH, IOAPIC_ACTIVE_LOW, IOAPIC_EDGE_TRIGGERED, IOAPIC_LEVEL_TRIGGERED, IOAPIC_MASK_ENABLED, IOAPIC_MASK_DISABLED): New macros. * i386/i386at/acpi_parse_apic.h (struct acpi_apic_ioapic): Rename base field to gsi_base. * i386/i386at/acpi_parse_apic.c (acpi_apic_add_ioapic): Update to gsi_base new name. Set ioapic field. (acpi_apic_setup): Rename lapic to lapic_unit. Message-Id: <20210328060320.36194-5-damien@zamaudio.com>
2021-03-28Don't allow writing to acpi table in memoryDamien Zammit
* i386/i386at/acpi_parse_apic.c (acpi_get_apic): Map rsdt entries read-only. Message-Id: <20210328060320.36194-4-damien@zamaudio.com>
2021-03-28fixup acpi base table searchDamien Zammit
* i386/i386at/acpi_parse_apic.c (acpi_check_rsdp_align): Make it take a void* instead of uint32_t. (acpi_get_rsdp): Apply phystokv on the EBDA base and 0xE0000. (acpi_apic_setup): Drop spurious negation. Message-Id: <20210328060320.36194-3-damien@zamaudio.com>
2021-02-11i386 fpu: fix bogus checkAndrea G. Monaco
Avoid panicing on all CPUs that do not support xsaves. * i386/i386/fpu.c (init_fpu): Panic on CPUs that do not support xsaves only if the cpu-reported xsave size is smaller than expected.
2021-02-03com: Fix bogus NCOM testAndrea G. Monaco
* i386/i386at/com.c (comprobe_general): Reject unit being equal to NCOM.
2021-01-09add a missing include header guard.guy fleury iteriteka
* i386/i386at/comreg.h: Add header guard angaist multiple inclusion. Message-Id: <20210109180149.11861-1-gfleury@disroot.org>
2020-12-23Fix _Static_assert callSamuel Thibault
Before C2X, _Static_assert requires a second parameter Reported by Andrea G. Monaco <andrea.monaco@autistici.org> * i386/i386/fpu.c: Add second parameter to _Static_assert calls.
2020-12-07i386at: Really disable com and lpr above NCOM and NLPRSamuel Thibault
commmodem and lprinfo arrays would otherwise overflow. * i386/i386at/com.c (comattach): Return early when unit is beyond NCOM. * i386/i386at/lpr.c (lprattach): Return early when unit is beyond NLPR.
2020-12-02pmap: Note that we should support PCIDSamuel Thibault
2020-12-01x86: Move fp_reg.h static assertions to .c fileSamuel Thibault
Since fp_reg.h is installed on the system, and compilers may not even support _Static_assert. * i386/include/mach/i386/fp_reg.h: Move _Static_assert to... * i386/i386/fpu.c: ... c file.
2020-12-01x86: Keep fp_regs.h standaloneSamuel Thibault
We cannot include stdint.h in fp_regs.h since this is included by mach_types.h for bootstrapping, before we have stdint.h from glibc. * i386/include/mach/i386/fp_reg.h: Do not include <stdint.h> (XSAVE_XCOMP_BV_COMPACT, struct i386_xfp_xstate_header): Use unsigned long long instead of uint64_t.
2020-11-29x86: Get default state from the CPU itselfSamuel Thibault
It seems that at least qemu does not like our initial state. We can as well just take it from fninit. * i386/i386/fpu.c (MXCSR_DEFAULT, CWD_DEFAULT): Remove macros. (fpu_module_init): Get default state from CPU. (fpinit): Do not call fninit.
2020-11-29x86: Make sure we allocate as much as our structure should holdSamuel Thibault
* i386/i386/fpu.c (init_fpu): Panic if the CPU gives us a size that is smaller than it should.
2020-11-29x86: clear exceptions etc. on fpinitSamuel Thibault
fpu_rstor is not enough, exceptions and such remain behind, so restore calling fninit. * i386/i386/fpu.c (fpinit): call fninit() before fpu_rstor().
2020-11-29x86: Fix initial control wordSamuel Thibault
The value in fp_state_alloc was actually an oldie, the value in fpinit was the expected one nowadays. * i386/i386/fpu.c (CWD_DEFAULT): Set to 0x37f.
2020-11-29x86: Fix initialization of new threadsSamuel Thibault
fninit does not clear MMX/SSE/AVX registers, so we have to use rstor to clear them when starting a new thread. Along the way, we can as well just have a default state to be loaded in each new thread. * i386/include/mach/i386/fp_reg.h (XSAVE_XCOMP_BV_COMPACT): New macro. * i386/i386/fpu.h (fp_default_state): New variable declaration. * i386/i386/fpu.c (fp_default_state): New variable. (MXCSR_DEFAULT, CWD_DEFAULT): New macros. (fpu_module_init): Allocate and initialize fp_default_state. (fpinit): rstor from fp_default_state instead of setting FPU state by hand. (fp_load): Copy initial state from fp_default_state instead of setting it to 0. This is more future-proof since this is the exact state that we are loading in fpinit. (fp_state_alloc): fp_state_alloc: Copy initial state from fp_default_state.
2020-11-29x86: Factorize fpu save/restoreSamuel Thibault
* i386/i386/fpu.h (fpu_save, fpu_rstor): New macros. (fpu_save_context): Use fpu_save macro. * i386/i386/fpu.c (fp_save): Use fpu_save macro. (fp_load): Use fpu_rstor macro.
2020-11-28x86: Drop XSAVE support limitationSamuel Thibault
Now that XSAVEOPT is supported, we are fine with supporting large FPU state. * i386/i386/fpu.c (init_fpu): Do not limit fp_xsave_support to CPU_XCR0_SUPPORTED. * i386/i386/fpu.h (CPU_XCR0_SUPPORTED): Remove macro.
2020-11-28x86: Add XSAVEOPT, XSAVEC, XSAVES supportSamuel Thibault
* i386/i386/fpu.h (CPU_FEATURE_XSAVEOPT, CPU_FEATURE_XSAVEC, CPU_FEATURE_XGETBV1, CPU_FEATURE_XSAVES): New macros. (xsaveopt, xsavec, xsaves, xrstors): New macros. (fpu_save_context): Use xsaveopt, xsavec, or xsaves when available. (fp_save_kind): New enum. (fp_save_kind): New variable declaration. * i386/i386/fpu.c (fp_save_kind): New variable. (init_fpu): Set fp_save_kind according to enumeration. When XSAVES is supported, use xsave area size from corresponding enumeration. (fp_save): Use xsaveopt, xsavec, xsaves when available. (fp_load): Use xrstors when available.
2020-11-28x86: Extend XSAVE support to unbound stateSamuel Thibault
* i386/i386/fpu.c (fp_xsave_size): New variable. (init_fpu): Save XSAVE size to fp_xsave_size. (fpu_module_init): Pass fp_xsave_size as size to kmem_cache_init. (fpu_set_state, fp_load, fp_state_alloc): Use fp_xsave_size to clear ifps. * i386/include/mach/i386/fp_reg.h (struct i386_xfp_save): Replace static fp_yreg_word with extended field. * i386/i386/thread.h (struct i386_fpsave_state): Make fp_valid field first in the structure to let the extended finish the structure.
2020-11-28x86: Add XSAVE supportSamuel Thibault
* i386/i386/fpu.h (CPU_XCR0_X87, CPU_XCR0_SSE, CPU_XCR0_AVX, CPU_XCR0_MPX, CPU_XCR0_AVX512): New macros. (xsave): Pass fp_xsave_support to xsave. (fpu_save_context): When fp_kind is FP_387X, use xsave. (fp_xsave_support): New variable declaration. * i386/i386/proc_reg.h (cpuid): New macro. * linux/src/include/asm-i386/processor.h (cpuid): Disable macro. * i386/include/mach/i386/fp_reg.h: Include <stdint.h> (i386_xfp_xstate_header): New structure. (i386_xfp_save): Add xsave fields. * i386/i386/fpu.c (fp_xsave_support): New variable. (init_fpu): Look for XSAVE feature; if available, get the supported parts and set fp_kind to FP_387X. (fpu_module_init): Set ifps_cache alignment to alignof(struct i386_fpsave_state). (fpu_set_state): Make sure to clear all the ifps structure. Reuse the FP_387FX for the FP_387X case. (fpu_get_state, fpexterrflt, fpastintr, fp_state_alloc): Reuse the FP_387FX for the FP_387X case. (fp_save): When fp_kind is FP_387X, use xsave. (fp_load): When fp_kind is FP_387X, use xrstor. Reuse the FP_387FX for the FP_387X case.
2020-11-28fpu: Rename FP_387X to FP_387FXSamuel Thibault
To leave FP_387X for XSAVE-supporting CPU (as opposed to FXSAVE-supporting CPU) * i386/include/mach/i386/fp_reg.h (FP_387X): Rename to FP_387FX. (FP_387X): New macro. * i386/i386/fpu.c (init_fpu, fpu_set_state, fpu_get_state, fpexterrflt, fpastintr, fp_save, fp_load, fp_state_alloc): Update accordingly. * i386/i386/fpu.h (fpu_save_context): Likewise.
2020-11-28fp_reg: update to latest SSE supported by FXSAVESamuel Thibault
* i386/include/mach/i386/fp_reg.h (struct i386_xfp_save): Extend fp_xreg_word to 16 registers. (sizeof(struct i386_xfp_save)): Assert that it is equal to 512.
2020-11-28x86: Pave the way for xsave/xrstor supportSamuel Thibault
* 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.
2020-11-28x86: allow using 8bit constants in in/out instructionsSamuel Thibault
* i386/i386/pio.h (inl, inw, inb, outl, outw, outb): Add N constraint alternative on port. (outl): Cast data to unsigned int.